Пример #1
0
def lts_save(tday):
    logging.basicConfig(
        filename="save_lts_agent.log",
        level=logging.INFO,
        format=
        '%(name)s:%(funcName)s:%(lineno)d:%(asctime)s %(levelname)s %(message)s'
    )
    app_name = 'lts_save_agent'
    save_insts = [
        "510180", "510050", "11000011", "11000016", "11000021", "11000026",
        "11000031", "11000036"
    ]
    my_agent = agent.SaveAgent(name=app_name,
                               trader=None,
                               cuser=None,
                               instruments=save_insts,
                               daily_data_days=0,
                               min_data_days=0,
                               tday=tday)
    lts_api.make_user(my_agent, LTS_SO_USER, save_insts)
    try:
        while 1:
            time.sleep(1)

    except KeyboardInterrupt:
        my_agent.mdapis = []
        my_agent.trader = None
Пример #2
0
 def onRestart(self):
     if self.agent != None:
         self.scur_day = self.agent.scur_day
     save_insts = filter_main_cont(self.scur_day)
     self.agent = agent.SaveAgent(name = self.name, trader = None, cuser = None, instruments=save_insts, daily_data_days=0, min_data_days=0, tday = tday)
     self.agent.logger.addHandler(self.text_handler)
     fut_api.make_user(self.agent, misc.PROD_USER)
     return
Пример #3
0
def save_LTS(user, insts, run_date):
    app_name = 'SaveAgent'
    my_agent = agent.SaveAgent(name = app_name, trader = None, cuser = None, instruments=insts, daily_data_days=0, min_data_days=0, tday = run_date)
    lts_api.make_user(my_agent, user, insts)
    try:
        while 1: time.sleep(1)
    except KeyboardInterrupt:
        my_agent.mdapis = []; my_agent.trader = None
Пример #4
0
def save_all(tday):
    logging.basicConfig(filename="save_all_agent.log",level=logging.INFO,format='%(name)s:%(funcName)s:%(lineno)d:%(asctime)s %(levelname)s %(message)s')
    save_insts = filter_main_cont(tday)
    app_name = 'SaveAgent'
    my_agent = agent.SaveAgent(name = app_name, trader = None, cuser = None, instruments=save_insts, daily_data_days=0, min_data_days=0, tday = tday)
    fut_api.make_user(my_agent, misc.PROD_USER)
    try:
        while 1:
            time.sleep(1)
            
    except KeyboardInterrupt:
        my_agent.mdapis = []; my_agent.trader = None
Пример #5
0
def save_lts_test(tday):
    prod_md = misc.LTS_SO_USER
    base.config_logging("save_lts_test.log", level=logging.DEBUG,
                   format = '%(name)s:%(funcName)s:%(lineno)d:%(asctime)s %(levelname)s %(message)s',
                   to_console = True,
                   console_level = logging.INFO)
    save_insts = ['510050']
    app_name = 'SaveAgent'
    config = {'daily_data_days': 0, 'min_data_days': 0}
    my_agent = agent.SaveAgent(name = app_name, trader = None, cuser = None, instruments=save_insts, tday = tday, config = config)
    lts_api.make_user(my_agent, prod_md)
    try:
        my_agent.resume()
        while 1:
            time.sleep(1)
    except KeyboardInterrupt:
        my_agent.exit()
Пример #6
0
def save_ctp(tday):
    prod_md = misc.HT_PROD_MD
    base.config_logging("save_all_agent.log", level=logging.DEBUG,
                   format = '%(name)s:%(funcName)s:%(lineno)d:%(asctime)s %(levelname)s %(message)s',
                   to_console = True,
                   console_level = logging.INFO)
    save_insts = filter_main_cont(tday, filter = False)
    print "total inst = %s" % len(save_insts)
    app_name = 'SaveAgent'
    config = {'daily_data_days': 0, 'min_data_days': 0}
    my_agent = agent.SaveAgent(name = app_name, trader = None, cuser = None, instruments=save_insts,tday = tday, config = config)
    ctp_api.make_user(my_agent, prod_md)
    try:
        my_agent.resume()
        while 1:
            time.sleep(1)
    except KeyboardInterrupt:
        my_agent.exit()
Пример #7
0
 def __init__(self, instrument, tday=0):
     self.instrument = instrument
     self.agent = agent.SaveAgent(None, None, [instrument], {}, tday=tday)