def lts_test(tday, name='lts_test'): logging.basicConfig( filename="lts_" + name + ".log", level=logging.DEBUG, format= '%(name)s:%(funcName)s:%(lineno)d:%(asctime)s %(levelname)s %(message)s' ) trader_cfg = LTS_SO_TRADER user_cfg = LTS_SO_USER agent_name = name insts = [ "510180", "510050", "11000011", "11000016", "11000021", "11000026", "11000031", "11000036" ] strat_cfg = {'strategies': [], \ 'folder': 'C:\\dev\\src\\ktlib\\pythonctp\\pyctp\\', \ 'daily_data_days':0, \ 'min_data_days':0 } myagent = lts_api.create_agent(agent_name, user_cfg, trader_cfg, insts, strat_cfg, tday) try: myagent.resume() # position/trade test myagent.positions['510050'].pos_tday.long = 2 myagent.positions['510050'].pos_tday.short = 2 #myagent.positions['cu1502'].pos_yday.long = 0 #myagent.positions['cu1502'].pos_yday.short = 0 myagent.positions['510050'].re_calc() myagent.positions['510050'].re_calc() valid_time = myagent.tick_id + 10000 etrade = order.ETrade(['510050'], [1], [OPT_LIMIT_ORDER], 2.50, [0], valid_time, 'test', myagent.name) myagent.submit_trade(etrade) myagent.process_trade_list() #myagent.tick_id = valid_time - 10 #for o in myagent.positions['cu1501'].orders: #o.on_trade(2000,o.volume,141558400) #o.on_trade(2010,1,141558500) myagent.process_trade_list() myagent.positions['510050'].re_calc() myagent.positions['510050'].re_calc() #while 1: time.sleep(1) except KeyboardInterrupt: myagent.mdapis = [] myagent.trader = None
def test_main(tday=datetime.date.today()): logging.basicConfig(filename="test_lts_agent.log",level=logging.INFO,format='%(name)s:%(funcName)s:%(lineno)d:%(asctime)s %(levelname)s %(message)s') app_name = 'lts_agent' insts = ['510050', '510050C1502M02500', '510050P1502M02500'] strategies = [] trader_cfg = LTS_SO_TRADER user_cfg = LTS_SO_USER strat_cfg = {'strategies': strategies, \ 'folder': 'C:\\dev\\src\\ktlib\\pythonctp\\pyctp\\', \ 'daily_data_days':0, \ 'min_data_days':0 } myagent = lts_api.create_agent(app_name, user_cfg, trader_cfg, insts, strat_cfg, tday) try: myagent.resume() except KeyboardInterrupt: myagent.mdapis = []; myagent.trader = None
def lts_test(tday, name='lts_test'): logging.basicConfig(filename="lts_" + name + ".log",level=logging.DEBUG,format='%(name)s:%(funcName)s:%(lineno)d:%(asctime)s %(levelname)s %(message)s') trader_cfg = LTS_SO_TRADER user_cfg = LTS_SO_USER agent_name = name insts = [ "510180", "510050", "11000011", "11000016", "11000021", "11000026", "11000031", "11000036"] strat_cfg = {'strategies': [], \ 'folder': 'C:\\dev\\src\\ktlib\\pythonctp\\pyctp\\', \ 'daily_data_days':0, \ 'min_data_days':0 } myagent = lts_api.create_agent(agent_name, user_cfg, trader_cfg, insts, strat_cfg, tday) try: myagent.resume() # position/trade test myagent.positions['510050'].pos_tday.long = 2 myagent.positions['510050'].pos_tday.short = 2 #myagent.positions['cu1502'].pos_yday.long = 0 #myagent.positions['cu1502'].pos_yday.short = 0 myagent.positions['510050'].re_calc() myagent.positions['510050'].re_calc() valid_time = myagent.tick_id + 10000 etrade = order.ETrade( ['510050'], [1], [OPT_LIMIT_ORDER], 2.50, [0], valid_time, 'test', myagent.name) myagent.submit_trade(etrade) myagent.process_trade_list() #myagent.tick_id = valid_time - 10 #for o in myagent.positions['cu1501'].orders: #o.on_trade(2000,o.volume,141558400) #o.on_trade(2010,1,141558500) myagent.process_trade_list() myagent.positions['510050'].re_calc() myagent.positions['510050'].re_calc() #while 1: time.sleep(1) except KeyboardInterrupt: myagent.mdapis = []; myagent.trader = None
def test_main(tday=datetime.date.today()): logging.basicConfig( filename="test_lts_agent.log", level=logging.INFO, format= '%(name)s:%(funcName)s:%(lineno)d:%(asctime)s %(levelname)s %(message)s' ) app_name = 'lts_agent' insts = ['510050', '510050C1502M02500', '510050P1502M02500'] strategies = [] trader_cfg = LTS_SO_TRADER user_cfg = LTS_SO_USER strat_cfg = {'strategies': strategies, \ 'folder': 'C:\\dev\\src\\ktlib\\pythonctp\\pyctp\\', \ 'daily_data_days':0, \ 'min_data_days':0 } myagent = lts_api.create_agent(app_name, user_cfg, trader_cfg, insts, strat_cfg, tday) try: myagent.resume() except KeyboardInterrupt: myagent.mdapis = [] myagent.trader = None