You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.2 KiB
47 lines
1.2 KiB
# -*- coding: utf-8 -*-
|
|
|
|
import time
|
|
import logging
|
|
from binance.binance_trader import BinanceTrader
|
|
from binance.binance_future_trader import BinanceFutureTrader
|
|
from utils import utility
|
|
from utils import config
|
|
format = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
|
|
logging.basicConfig(level=logging.INFO, format=format, filename='grid_trader_log.txt')
|
|
logger = logging.getLogger('binance')
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
|
config.loads('./conf/config.json')
|
|
sleep_time = 5
|
|
if config.sleep_time:
|
|
sleep_time = config.sleep_time
|
|
|
|
if config.platform == 'binance_spot':
|
|
trader = BinanceTrader()
|
|
else:
|
|
trader = BinanceFutureTrader()
|
|
|
|
#启动新实例, 取消客户端创建的订单
|
|
print("启动新实例, 同步本客户端创建的订单:")
|
|
trader.sync_open_orders()
|
|
|
|
#启动新实例 发个通知
|
|
utility.alert(f"{utility.cn_time()} 交易对{config.symbol}启动")
|
|
|
|
|
|
|
|
|
|
|
|
while True:
|
|
try:
|
|
trader.grid_trader()
|
|
time.sleep(sleep_time)
|
|
|
|
except Exception as error:
|
|
utility.alert(f"交易{config.symbol}: {error}")
|
|
time.sleep(sleep_time)
|
|
|