質問編集履歴

1

2018/05/08 16:24

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -65,119 +65,3 @@
65
65
  Process finished with exit code 1
66
66
 
67
67
  ```
68
-
69
-
70
-
71
- ソースファイルは以下になります。
72
-
73
-
74
-
75
-
76
-
77
- ```ここに言語を入力
78
-
79
- ccxt_test.py
80
-
81
- import ccxt
82
-
83
-
84
-
85
- exchanges = {
86
-
87
- "bitflyer": {
88
-
89
- "apiKey": "hoge",
90
-
91
- "secret": "hoge"
92
-
93
- },
94
-
95
- "bitbank": {
96
-
97
- "apiKey": "hoge",
98
-
99
- "secret": "hoge"
100
-
101
- }
102
-
103
- }
104
-
105
-
106
-
107
- amount = 0.001
108
-
109
- ask_exchange = ''
110
-
111
- ask_price = 99999999
112
-
113
- bid_exchange = ''
114
-
115
- bid_price = 0
116
-
117
-
118
-
119
- # 各取引所のaskとbidを取得
120
-
121
- for exchange_id in exchanges:
122
-
123
- exchange = eval('ccxt.' + exchange_id + '()')
124
-
125
-
126
-
127
- orderbook = exchange.fetch_order_book('BTC/JPY')
128
-
129
- bid = orderbook['bids'][0][0] if len(orderbook['bids']) > 0 else None
130
-
131
- ask = orderbook['asks'][0][0] if len(orderbook['asks']) > 0 else None
132
-
133
- if ask < ask_price:
134
-
135
- ask_exchange = exchange_id
136
-
137
- ask_price = ask
138
-
139
- if bid > bid_price:
140
-
141
- bid_exchange = exchange_id
142
-
143
- bid_price = bid
144
-
145
-
146
-
147
- # 裁定取引を行う
148
-
149
- #買い
150
-
151
- ask_price = int(ask_price/5)*5
152
-
153
- exchange = eval('ccxt.' + ask_exchange + '()')
154
-
155
- exchange.apiKey = exchanges[ask_exchange]["apiKey"]
156
-
157
- exchange.secret = exchanges[ask_exchange]["secret"]
158
-
159
- exchange.create_limit_buy_order ('BTC/JPY', amount, ask_price)
160
-
161
-
162
-
163
- #売り
164
-
165
- bid_price = int(bid_price*5)/5
166
-
167
- exchange = eval('ccxt.' + bid_exchange + '()')
168
-
169
- exchange.apiKey = exchanges[bid_exchange]["apiKey"]
170
-
171
- exchange.secret = exchanges[bid_exchange]["secret"]
172
-
173
- exchange.create_limit_sell_order ('BTC/JPY', amount, bid_price)
174
-
175
-
176
-
177
- print(ask_exchange, 'で', ask_price, '円で', amount, '買って')
178
-
179
- print(bid_exchange, 'で', bid_price, '円で', amount, '売ったので')
180
-
181
- print((bid_price - ask_price)*amount, '円の利益!')
182
-
183
- ```