Created
November 30, 2018 14:28
-
-
Save arms22/f065cd1b2840d7f9889805d28ce402d1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import asyncio | |
import ccxt.async_support as ccxt | |
from random import gauss, uniform | |
async def main(): | |
api = ccxt.bitflyer({'apiKey':'xxxx','secret':'xxxx'}) | |
async def wabi(no): | |
while True: | |
try: | |
qty = gauss(0,1) | |
latelimit = uniform((60/200*8/4), (60/200*8/16)) | |
if qty > 0: | |
res = await api.create_market_buy_order('FX_BTC_JPY', qty) | |
elif qty < 0: | |
res = await api.create_market_sell_order('FX_BTC_JPY', -qty) | |
print(res) | |
except Exception as e: | |
print(e) | |
await asyncio.sleep(latelimit) | |
# 8並列実行 | |
return await asyncio.wait([wabi(i) for i in range(0,8)]) | |
if __name__ == "__main__": | |
loop = asyncio.get_event_loop() | |
loop.run_until_complete(asyncio.wait([main()])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment