def main(): # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> gateway_setting = load_json("connect_okex.json") setting_filename = "fsa_setting_test_okex.json" # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> event_engine = EventEngine() log_engine = LogEngine(event_engine, log_level=DEBUG, log_name='fsa1') fsa_engine = SpreadEngine(event_engine, setting_filename) fsa_engine.add_gateway(OkexGateway) fsa_engine.add_gateway(OkexsGateway) fsa_engine.write_log('Add gateway finished!') fsa_engine.start() fsa_engine.connect(gateway_setting, 'OKEX') fsa_engine.connect(gateway_setting, 'OKEXS') fsa_engine.write_log('Gateways is connecting, and sleep 20 seconds!') sleep(15) while True: # print('sleep') sleep(10)
def main(): # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> huobi_setting = load_json("connect_huobi.json") binance_setting = load_json("connect_binance.json") setting_filename = "fsa_setting_test.json" # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> event_engine = EventEngine() log_engine = LogEngine(event_engine, log_level=DEBUG, log_name='fsa1') fsa_engine = SpreadEngine(event_engine, setting_filename) fsa_engine.add_gateway(BinanceFuturesGateway) fsa_engine.add_gateway(HbdmGateway) fsa_engine.write_log('Add gateway finished!') fsa_engine.start() fsa_engine.connect(huobi_setting, 'HBDM') fsa_engine.connect(binance_setting, 'BINANCEFUTURES') fsa_engine.write_log('Gateways is connecting, and sleep 20 seconds!') sleep(15) while True: # print('sleep') sleep(10)
from Digiccy1.binance_gateway_local import BinanceGateway, BinanceFuturesGateway from Digiccy1.huobi_gateway_local import HuobiGateway, HbdmGateway db = get_sqlite('info.db') DbContractData, DbAccountData, DbBarData = init_models(db) def process_event(event:Event): print(event.type+ "*"*30) if isinstance(event.data, dict): print(event.data) else: print(event.data.__dict__) event_engine = EventEngine() event_engine.register(EVENT_LOG, process_event) event_engine.start() binance_setting = load_json("connect_binance.json") gateway = BinanceGateway(event_engine) gateway.connect(binance_setting) gateway_futures = BinanceFuturesGateway(event_engine) gateway_futures.connect(binance_setting) # huobi_setting = load_json("connect_huobi.json") # gateway = HuobiGateway(event_engine) # gateway.connect(huobi_setting) # gateway_futures = HbdmGateway(event_engine) # gateway_futures.connect(huobi_setting)
EVENT_TRADE, EVENT_POSITION, EVENT_ACCOUNT, EVENT_CONTRACT, EVENT_LOG, LogEngine ) from Digiccy1.binance_gateway_local import BinanceGateway, BinanceFuturesGateway from Digiccy1.futures_spot_arbitrage import SpreadEngine # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> binance_setting = load_json("connect_binance.json") setting_filename = "fsa_setting2_bi.json" # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> event_engine = EventEngine() log_engine = LogEngine(event_engine, log_level=CRITICAL, log_name='fsa2') fsa_engine = SpreadEngine(event_engine, setting_filename) fsa_engine.add_gateway(BinanceGateway) fsa_engine.add_gateway(BinanceFuturesGateway) fsa_engine.write_log('Add gateway finished!') fsa_engine.start() fsa_engine.connect(binance_setting, 'BINANCE') fsa_engine.connect(binance_setting, 'BINANCEFUTURES') fsa_engine.write_log('Gateways is connecting, and sleep 20 seconds!', level=CRITICAL) sleep(15)
from myObject import (TickData, OrderData, TradeData, AccountData, ContractData, OrderRequest, CancelRequest, SubscribeRequest, HistoryRequest) from myConstant import (Direction, Exchange, Product, Status, OrderType, Interval) setting = load_json("connect_huobi.json") def process_event(event: Event): print('event type:%s' % event.type) print("event data:%s" % event.data) event_engine = EventEngine() event_engine.register(EVENT_TICK, process_event) event_engine.register(EVENT_CONTRACT, process_event) event_engine.register(EVENT_POSITION, process_event) # event_engine.register(EVENT_ACCOUNT, process_event) event_engine.register(EVENT_LOG, process_event) event_engine.start() gateway = HbdmGateway(event_engine) gateway.connect(setting) req = SubscribeRequest("ethusdt", Exchange.HUOBI) # gateway.subscribe(req) # endtime = datetime.now()
from Digiccy1.okex_gateway_local import OkexGateway, OkexfGateway, OkexsGateway setting = load_json("connect_okex.json") # db = get_sqlite('info.db') # DbContractData, DbAccountData, DbBarData = init_models(db) def process_event(event: Event): print(event.type + "*" * 30) if isinstance(event.data, dict): print(event.data) else: print(event.data.__dict__) event_engine = EventEngine() event_engine.register(EVENT_TICK, process_event) # event_engine.register(EVENT_CONTRACT, process_event) event_engine.register(EVENT_ACCOUNT, process_event) event_engine.register(EVENT_ACCOUNT_MARGIN, process_event) event_engine.register(EVENT_LOG, process_event) event_engine.register(EVENT_BORROW_MONEY, process_event) event_engine.register(EVENT_REPAY_MONEY, process_event) event_engine.start() gateway1 = OkexGateway(event_engine) # gateway2 = OkexsGateway(event_engine) gateway1.connect(setting) # gateway2.connect(setting) # gateway_futures = BinanceFuturesGateway(event_engine)
from myObject import (TickData, OrderData, TradeData, AccountData, ContractData, OrderRequest, CancelRequest, SubscribeRequest, HistoryRequest) from myConstant import (Direction, Exchange, Product, Status, OrderType, Interval) setting = load_json("connect_huobi.json") def process_event(event: Event): print('event type:%s' % event.type) print("event data:%s" % event.data) event_engine = EventEngine() event_engine.register(EVENT_TICK, process_event) # event_engine.register(EVENT_CONTRACT, process_event) event_engine.register(EVENT_POSITION, process_event) # event_engine.register(EVENT_ACCOUNT, process_event) event_engine.register(EVENT_LOG, process_event) event_engine.start() gateway = HuobiGateway(event_engine) gateway.connect(setting) req = SubscribeRequest("ethusdt", Exchange.HUOBI) # gateway.subscribe(req) # endtime = datetime.now()