-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
48 lines (42 loc) · 1.22 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import time
from random import seed
from random import randint
seed(2)
txMax = 5
# MarketData
from kucoin.client import Market
market = Market(url='https://api.kucoin.com')
#market = Market()
# or connect to Sandbox
#market = Market(url='https://openapi-sandbox.kucoin.com')
#market = Market(is_sandbox=True)
api_key = ''
api_secret = ''
def returnBid(symbol):
book = market.get_aggregated_order(symbol)
return book['bids'][1][0]
# User
from kucoin.client import User
user = User(api_key, api_secret, api_passphrase)
# or connect to Sandbox
#user = User(api_key, api_secret, api_passphrase, is_sandbox=True)
def returnPrice(token):
account = market.get_ticker(token)
return account['price']
# Trade
from kucoin.client import Trade
client = Trade(api_key, api_secret, api_passphrase)
# or connect to Sandbox
# client = Trade(api_key, api_secret, api_passphrase, is_sandbox=True)# Trade
while(1):
debut = time.time()
bid = returnBid('BTC-USDT')
try:
order = client.create_limit_order('BTC-USDT', 'sell', randint(1,txMax), bid)
print(order)
fin = time.time()
print(fin - debut)
time.sleep(randint(10, 120))
except Exception as err:
print(err)
break