forked from dryob/CroSeller
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCroSeller.py
45 lines (35 loc) · 1.08 KB
/
CroSeller.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
import asyncio
import cryptocom.exchange as cro
import math
import time
api_key = "******************"
api_secret = "****************"
# Sell for USDT
# pair = cro.pairs.CRO_USDT
# or
# Sell for BTC
pair = cro.pairs.CRO_BTC
# CRO amount
threshold = 1
async def sell():
account = cro.Account(api_key=api_key, api_secret=api_secret)
data = await account.get_balance()
cro_balance = data[cro.Coin(name="CRO")].available
print(f'CRO balance {math.floor(cro_balance)}')
if cro_balance > threshold:
exchange = cro.Exchange()
price = await exchange.get_price(cro.pairs.CRO_USDT)
print(f'CRO price {price}')
result = await account.create_order(pair=pair,side=cro.OrderSide.SELL,type_=cro.OrderType.MARKET,quantity=math.floor(cro_balance))
print(result)
def main():
while True:
try:
asyncio.run(sell())
print("sleep 600s")
time.sleep(600)
except Exception as E:
time.sleep(30)
print(E)
if __name__ == '__main__':
main()