Ejemplo n.º 1
0
def run_config(name, config_file, tday = datetime.date.today(), agent_class = 'agent.Agent'):
    base.config_logging("ctp_" + name + ".log", level=logging.DEBUG,
                   format = '%(name)s:%(funcName)s:%(lineno)d:%(asctime)s %(levelname)s %(message)s',
                   to_console = True,
                   console_level = logging.INFO)
    myApp = MainApp(name, tday, config_file, agent_class = agent_class, master = None)
    myGui = Gui(myApp)
    # myGui.iconbitmap(r'c:\Python27\DLLs\thumbs-up-emoticon.ico')
    myGui.mainloop()
Ejemplo n.º 2
0
def prod_trade(tday, name='prod_trade'):
    base.config_logging(
        "ctp_" + name + ".log",
        level=logging.DEBUG,
        format=
        '%(name)s:%(funcName)s:%(lineno)d:%(asctime)s %(levelname)s %(message)s',
        to_console=True,
        console_level=logging.INFO)
    trader_cfg = misc.HT_DN_TD
    user_cfg = misc.HT_DN_MD
    ins_setup = {
        'm1605': (1, 0.7, 0.0, 2, False),
        'RM605': (1, 0.6, 0.0, 2, False),
        'y1605': (0, 0.8, 0.0, 1, False),
        'p1605': (1, 0.9, 0.0, 1, False),
        'OI601': (0, 0.7, 0.0, 0, False),
        'a1601': (0, 1.0, 0.0, 2, False),
        'rb1605': (0, 0.6, 0.0, 4, False),
        'l1605': (0, 0.7, 0.0, 1, False),
        'pp1601': (4, 0.3, 0.0, 1, False),
        'TA601': (1, 0.6, 0.0, 1, False),
        'MA601': (1, 0.8, 0.0, 2, False),
        'jd1601': (1, 0.8, 0.0, 1, False),
        'SR605': (1, 0.8, 0.0, 1, False),
    }
    insts = ins_setup.keys()
    units_dt = [ins_setup[inst][3] for inst in insts]
    under_dt = [[inst] for inst in insts]
    vol_dt = [[1] for inst in insts]
    ratios = [[ins_setup[inst][1], ins_setup[inst][2]] for inst in insts]
    lookbacks = [ins_setup[inst][0] for inst in insts]
    daily_close = [ins_setup[inst][4] for inst in insts]
    dt_strat = strat_dt.DTTrader('ProdDT',
                                 under_dt,
                                 vol_dt,
                                 trade_unit=units_dt,
                                 ratios=ratios,
                                 lookbacks=lookbacks,
                                 agent=None,
                                 daily_close=daily_close,
                                 email_notify=[],
                                 ma_win=10)
    strategies = [dt_strat]
    folder = misc.get_prod_folder()
    strat_cfg = {'strategies': strategies, \
                 'folder': folder, \
                 'daily_data_days':4, \
                 'min_data_days':1 }
    myApp = MainApp(name,
                    trader_cfg,
                    user_cfg,
                    strat_cfg,
                    tday,
                    master=None,
                    save_test=False)
    myGui = Gui(myApp)
    myGui.mainloop()
Ejemplo n.º 3
0
def option_test(tday, name='option_test'):
    base.config_logging("ctp_" + name + ".log", level=logging.DEBUG,
                   format = '%(name)s:%(funcName)s:%(lineno)d:%(asctime)s %(levelname)s %(message)s',
                   to_console = True,
                   console_level = logging.INFO)
    trader_cfg = misc.TEST_TRADER
    user_cfg = misc.TEST_USER
    opt_strat = optionarb.OptionArbStrat(name,
                                    ['IF1509', 'IF1512'],
                                    [201509, 201512],
                                    [[3400, 3500, 3600, 3650, 3700, 3750, 3800, 3850, 3900, 4000, 4100]]*2)
    ins_setup = {'IF1509':1}
    insts = ins_setup.keys()
    units_tl = [ins_setup[inst] for inst in insts]
    under_tl = [[inst] for inst in insts]
    vol_tl = [[1] for inst in insts]
    tl_strat = strat_tl.TurtleTrader('ProdTL', under_tl, vol_tl, trade_unit = units_tl,
                                 agent = None, email_notify = [])
    
    ins_setup = {'IF1509':(0, 0.7, 0.0, 1, False)}
    insts = ins_setup.keys()
    units_dt = [ins_setup[inst][3] for inst in insts]
    under_dt = [[inst] for inst in insts]
    vol_dt = [[1] for inst in insts]
    ratios = [[ins_setup[inst][1], ins_setup[inst][2]] for inst in insts]
    lookbacks = [ins_setup[inst][0] for inst in insts]
    daily_close = [ins_setup[inst][4] for inst in insts]
    dt_strat = strat_dt.DTTrader('ProdDT', under_dt, vol_dt, trade_unit = units_dt,
                                 ratios = ratios, lookbacks = lookbacks, 
                                 agent = None, daily_close = daily_close, 
                                 email_notify = [])
    ins_setup = {'IF1509': [[0.3, 0.07, 0.2], 1, 30, 1]}
    insts = ins_setup.keys()
    units_rb = [ins_setup[inst][1] for inst in insts]
    under_rb = [[inst] for inst in insts]
    vol_rb = [[1] for inst in insts]
    ratios = [ins_setup[inst][0] for inst in insts]
    min_rng = [ins_setup[inst][2] for inst in insts]
    freq = [ins_setup[inst][3] for inst in insts]
    stop_loss = 0.015
    rb_strat = strat_rb.RBreakerTrader('ProdRB', under_rb, vol_rb, trade_unit = units_rb,
                                 ratios = ratios, min_rng = min_rng, trail_loss = stop_loss, freq = freq, 
                                 agent = None, email_notify = [])
    strategies = [tl_strat, dt_strat, rb_strat]
    folder = misc.get_prod_folder()
    strat_cfg = {'strategies': strategies, \
                 'folder': folder, \
                 'daily_data_days':21, \
                 'min_data_days':1,
                 'enable_option': True }
    myApp = MainApp(name, trader_cfg, user_cfg, strat_cfg, tday, master = None, save_test = False)
    myGui = Gui(myApp)
    myGui.mainloop()
Ejemplo n.º 4
0
def Soymeal_Opt(tday, name='Soymeal_Opt'):
    base.config_logging("ctp_" + name + ".log", level=logging.DEBUG,
                   format = '%(name)s:%(funcName)s:%(lineno)d:%(asctime)s %(levelname)s %(message)s',
                   to_console = True,
                   console_level = logging.INFO)
    trader_cfg = misc.HT_OPTSIM_TRADER
    user_cfg = misc.HT_OPTSIM_USER
    ins_setup = {'m1601':5,
                 'm1605':5}
    insts = ins_setup.keys()
    units_tl = [ins_setup[inst] for inst in insts]
    under_tl = [[inst] for inst in insts]
    vol_tl = [[1] for inst in insts]
    tl_strat = strat_tl.TurtleTrader('ProdTL', under_tl, vol_tl, trade_unit = units_tl,
                                 agent = None, email_notify = [])

    ins_setup = {'m1601':(0, 0.5, 0.0, 10, False),
                 'm1605':(0, 0.5, 0.0, 10, False)}
    insts = ins_setup.keys()
    units_dt = [ins_setup[inst][3] for inst in insts]
    under_dt = [[inst] for inst in insts]
    vol_dt = [[1] for inst in insts]
    ratios = [[ins_setup[inst][1], ins_setup[inst][2]] for inst in insts]
    lookbacks = [ins_setup[inst][0] for inst in insts]
    daily_close = [ins_setup[inst][4] for inst in insts]
    dt_strat = strat_dt.DTTrader('ProdDT', under_dt, vol_dt, trade_unit = units_dt,
                                 ratios = ratios, lookbacks = lookbacks,
                                 agent = None, daily_close = daily_close,
                                 email_notify = [])
    ins_setup = {'m1601': [[0.3, 0.07, 0.2], 1, 30, 5],
                 'm1605': [[0.3, 0.07, 0.2], 1, 30, 5]}
    insts = ins_setup.keys()
    units_rb = [ins_setup[inst][1] for inst in insts]
    under_rb = [[inst] for inst in insts]
    vol_rb = [[1] for inst in insts]
    ratios = [ins_setup[inst][0] for inst in insts]
    min_rng = [ins_setup[inst][2] for inst in insts]
    freq = [ins_setup[inst][3] for inst in insts]
    stop_loss = 0.015
    rb_strat = strat_rb.RBreakerTrader('ProdRB', under_rb, vol_rb, trade_unit = units_rb,
                                 ratios = ratios, min_rng = min_rng, trail_loss = stop_loss, freq = freq,
                                 agent = None, email_notify = [])
    strategies = [tl_strat, dt_strat, rb_strat]
    folder = misc.get_prod_folder()
    strat_cfg = {'strategies': strategies, \
                 'folder': folder, \
                 'daily_data_days':21, \
                 'min_data_days':1,
                 'enable_option': True }
    myApp = MainApp(name, trader_cfg, user_cfg, strat_cfg, tday, master = None, save_test = True)
    myGui = Gui(myApp)
    myGui.mainloop()
Ejemplo n.º 5
0
def run_gui(config_file, tday):
    with open(config_file, 'r') as infile:
        config = json.load(infile)
    name = config.get('name', 'test_agent')
    base.config_logging(
        name + "/" + name + ".log",
        level=logging.DEBUG,
        format=
        '%(name)s:%(funcName)s:%(lineno)d:%(asctime)s %(levelname)s %(message)s',
        to_console=True,
        console_level=logging.INFO)
    scur_day = datetime.datetime.strptime(tday, '%Y%m%d').date()
    myApp = MainApp(scur_day, config, master=None)
    myGui = Gui(myApp)
    # myGui.iconbitmap(r'c:\Python27\DLLs\thumbs-up-emoticon.ico')
    myGui.mainloop()
Ejemplo n.º 6
0
def run_gui(name, config_file, tday, agent_class='agent.Agent'):
    base.config_logging(
        name + "\\" + name + ".log",
        level=logging.DEBUG,
        format=
        '%(name)s:%(funcName)s:%(lineno)d:%(asctime)s %(levelname)s %(message)s',
        to_console=True,
        console_level=logging.INFO)
    scur_day = datetime.datetime.strptime(tday, '%Y%m%d').date()
    myApp = MainApp(name,
                    scur_day,
                    config_file,
                    agent_class=agent_class,
                    master=None)
    myGui = Gui(myApp)
    # myGui.iconbitmap(r'c:\Python27\DLLs\thumbs-up-emoticon.ico')
    myGui.mainloop()
Ejemplo n.º 7
0
def save_ctp(tday, config_file, filter = False):
    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)
    app_name = 'SaveAgent'
    scur_day = datetime.datetime.strptime(tday, '%Y%m%d').date()
    save_agent = agent.SaveAgent(name = app_name, tday = scur_day, config_file = config_file)
    curr_insts = filter_main_cont(tday, False)
    for inst in curr_insts:
        save_agent.add_instrument(inst)
    try:
        save_agent.restart()
        while 1:
            time.sleep(1)
    except KeyboardInterrupt:
        save_agent.exit()
Ejemplo n.º 8
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()
Ejemplo n.º 9
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()
Ejemplo n.º 10
0
def run_proxy_server(config_file, tday):
    with open(config_file, 'r') as infile:
        config = json.load(infile)
    name = config.get('name', 'test_agent')
    base.config_logging(name + "/" + name + ".log", level=logging.DEBUG,
                        format='%(name)s:%(funcName)s:%(lineno)d:%(asctime)s %(levelname)s %(message)s',
                        to_console=True,
                        console_level=logging.INFO)
    scur_day = datetime.datetime.strptime(tday, '%Y%m%d').date()
    rep_address = config.get('rep_address', 'tcp://*:10010')
    pub_address = config.get('pub_address', 'tcp://*:10020')
    proxy_app = ProxyRpcServer(rep_address, pub_address, config, scur_day)
    proxy_app.start()
    try:
        while 1:
            time.sleep(1)
    except KeyboardInterrupt:
        proxy_app.exit_agent()
Ejemplo n.º 11
0
def save(name, config_file, tday, filter):
    base.config_logging(name + "\\" + name + ".log", level=logging.DEBUG,
                   format = '%(name)s:%(funcName)s:%(lineno)d:%(asctime)s %(levelname)s %(message)s',
                   to_console = True,
                   console_level = logging.INFO)
    scur_day = datetime.datetime.strptime(tday, '%Y%m%d').date()
    filter_flag = (int(filter)>0)
    with open(config_file, 'r') as infile:
        config = json.load(infile)
    save_agent = agent.SaveAgent(name = name, tday = scur_day, config = config)
    curr_insts = misc.filter_main_cont(tday, filter_flag)
    for inst in curr_insts:
        save_agent.add_instrument(inst)
    try:
        save_agent.restart()
        while 1:
            time.sleep(1)
    except KeyboardInterrupt:
        save_agent.exit()
Ejemplo n.º 12
0
def save_ctp(tday, config_file, filter = False):
    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)
    app_name = 'SaveAgent'
    scur_day = datetime.datetime.strptime(tday, '%Y%m%d').date()
	config = {}
	with open(config_file, 'r') as infile:
        config = json.load(infile)
    save_agent = agent.SaveAgent(name = app_name, tday = scur_day, config = config)
    curr_insts = filter_main_cont(tday, False)
    for inst in curr_insts:
        save_agent.add_instrument(inst)
    try:
        save_agent.restart()
        while 1:
            time.sleep(1)
    except KeyboardInterrupt:
        save_agent.exit()
Ejemplo n.º 13
0
def run(name, config_file, tday, agent_class='agent.Agent'):
    base.config_logging(
        name + "\\" + name + ".log",
        level=logging.DEBUG,
        format=
        '%(name)s:%(funcName)s:%(lineno)d:%(asctime)s %(levelname)s %(message)s',
        to_console=True,
        console_level=logging.INFO)
    scur_day = datetime.datetime.strptime(tday, '%Y%m%d').date()
    cls_str = agent_class.split('.')
    with open(config_file, 'r') as infile:
        config = json.load(infile)
    agent_cls = getattr(__import__(str(cls_str[0])), str(cls_str[1]))
    agent = agent_cls(name=name, tday=scur_day, config=config)
    try:
        agent.restart()
        while 1:
            time.sleep(1)
    except KeyboardInterrupt:
        agent.exit()
Ejemplo n.º 14
0
def prod_trade(tday, name='prod_trade'):
    base.config_logging("ctp_" + name + ".log", level=logging.DEBUG,
                   format = '%(name)s:%(funcName)s:%(lineno)d:%(asctime)s %(levelname)s %(message)s',
                   to_console = True,
                   console_level = logging.INFO)
    trader_cfg = misc.HT_DN_TD
    user_cfg = misc.HT_DN_MD
    ins_setup = {'m1605':(1, 0.7, 0.0, 2, False),
                'RM605': (1, 0.6, 0.0, 2, False),
                'y1605': (0, 0.8, 0.0, 1, False),
                'p1605': (1, 0.9, 0.0, 1, False),
                'OI601': (0, 0.7, 0.0, 0, False),
                'a1601': (0, 1.0, 0.0, 2, False),
                'rb1605':(0, 0.6, 0.0, 4, False),
                'l1605': (0, 0.7, 0.0, 1, False),
                'pp1601':(4, 0.3, 0.0, 1, False),
                'TA601' :(1, 0.6, 0.0, 1, False),
                'MA601' :(1, 0.8, 0.0, 2, False),
                'jd1601':(1 ,0.8, 0.0, 1, False),
                'SR605': (1, 0.8, 0.0, 1, False),
                }
    insts = ins_setup.keys()
    units_dt = [ins_setup[inst][3] for inst in insts]
    under_dt = [[inst] for inst in insts]
    vol_dt = [[1] for inst in insts]
    ratios = [[ins_setup[inst][1], ins_setup[inst][2]] for inst in insts]
    lookbacks = [ins_setup[inst][0] for inst in insts]
    daily_close = [ins_setup[inst][4] for inst in insts]
    dt_strat = strat_dt.DTTrader('ProdDT', under_dt, vol_dt, trade_unit = units_dt,
                                 ratios = ratios, lookbacks = lookbacks, 
                                 agent = None, daily_close = daily_close, 
                                 email_notify = [], ma_win = 10)
    strategies = [dt_strat]
    folder = misc.get_prod_folder()
    strat_cfg = {'strategies': strategies, \
                 'folder': folder, \
                 'daily_data_days':4, \
                 'min_data_days':1 }
    myApp = MainApp(name, trader_cfg, user_cfg, strat_cfg, tday, master = None, save_test = False)
    myGui = Gui(myApp)
    myGui.mainloop()
Ejemplo n.º 15
0
def run_proxy_server(config_file, tday):
    with open(config_file, 'r') as infile:
        config = json.load(infile)
    name = config.get('name', 'test_agent')
    base.config_logging(
        name + "/" + name + ".log",
        level=logging.DEBUG,
        format=
        '%(name)s:%(funcName)s:%(lineno)d:%(asctime)s %(levelname)s %(message)s',
        to_console=True,
        console_level=logging.INFO)
    scur_day = datetime.datetime.strptime(tday, '%Y%m%d').date()
    rep_address = config.get('rep_address', 'tcp://*:10010')
    pub_address = config.get('pub_address', 'tcp://*:10020')
    proxy_app = ProxyRpcServer(rep_address, pub_address, config, scur_day)
    proxy_app.start()
    try:
        while 1:
            time.sleep(1)
    except KeyboardInterrupt:
        proxy_app.exit_agent()
Ejemplo n.º 16
0
def save(name, config_file, tday, filter):
    base.config_logging(
        name + "\\" + name + ".log",
        level=logging.DEBUG,
        format=
        '%(name)s:%(funcName)s:%(lineno)d:%(asctime)s %(levelname)s %(message)s',
        to_console=True,
        console_level=logging.INFO)
    scur_day = datetime.datetime.strptime(tday, '%Y%m%d').date()
    filter_flag = (int(filter) > 0)
    with open(config_file, 'r') as infile:
        config = json.load(infile)
    save_agent = agent.SaveAgent(name=name, tday=scur_day, config=config)
    curr_insts = misc.filter_main_cont(tday, filter_flag)
    for inst in curr_insts:
        save_agent.add_instrument(inst)
    try:
        save_agent.restart()
        while 1:
            time.sleep(1)
    except KeyboardInterrupt:
        save_agent.exit()
Ejemplo n.º 17
0
def prod_test(tday, name='prod_test'):
    base.config_logging("ctp_" + name + ".log", level=logging.DEBUG,
                   format = '%(name)s:%(funcName)s:%(lineno)d:%(asctime)s %(levelname)s %(message)s',
                   to_console = True,
                   console_level = logging.INFO)
    trader_cfg = None
    user_cfg = misc.HT_PROD_MD
    # ins_setup = {'ru1605':  [[0.35, 0.08, 0.25], 1,  120, 3],
    #              'rb1605':  [[0.25, 0.05, 0.15], 5, 20, 3],
    #              'RM605' :  [[0.35, 0.07, 0.25], 4,  20, 1],
    #              'm1605' :  [[0.35, 0.07, 0.25], 4,  30, 3],
    #              'ag1606': [[0.4, 0.1, 0.3], 4,  40, 5],
    #              'y1605' : [[0.25, 0.05, 0.15], 4,  60, 1],
    #              'cu1603': [[0.25, 0.05, 0.15], 1,  700, 1]}
    # insts = ins_setup.keys()
    # units_rb = [ins_setup[inst][1] for inst in insts]
    # under_rb = [[inst] for inst in insts]
    # vol_rb = [[1] for inst in insts]
    # ratios = [ins_setup[inst][0] for inst in insts]
    # min_rng = [ins_setup[inst][2] for inst in insts]
    # freq = [ins_setup[inst][3] for inst in insts]
    # stop_loss = 0.015
    # rb_strat = strat_rb.RBreakerTrader('ProdRB', under_rb, vol_rb, trade_unit = units_rb,
    #                              ratios = ratios, min_rng = min_rng, trail_loss = stop_loss, freq = freq,
    #                              agent = None, email_notify = [])
    ins_setup ={
                'TF1603':(2, 0.5, 0.0, 1, False, 0.0),
                'm1605': (0,0.8, 0.0, 2, False, 0.004),
                'RM605': (0,0.8, 0.0, 2, False, 0.004),
                'y1605': (0,0.7, 0.0, 2, False, 0.004),
                'p1605': (0,0.9, 0.0, 2, False, 0.004),
                'a1605' :(0,1.0, 0.0, 2, False, 0.004),
                'rb1605':(0,0.7, 0.5, 4, False, 0.004),
                'l1605': (2,0.4, 0.0, 4, False, 0.004),
                'pp1605':(4,0.4, 0.0, 2, False, 0.004),
                'TA605' :(0, 0.6, 0.0, 3, False, 0.004),
                'MA605' :(0, 0.8, 0.0, 3, False, 0.004),
                'jd1605':(4, 0.4, 0.0, 4, False, 0.004),
                'SR605': (1, 0.9, 0.0, 2, False, 0.004),
                'i1605' :(2, 0.4,0.0, 2,  False, 0.004),
                'cs1605' :(0, 1.0, 0.0, 3, False, 0.004),
                }
    insts = ins_setup.keys()

    units_dt = [ins_setup[inst][3] for inst in insts]
    under_dt = [[inst] for inst in insts]
    vol_dt = [[1] for inst in insts]
    ratios = [[ins_setup[inst][1], ins_setup[inst][2]] for inst in insts]
    lookbacks = [ins_setup[inst][0] for inst in insts]
    daily_close = [ins_setup[inst][4] for inst in insts]
    min_rng = [ins_setup[inst][5] for inst in insts]
    #dt_strat = dt_bar.DTBarTrader('ProdDT', under_dt, vol_dt, trade_unit = units_dt,
    #                             ratios = ratios, lookbacks = lookbacks,
    #                             agent = None, daily_close = daily_close, ma_win = 10,
    #                             email_notify = [], min_rng = min_rng)
    ins_setup = {
                'TF1603': (2, 0.6, 0.0, 1, False, 0.0),
                'm1605':  (0, 0.7, 0.0, 2, False, 0.004),
                'RM605':  (0, 0.6, 0.0, 2, False, 0.004),
                'y1605':  (0, 0.6, 0.0, 2, False, 0.004),
                'p1605':  (0, 1.1, 0.0, 2, False, 0.004),
                'a1605' : (0, 0.8, 0.0, 2, False, 0.004),
                'rb1605': (0, 0.6, 0.0, 4, False, 0.004),
                'l1605':  (0, 0.7, 0.0, 4, False, 0.004),
                'pp1605': (4, 0.35, 0.0, 2, False, 0.004),
                'TA605' : (0, 1.0, 0.0, 3, False, 0.004),
                'MA605' : (0, 0.9, 0.0, 3, False, 0.004),
                'jd1605': (4, 0.3, 0.0, 4, False, 0.004),
                'SR605':  (1, 0.8, 0.0, 2, False, 0.004),
                'i1605' : (2, 0.5,0.0,  2, False, 0.004),
                'cs1605' :(0, 1.1, 0.0, 3, False, 0.004),
                }
    insts = ins_setup.keys()
    units_dt = [ins_setup[inst][3] for inst in insts]
    under_dt = [[inst] for inst in insts]
    vol_dt = [[1] for inst in insts]
    ratios = [[ins_setup[inst][1], ins_setup[inst][2]] for inst in insts]
    lookbacks = [ins_setup[inst][0] for inst in insts]
    daily_close = [ins_setup[inst][4] for inst in insts]
    min_rng = [ins_setup[inst][5] for inst in insts]
    #dtma_strat = dt_bar.DTBarTrader('DTMA10', under_dt, vol_dt, trade_unit = units_dt,
    #                             ratios = ratios, lookbacks = lookbacks,
    #                             agent = None, daily_close = daily_close,
    #                             email_notify = [], min_rng = min_rng)

    ins_setup = {
                 'ag1606': (1, 0.8, 0.0, 2, False),
                 'm1605': (0, 0.8, 0.0, 2, False),
                 'RM605':  (0, 0.8, 0.0, 2, False),
                 'y1605':  (0, 0.9, 0.0, 2, False),
                 'p1605':  (1, 1.0, 0.0, 2, False),
                 'a1605':  (1, 0.9, 0.0, 2, False),
                 'rb1605': (2, 0.5, 0.0, 4, False),
                 'TA605' : (1, 0.7, 0.0, 3, False),
                 'MA605' : (1, 0.7, 0.0, 3, False),
                 'SR605' : (2, 0.9, 0.0, 2, False),
                 'i1605' : (4, 0.4, 0.0, 2, False),
                }
    insts = ins_setup.keys()
    units_dt = [ins_setup[inst][3] for inst in insts]
    under_dt = [[inst] for inst in insts]
    vol_dt = [[1] for inst in insts]
    ratios = [[ins_setup[inst][1], ins_setup[inst][2]] for inst in insts]
    lookbacks = [ins_setup[inst][0] for inst in insts]
    daily_close = [ins_setup[inst][4] for inst in insts]
    #dtsplit_strat1 = dt_split.DTSplitTrader('DTSp1', under_dt, vol_dt, trade_unit = units_dt,
    #                             ratios = ratios, lookbacks = lookbacks,
    #                             agent = None, daily_close = daily_close, ma_win = 10,
    #                             email_notify = [], min_rng = [0.004])
    ins_setup = {
                 'ag1606': (1, 1.1, 0.0, 2, False),
                 'm1605':  (0, 1.0, 0.0, 2, False),
                 'RM605':  (0, 1.0, 0.0, 2, False),
                 'y1605':  (0, 1.0, 0.0, 2, False),
                 'p1605':  (1, 1.1, 0.0, 2, False),
                 'a1605':  (1, 1.1, 0.0, 2, False),
                 'rb1605': (0, 0.9, 0.0, 4, False),
                 'TA605' : (1, 0.9, 0.0, 3, False),
                 'MA605' : (1, 0.9, 0.0, 3, False),
                 'SR605' : (4,0.45, 0.0, 2, False),
                 'i1605' : (4, 0.5, 0.0, 2, False),
                }
    insts = ins_setup.keys()
    units_dt = [ins_setup[inst][3] for inst in insts]
    under_dt = [[inst] for inst in insts]
    vol_dt = [[1] for inst in insts]
    ratios = [[ins_setup[inst][1], ins_setup[inst][2]] for inst in insts]
    lookbacks = [ins_setup[inst][0] for inst in insts]
    daily_close = [ins_setup[inst][4] for inst in insts]
    #dtsplit_strat2 = dt_split.DTSplitTrader('DTSp2', under_dt, vol_dt, trade_unit = units_dt,
    #                             ratios = ratios, lookbacks = lookbacks,
    #                             agent = None, daily_close = daily_close, ma_win = 10,
    #                             email_notify = [], min_rng = [0.004])

    ins_setup = {
                 'p1605':  (1, 0.9, 0.0, 2, False),
                 'rb1605': (0, 0.7, 0.0, 2, False),
                 'pp1605': (2, 0.25,0.0, 1, False),
                 'TF1603': (2, 0.5, 0.0, 1, False),
                 'MA605' : (2, 0.25,0.0, 3, False),
                 'SR605' : (1, 0.9, 0.0, 2, False),
                }
    insts = ins_setup.keys()
    units_dt = [ins_setup[inst][3] for inst in insts]
    under_dt = [[inst] for inst in insts]
    vol_dt = [[1] for inst in insts]
    ratios = [[ins_setup[inst][1], ins_setup[inst][2]] for inst in insts]
    lookbacks = [ins_setup[inst][0] for inst in insts]
    daily_close = [ins_setup[inst][4] for inst in insts]
    chan_func ={'high_func': max,
                'high_args': {},
                'low_func': min,
                'low_args': {}}
    #dtchan5_sp1 = dt_dfilter.DTSplitChanFilter('DTChan5Sp1',
    #                                            under_dt,
    #                                            vol_dt,
    #                                            trade_unit = units_dt,
    #                                            ratios = ratios,
    #                                            lookbacks = lookbacks,
    #                                            agent = None,
    #                                            daily_close = daily_close,
    #                                            chan_func = chan_func,
    #                                            channels = [5],
    #                                            open_period = [300, 2115],
    #                                            email_notify = [],
    #                                            min_rng = [0.003])
    ins_setup = {
                 'p1605':  (1, 1.0, 0.0, 2, False),
                 'rb1605': (0, 0.6, 0.0, 2, False),
                 'pp1605': (2, 0.3, 0.0, 1, False),
                 'TF1603': (1, 0.7, 0.0, 1, False),
                 'MA605' : (2, 0.3, 0.0, 3, False),
                 'SR605' : (1, 1.0, 0.0, 2, False),
                }
    insts = ins_setup.keys()
    units_dt = [ins_setup[inst][3] for inst in insts]
    under_dt = [[inst] for inst in insts]
    vol_dt = [[1] for inst in insts]
    ratios = [[ins_setup[inst][1], ins_setup[inst][2]] for inst in insts]
    lookbacks = [ins_setup[inst][0] for inst in insts]
    daily_close = [ins_setup[inst][4] for inst in insts]
    #dtchan5_sp2 = dt_dfilter.DTSplitChanFilter('DTChan5Sp2',
    #                                            under_dt,
    #                                            vol_dt,
    #                                             trade_unit = units_dt,
    #                                             ratios = ratios,
    #                                             lookbacks = lookbacks,
    #                                             agent = None,
    #                                             daily_close = daily_close,
    #                                             chan_func = chan_func,
    #                                             channels = [5],
    #                                             open_period = [300, 2115],
    #                                             email_notify = [],
    #                                             min_rng = [0.003])
    ins_setup = {
                 'cs1605': (1, 1.1, 0.0, 3, False),
                 'l1605':  (0, 0.7, 0.0, 1, False),
                 'i1605':  (0, 0.7, 0.0, 2, False),
                 'j1605':  (2, 0.35,0.0, 2, False),
                 'cu1603': (1, 0.6, 0.0, 1, False),
                }
    insts = ins_setup.keys()
    units_dt = [ins_setup[inst][3] for inst in insts]
    under_dt = [[inst] for inst in insts]
    vol_dt = [[1] for inst in insts]
    ratios = [[ins_setup[inst][1], ins_setup[inst][2]] for inst in insts]
    lookbacks = [ins_setup[inst][0] for inst in insts]
    daily_close = [ins_setup[inst][4] for inst in insts]
    chan_func ={'high_func': np.percentile,
                'high_args': {'q':90,},
                'low_func': np.percentile,
                'low_args':  {'q':10,}}
    # dtchan10_sp1 = dt_dfilter.DTSplitChanFilter('DTChan10Sp1',
    #                                             under_dt,
    #                                             vol_dt,
    #                                             trade_unit = units_dt,
    #                                             ratios = ratios,
    #                                             lookbacks = lookbacks,
    #                                             agent = None,
    #                                             daily_close = daily_close,
    #                                             chan_func = chan_func,
    #                                             channels = [10],
    #                                             open_period = [300, 2115],
    #                                             email_notify = [],
    #                                             min_rng = [0.003])

    ins_setup = {
                 'cs1605': (1, 1.0, 0.0, 3, False),
                 'l1605':  (2, 0.4, 0.0, 1, False),
                 'i1605':  (0, 0.9, 0.0, 2, False),
                 'j1605':  (2, 0.4, 0.0, 2, False),
                 'cu1603': (2,0.35, 0.0, 1, False),
                }
    insts = ins_setup.keys()
    units_dt = [ins_setup[inst][3] for inst in insts]
    under_dt = [[inst] for inst in insts]
    vol_dt = [[1] for inst in insts]
    ratios = [[ins_setup[inst][1], ins_setup[inst][2]] for inst in insts]
    lookbacks = [ins_setup[inst][0] for inst in insts]
    daily_close = [ins_setup[inst][4] for inst in insts]
    chan_func ={'high_func': np.percentile,
                'high_args': {'q':80,},
                'low_func': np.percentile,
                'low_args':  {'q':20,}}
    # dtchan10_sp2 = dt_dfilter.DTSplitChanFilter('DTChan10Sp2',
    #                                             under_dt,
    #                                             vol_dt,
    #                                             trade_unit = units_dt,
    #                                             ratios = ratios,
    #                                             lookbacks = lookbacks,
    #                                             agent = None,
    #                                             daily_close = daily_close,
    #                                             chan_func = chan_func,
    #                                             channels = [10],
    #                                             open_period = [300, 2115],
    #                                             email_notify = [],
    #                                             min_rng = [0.003])
    ins_setup = {
                 'm1605':  (1, 0.7, 0.0, 3, False),
                 'RM605':  (2,0.25, 0.0, 3, False),
                 'y1605':  (1, 0.8, 0.0, 2, False),
                 'l1605':  (0, 0.7, 0.0, 1, False),
                 'TF1603': (2, 0.45,0.0, 1, False),
                 'TA605' : (0, 0.7, 0.0, 2, False),
                 'i1605' : (2, 0.35,0.0, 2, False),
                }
    insts = ins_setup.keys()
    units_dt = [ins_setup[inst][3] for inst in insts]
    under_dt = [[inst] for inst in insts]
    vol_dt = [[1] for inst in insts]
    ratios = [[ins_setup[inst][1], ins_setup[inst][2]] for inst in insts]
    lookbacks = [ins_setup[inst][0] for inst in insts]
    daily_close = [ins_setup[inst][4] for inst in insts]
    chan_func ={'high_func': np.percentile,
                'high_args': {'q':90,},
                'low_func': np.percentile,
                'low_args':  {'q':10,}}
    # dtchan20_sp1 = dt_dfilter.DTSplitChanFilter('DTChan20Sp1',
    #                                             under_dt,
    #                                             vol_dt,
    #                                             trade_unit = units_dt,
    #                                             ratios = ratios,
    #                                             lookbacks = lookbacks,
    #                                             agent = None,
    #                                             daily_close = daily_close,
    #                                             chan_func = chan_func,
    #                                             channels = [20],
    #                                             open_period = [300, 2115],
    #                                             email_notify = [],
    #                                             min_rng = [0.003])

    ins_setup = {
                 'm1605':  (1, 0.8, 0.0, 3, False),
                 'RM605':  (2, 0.3, 0.0, 3, False),
                 'y1605':  (1, 1.0, 0.0, 2, False),
                 'l1605':  (0, 1.0, 0.0, 1, False),
                 'TF1603': (2, 0.5, 0.0, 1, False),
                 'TA605' : (1, 0.8, 0.0, 2, False),
                 'i1605' : (2, 0.4, 0.0, 2, False),
                }
    insts = ins_setup.keys()
    units_dt = [ins_setup[inst][3] for inst in insts]
    under_dt = [[inst] for inst in insts]
    vol_dt = [[1] for inst in insts]
    ratios = [[ins_setup[inst][1], ins_setup[inst][2]] for inst in insts]
    lookbacks = [ins_setup[inst][0] for inst in insts]
    daily_close = [ins_setup[inst][4] for inst in insts]
    chan_func ={'high_func': np.percentile,
                'high_args': {'q':80,},
                'low_func': np.percentile,
                'low_args':  {'q':20,}}
    # dtchan20_sp2 = dt_dfilter.DTSplitChanFilter('DTChan20Sp2',
    #                                             under_dt,
    #                                             vol_dt,
    #                                             trade_unit = units_dt,
    #                                             ratios = ratios,
    #                                             lookbacks = lookbacks,
    #                                             agent = None,
    #                                             daily_close = daily_close,
    #                                             chan_func = chan_func,
    #                                             channels = [20],
    #                                             open_period = [300, 2115],
    #                                             email_notify = [],
    #                                             min_rng = [0.003])

    ins_setup = {
                 'bu1601':[2, 1, 1],
                 'i1605': [1, 1, 2],
                 'TA605': [2, 2, 2],
                 'ZC605': [2, 3, 1],
                 }
    insts = ins_setup.keys()
    units_tl = [ins_setup[inst][2] for inst in insts]
    under_tl = [[inst] for inst in insts]
    vol_tl = [[1] for inst in insts]
    trail_loss = [ins_setup[inst][0] for inst in insts]
    max_pos = [ins_setup[inst][1] for inst in insts]
    # tl_strat = strat_tl.TurtleTrader('ProdTL', under_tl, vol_tl, trade_unit = units_tl,
    #                                 agent = None, email_notify = ['*****@*****.**'],
    #                                  windows = [5, 15],
    #                                  max_pos = max_pos,
    #                                  trail_loss = trail_loss)
    ins_setup = {
                 'j1605': [1, 2, 1],
                 'ZC605': [2, 3, 2],
                 'i1605': [2, 2, 1],
                 }
    insts = ins_setup.keys()
    units_tl = [ins_setup[inst][2] for inst in insts]
    under_tl = [[inst] for inst in insts]
    vol_tl = [[1] for inst in insts]
    trail_loss = [ins_setup[inst][0] for inst in insts]
    max_pos = [ins_setup[inst][1] for inst in insts]
Ejemplo n.º 18
0
def Soymeal_Opt(tday, name='Soymeal_Opt'):
    base.config_logging(
        "ctp_" + name + ".log",
        level=logging.DEBUG,
        format=
        '%(name)s:%(funcName)s:%(lineno)d:%(asctime)s %(levelname)s %(message)s',
        to_console=True,
        console_level=logging.INFO)
    trader_cfg = misc.HT_OPTSIM_TRADER
    user_cfg = misc.HT_OPTSIM_USER
    ins_setup = {'m1601': 5, 'm1605': 5}
    insts = ins_setup.keys()
    units_tl = [ins_setup[inst] for inst in insts]
    under_tl = [[inst] for inst in insts]
    vol_tl = [[1] for inst in insts]
    tl_strat = strat_tl.TurtleTrader('ProdTL',
                                     under_tl,
                                     vol_tl,
                                     trade_unit=units_tl,
                                     agent=None,
                                     email_notify=[])

    ins_setup = {
        'm1601': (0, 0.5, 0.0, 10, False),
        'm1605': (0, 0.5, 0.0, 10, False)
    }
    insts = ins_setup.keys()
    units_dt = [ins_setup[inst][3] for inst in insts]
    under_dt = [[inst] for inst in insts]
    vol_dt = [[1] for inst in insts]
    ratios = [[ins_setup[inst][1], ins_setup[inst][2]] for inst in insts]
    lookbacks = [ins_setup[inst][0] for inst in insts]
    daily_close = [ins_setup[inst][4] for inst in insts]
    dt_strat = strat_dt.DTTrader('ProdDT',
                                 under_dt,
                                 vol_dt,
                                 trade_unit=units_dt,
                                 ratios=ratios,
                                 lookbacks=lookbacks,
                                 agent=None,
                                 daily_close=daily_close,
                                 email_notify=[])
    ins_setup = {
        'm1601': [[0.3, 0.07, 0.2], 1, 30, 5],
        'm1605': [[0.3, 0.07, 0.2], 1, 30, 5]
    }
    insts = ins_setup.keys()
    units_rb = [ins_setup[inst][1] for inst in insts]
    under_rb = [[inst] for inst in insts]
    vol_rb = [[1] for inst in insts]
    ratios = [ins_setup[inst][0] for inst in insts]
    min_rng = [ins_setup[inst][2] for inst in insts]
    freq = [ins_setup[inst][3] for inst in insts]
    stop_loss = 0.015
    rb_strat = strat_rb.RBreakerTrader('ProdRB',
                                       under_rb,
                                       vol_rb,
                                       trade_unit=units_rb,
                                       ratios=ratios,
                                       min_rng=min_rng,
                                       trail_loss=stop_loss,
                                       freq=freq,
                                       agent=None,
                                       email_notify=[])
    strategies = [tl_strat, dt_strat, rb_strat]
    folder = misc.get_prod_folder()
    strat_cfg = {'strategies': strategies, \
                 'folder': folder, \
                 'daily_data_days':21, \
                 'min_data_days':1,
                 'enable_option': True }
    myApp = MainApp(name,
                    trader_cfg,
                    user_cfg,
                    strat_cfg,
                    tday,
                    master=None,
                    save_test=True)
    myGui = Gui(myApp)
    myGui.mainloop()
Ejemplo n.º 19
0
def option_test(tday, name='option_test'):
    base.config_logging(
        "ctp_" + name + ".log",
        level=logging.DEBUG,
        format=
        '%(name)s:%(funcName)s:%(lineno)d:%(asctime)s %(levelname)s %(message)s',
        to_console=True,
        console_level=logging.INFO)
    trader_cfg = misc.TEST_TRADER
    user_cfg = misc.TEST_USER
    opt_strat = optionarb.OptionArbStrat(
        name, ['IF1509', 'IF1512'], [201509, 201512],
        [[3400, 3500, 3600, 3650, 3700, 3750, 3800, 3850, 3900, 4000, 4100]] *
        2)
    ins_setup = {'IF1509': 1}
    insts = ins_setup.keys()
    units_tl = [ins_setup[inst] for inst in insts]
    under_tl = [[inst] for inst in insts]
    vol_tl = [[1] for inst in insts]
    tl_strat = strat_tl.TurtleTrader('ProdTL',
                                     under_tl,
                                     vol_tl,
                                     trade_unit=units_tl,
                                     agent=None,
                                     email_notify=[])

    ins_setup = {'IF1509': (0, 0.7, 0.0, 1, False)}
    insts = ins_setup.keys()
    units_dt = [ins_setup[inst][3] for inst in insts]
    under_dt = [[inst] for inst in insts]
    vol_dt = [[1] for inst in insts]
    ratios = [[ins_setup[inst][1], ins_setup[inst][2]] for inst in insts]
    lookbacks = [ins_setup[inst][0] for inst in insts]
    daily_close = [ins_setup[inst][4] for inst in insts]
    dt_strat = strat_dt.DTTrader('ProdDT',
                                 under_dt,
                                 vol_dt,
                                 trade_unit=units_dt,
                                 ratios=ratios,
                                 lookbacks=lookbacks,
                                 agent=None,
                                 daily_close=daily_close,
                                 email_notify=[])
    ins_setup = {'IF1509': [[0.3, 0.07, 0.2], 1, 30, 1]}
    insts = ins_setup.keys()
    units_rb = [ins_setup[inst][1] for inst in insts]
    under_rb = [[inst] for inst in insts]
    vol_rb = [[1] for inst in insts]
    ratios = [ins_setup[inst][0] for inst in insts]
    min_rng = [ins_setup[inst][2] for inst in insts]
    freq = [ins_setup[inst][3] for inst in insts]
    stop_loss = 0.015
    rb_strat = strat_rb.RBreakerTrader('ProdRB',
                                       under_rb,
                                       vol_rb,
                                       trade_unit=units_rb,
                                       ratios=ratios,
                                       min_rng=min_rng,
                                       trail_loss=stop_loss,
                                       freq=freq,
                                       agent=None,
                                       email_notify=[])
    strategies = [tl_strat, dt_strat, rb_strat]
    folder = misc.get_prod_folder()
    strat_cfg = {'strategies': strategies, \
                 'folder': folder, \
                 'daily_data_days':21, \
                 'min_data_days':1,
                 'enable_option': True }
    myApp = MainApp(name,
                    trader_cfg,
                    user_cfg,
                    strat_cfg,
                    tday,
                    master=None,
                    save_test=False)
    myGui = Gui(myApp)
    myGui.mainloop()
Ejemplo n.º 20
0
def prod_test(tday, name='prod_test'):
    base.config_logging("ctp_" + name + ".log", level=logging.DEBUG,
                   format = '%(name)s:%(funcName)s:%(lineno)d:%(asctime)s %(levelname)s %(message)s',
                   to_console = True,
                   console_level = logging.INFO)
    trader_cfg = None
    user_cfg = misc.HT_PROD_MD
    ins_setup = {'IF1510': [[0.3, 0.07, 0.2], 1,  30, 1],
                 'IH1510': [[0.3, 0.07, 0.2], 1,  30, 1],
                'ru1601':  [[0.35, 0.08, 0.25], 1,  120, 3],
                'rb1601':  [[0.25, 0.05, 0.15], 5, 20, 3],
                'RM601' :  [[0.35, 0.07, 0.25], 4,  20, 1],
                'm1601' :  [[0.35, 0.07, 0.25], 4,  30, 3],
                'ag1512': [[0.4, 0.1, 0.3], 4,  40, 5],
                'y1601' : [[0.25, 0.05, 0.15], 4,  60, 1],
                'cu1512': [[0.25, 0.05, 0.15], 1,  700, 1]}
    insts = ins_setup.keys()
    units_rb = [ins_setup[inst][1] for inst in insts]
    under_rb = [[inst] for inst in insts]
    vol_rb = [[1] for inst in insts]
    ratios = [ins_setup[inst][0] for inst in insts]
    min_rng = [ins_setup[inst][2] for inst in insts]
    freq = [ins_setup[inst][3] for inst in insts]
    stop_loss = 0.015
    rb_strat = strat_rb.RBreakerTrader('ProdRB', under_rb, vol_rb, trade_unit = units_rb,
                                 ratios = ratios, min_rng = min_rng, trail_loss = stop_loss, freq = freq, 
                                 agent = None, email_notify = [])
    ins_setup = {'m1601':(0,0.7, 0.0, 8, False, 0.004),
                'RM601': (-1,0.5, 0.0, 8, False, 0.004),
                'rb1601':(0,0.7, 0.0, 8, False, 0.004),
                'l1601': (0,0.7, 0.0, 2, False, 0.004),
                'pp1601':(0,0.7, 0.0, 2, False, 0.004),
                'TA601' :(-1,0.4, 0.0, 4, False, 0.004),
                'ru1601':(0, 0.7, 0.0, 1, False, 0.004),
                'SR601' :(0, 0.7, 0.0, 4, False, 0.004),
                'MA601' :(0, 0.7, 0.0, 3, False, 0.004),
                'au1512':(0, 0.7, 0.0, 1, False, 0.004),
                'i1601' :(2, 0.4, 0.0, 1, False, 0.004),
                'IF1510':(0, 0.6, 0.0, 1, False, 0.004),
                'IH1510':(0, 0.6, 0.0, 1, False, 0.004),
                'y1601': (0,0.7, 0.0, 4, False, 0.004),
                'p1601': (0,0.7, 0.0, 4, False, 0.004),
                 'TF1512':(2, 0.5, 0.0, 1, False, 0.0),
                }
    insts = ins_setup.keys()
    units_dt = [ins_setup[inst][3] for inst in insts]
    under_dt = [[inst] for inst in insts]
    vol_dt = [[1] for inst in insts]
    ratios = [[ins_setup[inst][1], ins_setup[inst][2]] for inst in insts]
    lookbacks = [ins_setup[inst][0] for inst in insts]
    daily_close = [ins_setup[inst][4] for inst in insts]
    min_rng = [ins_setup[inst][5] for inst in insts]
    dt_strat = strat_dt.DTTrader('ProdDT', under_dt, vol_dt, trade_unit = units_dt,
                                 ratios = ratios, lookbacks = lookbacks, 
                                 agent = None, daily_close = daily_close, ma_win = 10,
                                 email_notify = [], min_rng = min_rng)
    ins_setup = {'rb1601':(1,0.6, 0.5, 4, False, 0.004),
                'l1601' :(0,0.5, 0.5, 1, False, 0.004),
                'pp1601':(0,0.5, 0.5, 1, False, 0.004),
                'TA601' :(0,0.4, 0.5, 2, False, 0.004),
                'MA601' :(-1,0.5, 0.5, 2, False, 0.004),
                'jd1601':(2,0.4, 0.5, 2, False, 0.004),
                'a1601' :(2,0.4, 0.5, 2, False, 0.004),
                'SR601' :(1,0.6, 0.5, 1, False, 0.004),
                'm1601':(2,0.3, 0.5, 2, False, 0.004),
                'RM601' :(-1,0.3, 0.5, 2, False, 0.004),
                'i1601' :(4, 0.3, 0.5, 1, False, 0.004),
                'TF1512':(2, 0.4, 0.5, 1, False, 0.0),
                }
    insts = ins_setup.keys()
    units_dt = [ins_setup[inst][3] for inst in insts]
    under_dt = [[inst] for inst in insts]
    vol_dt = [[1] for inst in insts]
    ratios = [[ins_setup[inst][1], ins_setup[inst][2]] for inst in insts]
    lookbacks = [ins_setup[inst][0] for inst in insts]
    daily_close = [ins_setup[inst][4] for inst in insts]
    min_rng = [ins_setup[inst][5] for inst in insts]
    dtma_strat = strat_dt.DTTrader('DTMA10', under_dt, vol_dt, trade_unit = units_dt,
                                 ratios = ratios, lookbacks = lookbacks, 
                                 agent = None, daily_close = daily_close, 
                                 email_notify = [], min_rng = min_rng)

    ins_setup = {'m1601': (0, 0.8, 0.0, 2, False),
                 'RM601':  (0, 0.8, 0.0, 2, False),
                 'y1601':  (0, 0.9, 0.0, 2, False),
                 'p1601':  (1, 1.0, 0.0, 2, False),
                 'a1601':  (1, 0.9, 0.0, 3, False),
                 'rb1601': (2, 0.5, 0.0, 5, False),
                 'TA601' : (1, 0.7, 0.0, 3, False),
                 'MA601' : (1, 0.7, 0.0, 5, False),
                 'SR601' : (2, 0.9, 0.0, 3, False),
                 'i1601' : (4, 0.4, 0.0, 1, False),
                 'ag1512': (1, 0.8, 0.0, 2, False),
                }
    insts = ins_setup.keys()
    units_dt = [ins_setup[inst][3] for inst in insts]
    under_dt = [[inst] for inst in insts]
    vol_dt = [[1] for inst in insts]
    ratios = [[ins_setup[inst][1], ins_setup[inst][2]] for inst in insts]
    lookbacks = [ins_setup[inst][0] for inst in insts]
    daily_close = [ins_setup[inst][4] for inst in insts]
    dtsplit_strat1 = dt_split.DTSplitTrader('DTSp1', under_dt, vol_dt, trade_unit = units_dt,
                                 ratios = ratios, lookbacks = lookbacks,
                                 agent = None, daily_close = daily_close, ma_win = 10,
                                 email_notify = [], min_rng = [0.004])
    ins_setup = {'m1601':  (0, 1.0, 0.0, 2, False),
                 'RM601':  (0, 1.0, 0.0, 2, False),
                 'y1601':  (0, 1.0, 0.0, 2, False),
                 'p1601':  (1, 1.1, 0.0, 2, False),
                 'a1601':  (1, 1.1, 0.0, 3, False),
                 'rb1601': (0, 0.9, 0.0, 5, False),
                 'TA601' : (1, 0.9, 0.0, 3, False),
                 'MA601' : (1, 0.9, 0.0, 5, False),
                 'SR601' : (4,0.45, 0.0, 3, False),
                 'i1601' : (4, 0.5, 0.0, 1, False),
                 'ag1512': (1, 1.1, 0.0, 2, False),
                }
    insts = ins_setup.keys()
    units_dt = [ins_setup[inst][3] for inst in insts]
    under_dt = [[inst] for inst in insts]
    vol_dt = [[1] for inst in insts]
    ratios = [[ins_setup[inst][1], ins_setup[inst][2]] for inst in insts]
    lookbacks = [ins_setup[inst][0] for inst in insts]
    daily_close = [ins_setup[inst][4] for inst in insts]
    dtsplit_strat2 = dt_split.DTSplitTrader('DTSp2', under_dt, vol_dt, trade_unit = units_dt,
                                 ratios = ratios, lookbacks = lookbacks,
                                 agent = None, daily_close = daily_close, ma_win = 10,
                                 email_notify = [], min_rng = [0.004])

    ins_setup = {'i1601': [2, 2, 2],
                 #'jm1601': [1, 1, 1],
                 'TF1512': [1, 1, 1],
                 'TC601': [2, 4, 1],
                 'TA601': [2, 3, 2],
                 #'bu1512': [1, 1, 1],
                 'CF601': [2, 1, 2],
                 'ru1601': [1, 1, 1],
                 }
    insts = ins_setup.keys()
    units_tl = [ins_setup[inst][2] for inst in insts]
    under_tl = [[inst] for inst in insts]
    vol_tl = [[1] for inst in insts]
    trail_loss = [ins_setup[inst][0] for inst in insts]
    max_pos = [ins_setup[inst][1] for inst in insts]
    tl_strat = strat_tl.TurtleTrader('ProdTL', under_tl, vol_tl, trade_unit = units_tl,
                                    agent = None, email_notify = ['*****@*****.**'],
                                     windows = [5, 15],
                                     max_pos = max_pos,
                                     trail_loss = trail_loss)
    ins_setup = {'j1601': [1, 1, 1],
                 'rb1601': [1, 1, 1],
                 #'bu1512' :[2, 4, 1],
                 'p1601' :[1, 1, 2],
                 'jd1601':[2, 2, 1],
                 }
    insts = ins_setup.keys()
    units_tl = [ins_setup[inst][2] for inst in insts]
    under_tl = [[inst] for inst in insts]
    vol_tl = [[1] for inst in insts]
    trail_loss = [ins_setup[inst][0] for inst in insts]
    max_pos = [ins_setup[inst][1] for inst in insts]
    tl_strat2 = strat_tl.TurtleTrader('ProdTL2', under_tl, vol_tl, trade_unit = units_tl,
                                    agent = None, email_notify = ['*****@*****.**'],
                                    windows = [10, 20],
                                    max_pos = max_pos,
                                    trail_loss = trail_loss )
    strategies = [rb_strat, dt_strat, dtma_strat, tl_strat, tl_strat2, dtsplit_strat1, dtsplit_strat2]
    folder = misc.get_prod_folder()
    strat_cfg = {'strategies': strategies, \
                 'folder': folder, \
                 'daily_data_days':21, \
                 'min_data_days':4 }
    myApp = MainApp(name, trader_cfg, user_cfg, strat_cfg, tday, master = None, save_test = False)
    myGui = Gui(myApp)
    #myGui.iconbitmap(r'c:\Python27\DLLs\thumbs-up-emoticon.ico')
    myGui.mainloop()
Ejemplo n.º 21
0
def prod_trade2(tday, name='prod_trade2'):
    base.config_logging("ctp_" + name + ".log", level=logging.DEBUG,
                   format = '%(name)s:%(funcName)s:%(lineno)d:%(asctime)s %(levelname)s %(message)s',
                   to_console = True,
                   console_level = logging.INFO)
    trader_cfg = misc.HT_PROD_TD
    user_cfg = misc.HT_PROD_MD

    ins_setup ={'m1601': (0,0.7, 0.0, 2, False, 0.004),
                'RM601': (0,0.8, 0.0, 2, False, 0.004),
                'y1601': (0,0.7, 0.0, 1, False, 0.004),
                'p1601': (0,0.8, 0.0, 1, False, 0.004),
                'a1601' :(0,0.9, 0.0, 1, False, 0.004),
                'rb1601':(0,0.7, 0.5, 2, False, 0.004),
                'l1601': (2,0.4, 0.0, 3, False, 0.004),
                'pp1601':(2,0.3, 0.0, 2, False, 0.004),
                'TA601' :(0, 0.6, 0.0, 2, False, 0.004),
                'MA601' :(0, 0.8, 0.0, 3, False, 0.004),
                'jd1601':(4, 0.4, 0.0, 3, False, 0.004),
                'SR601': (1, 0.9, 0.0, 1, False, 0.004),
                'TF1512':(2, 0.5, 0.0, 1, False, 0.0),
                'i1601' :(2, 0.45,0.0, 1, False, 0.004),
                }
    insts = ins_setup.keys()
    units_dt = [ins_setup[inst][3] for inst in insts]
    under_dt = [[inst] for inst in insts]
    vol_dt = [[1] for inst in insts]
    ratios = [[ins_setup[inst][1], ins_setup[inst][2]] for inst in insts]
    lookbacks = [ins_setup[inst][0] for inst in insts]
    daily_close = [ins_setup[inst][4] for inst in insts]
    min_rng = [ins_setup[inst][5] for inst in insts]
    dt_strat1 = strat_dt.DTTrader('DT1', under_dt, vol_dt, trade_unit = units_dt,
                                 ratios = ratios, lookbacks = lookbacks, 
                                 agent = None, daily_close = daily_close, 
                                 email_notify = [], ma_win = 10, min_rng = min_rng)

    ins_setup ={'m1601':  (0, 0.7, 0.0, 2, False, 0.004),
                'RM601':  (0, 0.6, 0.0, 2, False, 0.004),
                'y1601':  (0, 0.6, 0.0, 1, False, 0.004),
                'p1601':  (0, 0.9, 0.0, 1, False, 0.004),
                'a1601' : (0, 0.8, 0.0, 2, False, 0.004),
                'rb1601': (0, 0.6, 0.0, 3, False, 0.004),
                'l1601':  (0, 0.7, 0.0, 3, False, 0.004),
                'pp1601': (0, 0.6, 0.0, 2, False, 0.004),
                'TA601' : (0, 1.0, 0.0, 2, False, 0.004),
                'MA601' : (0, 0.8, 0.0, 3, False, 0.004),
                'jd1601': (4, 0.3, 0.0, 3, False, 0.004),
                'SR601':  (1, 0.8, 0.0, 1, False, 0.004),
                'TF1512': (2, 0.6, 0.0, 1, False, 0.0),
                'i1601' : (2, 0.45,0.0, 1, False, 0.004),
                }
    insts = ins_setup.keys()
    units_dt = [ins_setup[inst][3] for inst in insts]
    under_dt = [[inst] for inst in insts]
    vol_dt = [[1] for inst in insts]
    ratios = [[ins_setup[inst][1], ins_setup[inst][2]] for inst in insts]
    lookbacks = [ins_setup[inst][0] for inst in insts]
    daily_close = [ins_setup[inst][4] for inst in insts]
    min_rng = [ins_setup[inst][5] for inst in insts]
    dt_strat2 = strat_dt.DTTrader('DT2', under_dt, vol_dt, trade_unit = units_dt,
                                 ratios = ratios, lookbacks = lookbacks,
                                 agent = None, daily_close = daily_close,
                                 email_notify = [], ma_win = 10, min_rng = min_rng)
    ins_setup = {'m1601': (0, 0.8, 0.0, 2, False),
                 'RM601':  (0, 0.8, 0.0, 2, False),
                 'y1601':  (0, 0.9, 0.0, 2, False),
                 'p1601':  (1, 1.0, 0.0, 2, False),
                 'a1601':  (1, 0.9, 0.0, 3, False),
                 'rb1601': (2, 0.5, 0.0, 5, False),
                 'TA601' : (1, 0.7, 0.0, 3, False),
                 'MA601' : (1, 0.7, 0.0, 5, False),
                 'SR601' : (2, 0.9, 0.0, 3, False),
                 'i1601' : (4, 0.4, 0.0, 1, False),
                 'ag1512': (1, 0.8, 0.0, 2, False),
                }
    insts = ins_setup.keys()
    units_dt = [ins_setup[inst][3] for inst in insts]
    under_dt = [[inst] for inst in insts]
    vol_dt = [[1] for inst in insts]
    ratios = [[ins_setup[inst][1], ins_setup[inst][2]] for inst in insts]
    lookbacks = [ins_setup[inst][0] for inst in insts]
    daily_close = [ins_setup[inst][4] for inst in insts]
    dtsplit_strat1 = dt_split.DTSplitTrader('DTSp1', under_dt, vol_dt, trade_unit = units_dt,
                                 ratios = ratios, lookbacks = lookbacks,
                                 agent = None, daily_close = daily_close, ma_win = 10,
                                 email_notify = [], min_rng = [0.004])
    ins_setup = {'m1601':  (0, 1.0, 0.0, 2, False),
                 'RM601':  (0, 1.0, 0.0, 2, False),
                 'y1601':  (0, 1.0, 0.0, 2, False),
                 'p1601':  (1, 1.1, 0.0, 2, False),
                 'a1601':  (1, 1.1, 0.0, 3, False),
                 'rb1601': (0, 0.9, 0.0, 5, False),
                 'TA601' : (1, 0.9, 0.0, 3, False),
                 'MA601' : (1, 0.9, 0.0, 5, False),
                 'SR601' : (4,0.45, 0.0, 3, False),
                 'i1601' : (4, 0.5, 0.0, 1, False),
                 'ag1512': (1, 1.1, 0.0, 2, False),
                }
    insts = ins_setup.keys()
    units_dt = [ins_setup[inst][3] for inst in insts]
    under_dt = [[inst] for inst in insts]
    vol_dt = [[1] for inst in insts]
    ratios = [[ins_setup[inst][1], ins_setup[inst][2]] for inst in insts]
    lookbacks = [ins_setup[inst][0] for inst in insts]
    daily_close = [ins_setup[inst][4] for inst in insts]
    dtsplit_strat2 = dt_split.DTSplitTrader('DTSp2', under_dt, vol_dt, trade_unit = units_dt,
                                 ratios = ratios, lookbacks = lookbacks,
                                 agent = None, daily_close = daily_close, ma_win = 10,
                                 email_notify = [], min_rng = [0.004])
    ins_setup = {'i1601': [1, 1, 2],
                 'TA601': [2, 2, 2],
                 #'bu1512':[2, 1, 1],
                 }
    insts = ins_setup.keys()
    units_tl = [ins_setup[inst][2] for inst in insts]
    under_tl = [[inst] for inst in insts]
    vol_tl = [[1] for inst in insts]
    trail_loss = [ins_setup[inst][0] for inst in insts]
    max_pos = [ins_setup[inst][1] for inst in insts]
    tl_strat1 = strat_tl.TurtleTrader('TL1', under_tl, vol_tl, trade_unit = units_tl,
                                    agent = None, email_notify = [],
                                     windows = [5, 15],
                                     max_pos = max_pos,
                                     trail_loss = trail_loss)
    ins_setup = {'j1601': [1, 2, 1],
                 'TC601': [2, 4, 1],
                 #'bu1512' :[2, 1, 1],
                 }
    insts = ins_setup.keys()
    units_tl = [ins_setup[inst][2] for inst in insts]
    under_tl = [[inst] for inst in insts]
    vol_tl = [[1] for inst in insts]
    trail_loss = [ins_setup[inst][0] for inst in insts]
    max_pos = [ins_setup[inst][1] for inst in insts]
    tl_strat2 = strat_tl.TurtleTrader('TL2', under_tl, vol_tl, trade_unit = units_tl,
                                    agent = None, email_notify = [],
                                    windows = [10, 20],
                                    max_pos = max_pos,
                                    trail_loss = trail_loss )
    strategies = [dt_strat1, dt_strat2, tl_strat1, tl_strat2]
    folder = misc.get_prod_folder()
    strat_cfg = {'strategies': strategies, \
                 'folder': folder, \
                 'daily_data_days':22, \
                 'min_data_days':5 }

    myApp = MainApp(name, trader_cfg, user_cfg, strat_cfg, tday, master = None, save_test = False)
    myGui = Gui(myApp)
    #myGui.iconbitmap(r'c:\Python27\DLLs\thumbs-up-emoticon.ico')
    myGui.mainloop()
Ejemplo n.º 22
0
def prod_test(tday, name='prod_test'):
    base.config_logging(
        "ctp_" + name + ".log",
        level=logging.DEBUG,
        format=
        '%(name)s:%(funcName)s:%(lineno)d:%(asctime)s %(levelname)s %(message)s',
        to_console=True,
        console_level=logging.INFO)
    trader_cfg = None
    user_cfg = misc.HT_PROD_MD
    ins_setup = {
        'IF1510': [[0.3, 0.07, 0.2], 1, 30, 1],
        'IH1510': [[0.3, 0.07, 0.2], 1, 30, 1],
        'ru1601': [[0.35, 0.08, 0.25], 1, 120, 3],
        'rb1601': [[0.25, 0.05, 0.15], 5, 20, 3],
        'RM601': [[0.35, 0.07, 0.25], 4, 20, 1],
        'm1601': [[0.35, 0.07, 0.25], 4, 30, 3],
        'ag1512': [[0.4, 0.1, 0.3], 4, 40, 5],
        'y1601': [[0.25, 0.05, 0.15], 4, 60, 1],
        'cu1512': [[0.25, 0.05, 0.15], 1, 700, 1]
    }
    insts = ins_setup.keys()
    units_rb = [ins_setup[inst][1] for inst in insts]
    under_rb = [[inst] for inst in insts]
    vol_rb = [[1] for inst in insts]
    ratios = [ins_setup[inst][0] for inst in insts]
    min_rng = [ins_setup[inst][2] for inst in insts]
    freq = [ins_setup[inst][3] for inst in insts]
    stop_loss = 0.015
    rb_strat = strat_rb.RBreakerTrader('ProdRB',
                                       under_rb,
                                       vol_rb,
                                       trade_unit=units_rb,
                                       ratios=ratios,
                                       min_rng=min_rng,
                                       trail_loss=stop_loss,
                                       freq=freq,
                                       agent=None,
                                       email_notify=[])
    ins_setup = {
        'm1601': (0, 0.7, 0.0, 8, False, 0.004),
        'RM601': (-1, 0.5, 0.0, 8, False, 0.004),
        'rb1601': (0, 0.7, 0.0, 8, False, 0.004),
        'l1601': (0, 0.7, 0.0, 2, False, 0.004),
        'pp1601': (0, 0.7, 0.0, 2, False, 0.004),
        'TA601': (-1, 0.4, 0.0, 4, False, 0.004),
        'ru1601': (0, 0.7, 0.0, 1, False, 0.004),
        'SR601': (0, 0.7, 0.0, 4, False, 0.004),
        'MA601': (0, 0.7, 0.0, 3, False, 0.004),
        'au1512': (0, 0.7, 0.0, 1, False, 0.004),
        'i1601': (2, 0.4, 0.0, 1, False, 0.004),
        'IF1510': (0, 0.6, 0.0, 1, False, 0.004),
        'IH1510': (0, 0.6, 0.0, 1, False, 0.004),
        'y1601': (0, 0.7, 0.0, 4, False, 0.004),
        'p1601': (0, 0.7, 0.0, 4, False, 0.004),
        'TF1512': (2, 0.5, 0.0, 1, False, 0.0),
    }
    insts = ins_setup.keys()
    units_dt = [ins_setup[inst][3] for inst in insts]
    under_dt = [[inst] for inst in insts]
    vol_dt = [[1] for inst in insts]
    ratios = [[ins_setup[inst][1], ins_setup[inst][2]] for inst in insts]
    lookbacks = [ins_setup[inst][0] for inst in insts]
    daily_close = [ins_setup[inst][4] for inst in insts]
    min_rng = [ins_setup[inst][5] for inst in insts]
    dt_strat = strat_dt.DTTrader('ProdDT',
                                 under_dt,
                                 vol_dt,
                                 trade_unit=units_dt,
                                 ratios=ratios,
                                 lookbacks=lookbacks,
                                 agent=None,
                                 daily_close=daily_close,
                                 ma_win=10,
                                 email_notify=[],
                                 min_rng=min_rng)
    ins_setup = {
        'rb1601': (1, 0.6, 0.5, 4, False, 0.004),
        'l1601': (0, 0.5, 0.5, 1, False, 0.004),
        'pp1601': (0, 0.5, 0.5, 1, False, 0.004),
        'TA601': (0, 0.4, 0.5, 2, False, 0.004),
        'MA601': (-1, 0.5, 0.5, 2, False, 0.004),
        'jd1601': (2, 0.4, 0.5, 2, False, 0.004),
        'a1601': (2, 0.4, 0.5, 2, False, 0.004),
        'SR601': (1, 0.6, 0.5, 1, False, 0.004),
        'm1601': (2, 0.3, 0.5, 2, False, 0.004),
        'RM601': (-1, 0.3, 0.5, 2, False, 0.004),
        'i1601': (4, 0.3, 0.5, 1, False, 0.004),
        'TF1512': (2, 0.4, 0.5, 1, False, 0.0),
    }
    insts = ins_setup.keys()
    units_dt = [ins_setup[inst][3] for inst in insts]
    under_dt = [[inst] for inst in insts]
    vol_dt = [[1] for inst in insts]
    ratios = [[ins_setup[inst][1], ins_setup[inst][2]] for inst in insts]
    lookbacks = [ins_setup[inst][0] for inst in insts]
    daily_close = [ins_setup[inst][4] for inst in insts]
    min_rng = [ins_setup[inst][5] for inst in insts]
    dtma_strat = strat_dt.DTTrader('DTMA10',
                                   under_dt,
                                   vol_dt,
                                   trade_unit=units_dt,
                                   ratios=ratios,
                                   lookbacks=lookbacks,
                                   agent=None,
                                   daily_close=daily_close,
                                   email_notify=[],
                                   min_rng=min_rng)

    ins_setup = {
        'm1601': (0, 0.7, 0.0, 8, False),
        'RM601': (-1, 0.5, 0.0, 8, False),
        'rb1601': (0, 0.7, 0.0, 8, False),
        'TA601': (-1, 0.4, 0.0, 4, False),
        'ru1601': (0, 0.7, 0.0, 1, False),
        'SR601': (0, 0.7, 0.0, 4, False),
        'MA601': (0, 0.7, 0.0, 3, False),
        'ag1512': (0, 0.7, 0.0, 1, False),
        'i1601': (2, 0.4, 0.0, 1, False),
        'y1601': (0, 0.7, 0.0, 4, False),
        'p1601': (0, 0.7, 0.0, 4, False),
    }
    insts = ins_setup.keys()
    units_dt = [ins_setup[inst][3] for inst in insts]
    under_dt = [[inst] for inst in insts]
    vol_dt = [[1] for inst in insts]
    ratios = [[ins_setup[inst][1], ins_setup[inst][2]] for inst in insts]
    lookbacks = [ins_setup[inst][0] for inst in insts]
    daily_close = [ins_setup[inst][4] for inst in insts]
    dtsplit_strat = dt_split.DTSplitTrader('DTSplit',
                                           under_dt,
                                           vol_dt,
                                           trade_unit=units_dt,
                                           ratios=ratios,
                                           lookbacks=lookbacks,
                                           agent=None,
                                           daily_close=daily_close,
                                           ma_win=10,
                                           email_notify=[],
                                           min_rng=[0.004])

    ins_setup = {
        'i1601': [2, 2, 2],
        #'jm1601': [1, 1, 1],
        'TF1512': [1, 1, 1],
        'TC601': [2, 4, 1],
        'TA601': [2, 3, 2],
        #'bu1512': [1, 1, 1],
        'CF601': [2, 1, 2],
        'ru1601': [1, 1, 1],
    }
    insts = ins_setup.keys()
    units_tl = [ins_setup[inst][2] for inst in insts]
    under_tl = [[inst] for inst in insts]
    vol_tl = [[1] for inst in insts]
    trail_loss = [ins_setup[inst][0] for inst in insts]
    max_pos = [ins_setup[inst][1] for inst in insts]
    tl_strat = strat_tl.TurtleTrader('ProdTL',
                                     under_tl,
                                     vol_tl,
                                     trade_unit=units_tl,
                                     agent=None,
                                     email_notify=['*****@*****.**'],
                                     windows=[5, 15],
                                     max_pos=max_pos,
                                     trail_loss=trail_loss)
    ins_setup = {
        'j1601': [1, 1, 1],
        'rb1601': [1, 1, 1],
        #'bu1512' :[2, 4, 1],
        'p1601': [1, 1, 2],
        'jd1601': [2, 2, 1],
    }
    insts = ins_setup.keys()
    units_tl = [ins_setup[inst][2] for inst in insts]
    under_tl = [[inst] for inst in insts]
    vol_tl = [[1] for inst in insts]
    trail_loss = [ins_setup[inst][0] for inst in insts]
    max_pos = [ins_setup[inst][1] for inst in insts]
    tl_strat2 = strat_tl.TurtleTrader('ProdTL2',
                                      under_tl,
                                      vol_tl,
                                      trade_unit=units_tl,
                                      agent=None,
                                      email_notify=['*****@*****.**'],
                                      windows=[10, 20],
                                      max_pos=max_pos,
                                      trail_loss=trail_loss)
    strategies = [
        rb_strat, dt_strat, dtma_strat, tl_strat, tl_strat2, dtsplit_strat
    ]
    folder = misc.get_prod_folder()
    strat_cfg = {'strategies': strategies, \
                 'folder': folder, \
                 'daily_data_days':21, \
                 'min_data_days':4 }
    myApp = MainApp(name,
                    trader_cfg,
                    user_cfg,
                    strat_cfg,
                    tday,
                    master=None,
                    save_test=False)
    myGui = Gui(myApp)
    #myGui.iconbitmap(r'c:\Python27\DLLs\thumbs-up-emoticon.ico')
    myGui.mainloop()
Ejemplo n.º 23
0
def prod_trade2(tday, name='prod_trade2'):
    base.config_logging(
        "ctp_" + name + ".log",
        level=logging.DEBUG,
        format=
        '%(name)s:%(funcName)s:%(lineno)d:%(asctime)s %(levelname)s %(message)s',
        to_console=True,
        console_level=logging.INFO)
    trader_cfg = misc.HT_PROD_TD
    user_cfg = misc.HT_PROD_MD

    ins_setup = {
        'm1601': (0, 0.8, 0.0, 0, False, 0.004),
        'RM601': (0, 0.8, 0.0, 0, False, 0.004),
        'y1601': (0, 0.7, 0.0, 0, False, 0.004),
        'p1601': (0, 0.9, 0.0, 0, False, 0.004),
        'a1601': (0, 1.0, 0.0, 0, False, 0.004),
        'rb1601': (0, 0.7, 0.5, 0, False, 0.004),
        'l1601': (2, 0.4, 0.0, 0, False, 0.004),
        'pp1601': (4, 0.4, 0.0, 0, False, 0.004),
        'TA601': (0, 0.6, 0.0, 0, False, 0.004),
        'MA601': (0, 0.8, 0.0, 0, False, 0.004),
        'jd1601': (4, 0.4, 0.0, 0, False, 0.004),
        'SR601': (1, 0.9, 0.0, 0, False, 0.004),
        'i1601': (2, 0.4, 0.0, 0, False, 0.004),
        #'TF1512':(2, 0.5, 0.0, 1, False, 0.0),
        'm1605': (0, 0.8, 0.0, 2, False, 0.004),
        'RM605': (0, 0.8, 0.0, 2, False, 0.004),
        'y1605': (0, 0.7, 0.0, 2, False, 0.004),
        'p1605': (0, 0.9, 0.0, 2, False, 0.004),
        'a1605': (0, 1.0, 0.0, 2, False, 0.004),
        'rb1605': (0, 0.7, 0.5, 4, False, 0.004),
        'l1605': (2, 0.4, 0.0, 4, False, 0.004),
        'pp1605': (4, 0.4, 0.0, 2, False, 0.004),
        'TA605': (0, 0.6, 0.0, 3, False, 0.004),
        'MA605': (0, 0.8, 0.0, 3, False, 0.004),
        'jd1605': (4, 0.4, 0.0, 4, False, 0.004),
        'SR605': (1, 0.9, 0.0, 2, False, 0.004),
        'i1605': (2, 0.4, 0.0, 2, False, 0.004),
        'cs1605': (0, 1.0, 0.0, 3, False, 0.004),
    }
    insts = ins_setup.keys()
    units_dt = [ins_setup[inst][3] for inst in insts]
    under_dt = [[inst] for inst in insts]
    vol_dt = [[1] for inst in insts]
    ratios = [[ins_setup[inst][1], ins_setup[inst][2]] for inst in insts]
    lookbacks = [ins_setup[inst][0] for inst in insts]
    daily_close = [ins_setup[inst][4] for inst in insts]
    min_rng = [ins_setup[inst][5] for inst in insts]
    dt_strat1 = strat_dt.DTTrader('DT1',
                                  under_dt,
                                  vol_dt,
                                  trade_unit=units_dt,
                                  ratios=ratios,
                                  lookbacks=lookbacks,
                                  agent=None,
                                  daily_close=daily_close,
                                  email_notify=[],
                                  ma_win=10,
                                  min_rng=min_rng)

    ins_setup = {
        'm1601': (0, 0.7, 0.0, 0, False, 0.004),
        'RM601': (0, 0.6, 0.0, 0, False, 0.004),
        'y1601': (0, 0.6, 0.0, 0, False, 0.004),
        'p1601': (0, 1.1, 0.0, 0, False, 0.004),
        'a1601': (0, 0.8, 0.0, 0, False, 0.004),
        'rb1601': (0, 0.6, 0.0, 0, False, 0.004),
        'l1601': (0, 0.7, 0.0, 0, False, 0.004),
        'pp1601': (4, 0.35, 0.0, 0, False, 0.004),
        'TA601': (0, 1.0, 0.0, 0, False, 0.004),
        'MA601': (0, 0.9, 0.0, 0, False, 0.004),
        'jd1601': (4, 0.3, 0.0, 0, False, 0.004),
        'SR601': (1, 0.8, 0.0, 0, False, 0.004),
        'i1601': (2, 0.5, 0.0, 0, False, 0.004),
        #'TF1512': (2, 0.6, 0.0, 1, False, 0.0),
        'm1605': (0, 0.7, 0.0, 2, False, 0.004),
        'RM605': (0, 0.6, 0.0, 2, False, 0.004),
        'y1605': (0, 0.6, 0.0, 2, False, 0.004),
        'p1605': (0, 1.1, 0.0, 2, False, 0.004),
        'a1605': (0, 0.8, 0.0, 2, False, 0.004),
        'rb1605': (0, 0.6, 0.0, 4, False, 0.004),
        'l1605': (0, 0.7, 0.0, 4, False, 0.004),
        'pp1605': (4, 0.35, 0.0, 2, False, 0.004),
        'TA605': (0, 1.0, 0.0, 3, False, 0.004),
        'MA605': (0, 0.9, 0.0, 3, False, 0.004),
        'jd1605': (4, 0.3, 0.0, 4, False, 0.004),
        'SR605': (1, 0.8, 0.0, 2, False, 0.004),
        'i1605': (2, 0.5, 0.0, 2, False, 0.004),
        'cs1605': (0, 1.1, 0.0, 3, False, 0.004),
    }
    insts = ins_setup.keys()
    units_dt = [ins_setup[inst][3] for inst in insts]
    under_dt = [[inst] for inst in insts]
    vol_dt = [[1] for inst in insts]
    ratios = [[ins_setup[inst][1], ins_setup[inst][2]] for inst in insts]
    lookbacks = [ins_setup[inst][0] for inst in insts]
    daily_close = [ins_setup[inst][4] for inst in insts]
    min_rng = [ins_setup[inst][5] for inst in insts]
    dt_strat2 = strat_dt.DTTrader('DT2',
                                  under_dt,
                                  vol_dt,
                                  trade_unit=units_dt,
                                  ratios=ratios,
                                  lookbacks=lookbacks,
                                  agent=None,
                                  daily_close=daily_close,
                                  email_notify=[],
                                  ma_win=10,
                                  min_rng=min_rng)
    ins_setup = {
        'm1601': (0, 0.8, 0.0, 0, False),
        'RM601': (0, 0.8, 0.0, 0, False),
        'y1601': (0, 0.9, 0.0, 0, False),
        'p1601': (1, 1.0, 0.0, 0, False),
        'a1601': (1, 0.9, 0.0, 0, False),
        'rb1601': (2, 0.5, 0.0, 0, False),
        'TA601': (1, 0.7, 0.0, 0, False),
        'MA601': (1, 0.7, 0.0, 0, False),
        'SR601': (2, 0.9, 0.0, 0, False),
        'i1601': (4, 0.4, 0.0, 0, False),
        'ag1512': (1, 0.6, 0.0, 0, False),
        'ag1606': (1, 0.8, 0.0, 2, False),
        'm1605': (0, 0.8, 0.0, 2, False),
        'RM605': (0, 0.8, 0.0, 2, False),
        'y1605': (0, 0.9, 0.0, 2, False),
        'p1605': (1, 1.0, 0.0, 2, False),
        'a1605': (1, 0.9, 0.0, 2, False),
        'rb1605': (2, 0.5, 0.0, 4, False),
        'TA605': (1, 0.7, 0.0, 3, False),
        'MA605': (1, 0.7, 0.0, 3, False),
        'SR605': (2, 0.9, 0.0, 2, False),
        'i1605': (4, 0.4, 0.0, 2, False),
    }
    insts = ins_setup.keys()
    units_dt = [ins_setup[inst][3] for inst in insts]
    under_dt = [[inst] for inst in insts]
    vol_dt = [[1] for inst in insts]
    ratios = [[ins_setup[inst][1], ins_setup[inst][2]] for inst in insts]
    lookbacks = [ins_setup[inst][0] for inst in insts]
    daily_close = [ins_setup[inst][4] for inst in insts]
    dtsplit_strat1 = dt_split.DTSplitTrader('DTSp1',
                                            under_dt,
                                            vol_dt,
                                            trade_unit=units_dt,
                                            ratios=ratios,
                                            lookbacks=lookbacks,
                                            agent=None,
                                            daily_close=daily_close,
                                            ma_win=10,
                                            email_notify=[],
                                            min_rng=[0.004])
    ins_setup = {
        'm1601': (0, 1.0, 0.0, 0, False),
        'RM601': (0, 1.0, 0.0, 0, False),
        'y1601': (0, 1.0, 0.0, 0, False),
        'p1601': (1, 1.1, 0.0, 0, False),
        'a1601': (1, 1.1, 0.0, 0, False),
        'rb1601': (0, 0.9, 0.0, 0, False),
        'TA601': (1, 0.9, 0.0, 0, False),
        'MA601': (1, 0.9, 0.0, 0, False),
        'SR601': (4, 0.45, 0.0, 0, False),
        'i1601': (4, 0.5, 0.0, 0, False),
        'ag1512': (1, 1.1, 0.0, 0, False),
        'ag1606': (1, 1.1, 0.0, 2, False),
        'm1605': (0, 1.0, 0.0, 2, False),
        'RM605': (0, 1.0, 0.0, 2, False),
        'y1605': (0, 1.0, 0.0, 2, False),
        'p1605': (1, 1.1, 0.0, 2, False),
        'a1605': (1, 1.1, 0.0, 2, False),
        'rb1605': (0, 0.9, 0.0, 4, False),
        'TA605': (1, 0.9, 0.0, 3, False),
        'MA605': (1, 0.9, 0.0, 3, False),
        'SR605': (4, 0.45, 0.0, 2, False),
        'i1605': (4, 0.5, 0.0, 2, False),
    }
    insts = ins_setup.keys()
    units_dt = [ins_setup[inst][3] for inst in insts]
    under_dt = [[inst] for inst in insts]
    vol_dt = [[1] for inst in insts]
    ratios = [[ins_setup[inst][1], ins_setup[inst][2]] for inst in insts]
    lookbacks = [ins_setup[inst][0] for inst in insts]
    daily_close = [ins_setup[inst][4] for inst in insts]
    dtsplit_strat2 = dt_split.DTSplitTrader('DTSp2',
                                            under_dt,
                                            vol_dt,
                                            trade_unit=units_dt,
                                            ratios=ratios,
                                            lookbacks=lookbacks,
                                            agent=None,
                                            daily_close=daily_close,
                                            ma_win=10,
                                            email_notify=[],
                                            min_rng=[0.004])
    ins_setup = {
        'i1601': [1, 1, 2],
        'TA601': [2, 2, 2],
        'bu1512': [2, 1, 1],
        'bu1601': [2, 1, 1],
        'i1605': [1, 1, 2],
        'TA605': [2, 2, 2],
        'ZC605': [2, 3, 1],
    }
    insts = ins_setup.keys()
    units_tl = [ins_setup[inst][2] for inst in insts]
    under_tl = [[inst] for inst in insts]
    vol_tl = [[1] for inst in insts]
    trail_loss = [ins_setup[inst][0] for inst in insts]
    max_pos = [ins_setup[inst][1] for inst in insts]
    tl_strat1 = strat_tl.TurtleTrader('TL1',
                                      under_tl,
                                      vol_tl,
                                      trade_unit=units_tl,
                                      agent=None,
                                      email_notify=[],
                                      windows=[5, 15],
                                      max_pos=max_pos,
                                      trail_loss=trail_loss)
    ins_setup = {
        'j1601': [1, 2, 1],
        #'TC605': [2, 3, 2],
        'i1601': [2, 2, 1],
        'j1605': [1, 2, 1],
        'ZC605': [2, 3, 2],
        'i1605': [2, 2, 1],
    }
    insts = ins_setup.keys()
    units_tl = [ins_setup[inst][2] for inst in insts]
    under_tl = [[inst] for inst in insts]
    vol_tl = [[1] for inst in insts]
    trail_loss = [ins_setup[inst][0] for inst in insts]
    max_pos = [ins_setup[inst][1] for inst in insts]
    tl_strat2 = strat_tl.TurtleTrader('TL2',
                                      under_tl,
                                      vol_tl,
                                      trade_unit=units_tl,
                                      agent=None,
                                      email_notify=[],
                                      windows=[10, 20],
                                      max_pos=max_pos,
                                      trail_loss=trail_loss)
    strategies = [
        dtsplit_strat1, dtsplit_strat2, dt_strat1, dt_strat2, tl_strat1,
        tl_strat2
    ]
    folder = misc.get_prod_folder()
    strat_cfg = {'strategies': strategies, \
                 'folder': folder, \
                 'daily_data_days':21, \
                 'min_data_days':3 }

    myApp = MainApp(name,
                    trader_cfg,
                    user_cfg,
                    strat_cfg,
                    tday,
                    master=None,
                    save_test=False)
    myGui = Gui(myApp)
    #myGui.iconbitmap(r'c:\Python27\DLLs\thumbs-up-emoticon.ico')
    myGui.mainloop()
Ejemplo n.º 24
0
def prod_test(tday, name='prod_test'):
    base.config_logging("ctp_" + name + ".log", level=logging.DEBUG,
                   format = '%(name)s:%(funcName)s:%(lineno)d:%(asctime)s %(levelname)s %(message)s',
                   to_console = True,
                   console_level = logging.INFO)
    trader_cfg = None
    user_cfg = misc.HT_PROD_MD
    ins_setup = {'ru1605':  [[0.35, 0.08, 0.25], 1,  120, 3],
                 'rb1605':  [[0.25, 0.05, 0.15], 5, 20, 3],
                 'RM605' :  [[0.35, 0.07, 0.25], 4,  20, 1],
                 'm1605' :  [[0.35, 0.07, 0.25], 4,  30, 3],
                 'ag1606': [[0.4, 0.1, 0.3], 4,  40, 5],
                 'y1605' : [[0.25, 0.05, 0.15], 4,  60, 1],
                 'cu1603': [[0.25, 0.05, 0.15], 1,  700, 1]}
    insts = ins_setup.keys()
    units_rb = [ins_setup[inst][1] for inst in insts]
    under_rb = [[inst] for inst in insts]
    vol_rb = [[1] for inst in insts]
    ratios = [ins_setup[inst][0] for inst in insts]
    min_rng = [ins_setup[inst][2] for inst in insts]
    freq = [ins_setup[inst][3] for inst in insts]
    stop_loss = 0.015
    rb_strat = strat_rb.RBreakerTrader('ProdRB', under_rb, vol_rb, trade_unit = units_rb,
                                 ratios = ratios, min_rng = min_rng, trail_loss = stop_loss, freq = freq,
                                 agent = None, email_notify = [])
    ins_setup ={
                'TF1603':(2, 0.5, 0.0, 1, False, 0.0),
                'm1605': (0,0.8, 0.0, 2, False, 0.004),
                'RM605': (0,0.8, 0.0, 2, False, 0.004),
                'y1605': (0,0.7, 0.0, 2, False, 0.004),
                'p1605': (0,0.9, 0.0, 2, False, 0.004),
                'a1605' :(0,1.0, 0.0, 2, False, 0.004),
                'rb1605':(0,0.7, 0.5, 4, False, 0.004),
                'l1605': (2,0.4, 0.0, 4, False, 0.004),
                'pp1605':(4,0.4, 0.0, 2, False, 0.004),
                'TA605' :(0, 0.6, 0.0, 3, False, 0.004),
                'MA605' :(0, 0.8, 0.0, 3, False, 0.004),
                'jd1605':(4, 0.4, 0.0, 4, False, 0.004),
                'SR605': (1, 0.9, 0.0, 2, False, 0.004),
                'i1605' :(2, 0.4,0.0, 2,  False, 0.004),
                'cs1605' :(0, 1.0, 0.0, 3, False, 0.004),
                }
    insts = ins_setup.keys()
    units_dt = [ins_setup[inst][3] for inst in insts]
    under_dt = [[inst] for inst in insts]
    vol_dt = [[1] for inst in insts]
    ratios = [[ins_setup[inst][1], ins_setup[inst][2]] for inst in insts]
    lookbacks = [ins_setup[inst][0] for inst in insts]
    daily_close = [ins_setup[inst][4] for inst in insts]
    min_rng = [ins_setup[inst][5] for inst in insts]
    dt_strat = dt_bar.DTBarTrader('ProdDT', under_dt, vol_dt, trade_unit = units_dt,
                                 ratios = ratios, lookbacks = lookbacks, 
                                 agent = None, daily_close = daily_close, ma_win = 10,
                                 email_notify = [], min_rng = min_rng)
    ins_setup = {
                'TF1603': (2, 0.6, 0.0, 1, False, 0.0),
                'm1605':  (0, 0.7, 0.0, 2, False, 0.004),
                'RM605':  (0, 0.6, 0.0, 2, False, 0.004),
                'y1605':  (0, 0.6, 0.0, 2, False, 0.004),
                'p1605':  (0, 1.1, 0.0, 2, False, 0.004),
                'a1605' : (0, 0.8, 0.0, 2, False, 0.004),
                'rb1605': (0, 0.6, 0.0, 4, False, 0.004),
                'l1605':  (0, 0.7, 0.0, 4, False, 0.004),
                'pp1605': (4, 0.35, 0.0, 2, False, 0.004),
                'TA605' : (0, 1.0, 0.0, 3, False, 0.004),
                'MA605' : (0, 0.9, 0.0, 3, False, 0.004),
                'jd1605': (4, 0.3, 0.0, 4, False, 0.004),
                'SR605':  (1, 0.8, 0.0, 2, False, 0.004),
                'i1605' : (2, 0.5,0.0,  2, False, 0.004),
                'cs1605' :(0, 1.1, 0.0, 3, False, 0.004),
                }
    insts = ins_setup.keys()
    units_dt = [ins_setup[inst][3] for inst in insts]
    under_dt = [[inst] for inst in insts]
    vol_dt = [[1] for inst in insts]
    ratios = [[ins_setup[inst][1], ins_setup[inst][2]] for inst in insts]
    lookbacks = [ins_setup[inst][0] for inst in insts]
    daily_close = [ins_setup[inst][4] for inst in insts]
    min_rng = [ins_setup[inst][5] for inst in insts]
    dtma_strat = dt_bar.DTBarTrader('DTMA10', under_dt, vol_dt, trade_unit = units_dt,
                                 ratios = ratios, lookbacks = lookbacks, 
                                 agent = None, daily_close = daily_close, 
                                 email_notify = [], min_rng = min_rng)

    ins_setup = {
                 'ag1606': (1, 0.8, 0.0, 2, False),
                 'm1605': (0, 0.8, 0.0, 2, False),
                 'RM605':  (0, 0.8, 0.0, 2, False),
                 'y1605':  (0, 0.9, 0.0, 2, False),
                 'p1605':  (1, 1.0, 0.0, 2, False),
                 'a1605':  (1, 0.9, 0.0, 2, False),
                 'rb1605': (2, 0.5, 0.0, 4, False),
                 'TA605' : (1, 0.7, 0.0, 3, False),
                 'MA605' : (1, 0.7, 0.0, 3, False),
                 'SR605' : (2, 0.9, 0.0, 2, False),
                 'i1605' : (4, 0.4, 0.0, 2, False),
                }
    insts = ins_setup.keys()
    units_dt = [ins_setup[inst][3] for inst in insts]
    under_dt = [[inst] for inst in insts]
    vol_dt = [[1] for inst in insts]
    ratios = [[ins_setup[inst][1], ins_setup[inst][2]] for inst in insts]
    lookbacks = [ins_setup[inst][0] for inst in insts]
    daily_close = [ins_setup[inst][4] for inst in insts]
    dtsplit_strat1 = dt_split.DTSplitTrader('DTSp1', under_dt, vol_dt, trade_unit = units_dt,
                                 ratios = ratios, lookbacks = lookbacks,
                                 agent = None, daily_close = daily_close, ma_win = 10,
                                 email_notify = [], min_rng = [0.004])
    ins_setup = {
                 'ag1606': (1, 1.1, 0.0, 2, False),
                 'm1605':  (0, 1.0, 0.0, 2, False),
                 'RM605':  (0, 1.0, 0.0, 2, False),
                 'y1605':  (0, 1.0, 0.0, 2, False),
                 'p1605':  (1, 1.1, 0.0, 2, False),
                 'a1605':  (1, 1.1, 0.0, 2, False),
                 'rb1605': (0, 0.9, 0.0, 4, False),
                 'TA605' : (1, 0.9, 0.0, 3, False),
                 'MA605' : (1, 0.9, 0.0, 3, False),
                 'SR605' : (4,0.45, 0.0, 2, False),
                 'i1605' : (4, 0.5, 0.0, 2, False),
                }
    insts = ins_setup.keys()
    units_dt = [ins_setup[inst][3] for inst in insts]
    under_dt = [[inst] for inst in insts]
    vol_dt = [[1] for inst in insts]
    ratios = [[ins_setup[inst][1], ins_setup[inst][2]] for inst in insts]
    lookbacks = [ins_setup[inst][0] for inst in insts]
    daily_close = [ins_setup[inst][4] for inst in insts]
    dtsplit_strat2 = dt_split.DTSplitTrader('DTSp2', under_dt, vol_dt, trade_unit = units_dt,
                                 ratios = ratios, lookbacks = lookbacks,
                                 agent = None, daily_close = daily_close, ma_win = 10,
                                 email_notify = [], min_rng = [0.004])

    ins_setup = {
                 'p1605':  (1, 0.9, 0.0, 2, False),
                 'rb1605': (0, 0.7, 0.0, 2, False),
                 'pp1605': (2, 0.25,0.0, 1, False),
                 'TF1603': (2, 0.5, 0.0, 1, False),
                 'MA605' : (2, 0.25,0.0, 3, False),
                 'SR605' : (1, 0.9, 0.0, 2, False),
                }
    insts = ins_setup.keys()
    units_dt = [ins_setup[inst][3] for inst in insts]
    under_dt = [[inst] for inst in insts]
    vol_dt = [[1] for inst in insts]
    ratios = [[ins_setup[inst][1], ins_setup[inst][2]] for inst in insts]
    lookbacks = [ins_setup[inst][0] for inst in insts]
    daily_close = [ins_setup[inst][4] for inst in insts]
    chan_func ={'func_high': [data_handler.DONCH_H, data_handler.donch_h], 'high_name': 'DONCH_H', \
                'func_low': [data_handler.DONCH_L, data_handler.donch_l],  'low_name': 'DONCH_L',  \
                'func_args': {'n': 5}}
    dtchan5_sp1 = dt_chansplit.DTChanSplitTrader('DTChan5Sp1',
                                                under_dt,
                                                vol_dt,
                                                trade_unit = units_dt,
                                                ratios = ratios,
                                                lookbacks = lookbacks,
                                                agent = None,
                                                daily_close = daily_close,
                                                chan_func = chan_func,
                                                open_period = [300, 2115],
                                                email_notify = [],
                                                min_rng = [0.002])
    ins_setup = {
                 'p1605':  (1, 1.0, 0.0, 2, False),
                 'rb1605': (0, 0.6, 0.0, 2, False),
                 'pp1605': (2, 0.3, 0.0, 1, False),
                 'TF1603': (1, 0.7, 0.0, 1, False),
                 'MA605' : (2, 0.3, 0.0, 3, False),
                 'SR605' : (1, 1.0, 0.0, 2, False),
                }
    insts = ins_setup.keys()
    units_dt = [ins_setup[inst][3] for inst in insts]
    under_dt = [[inst] for inst in insts]
    vol_dt = [[1] for inst in insts]
    ratios = [[ins_setup[inst][1], ins_setup[inst][2]] for inst in insts]
    lookbacks = [ins_setup[inst][0] for inst in insts]
    daily_close = [ins_setup[inst][4] for inst in insts]
    chan_func ={'func_high': [data_handler.DONCH_H, data_handler.donch_h], 'high_name': 'DONCH_H', \
                'func_low': [data_handler.DONCH_L, data_handler.donch_l],  'low_name': 'DONCH_L',  \
                'func_args': {'n': 5}}
    dtchan5_sp2 = dt_chansplit.DTChanSplitTrader('DTChan5Sp2',
                                                under_dt,
                                                vol_dt,
                                                trade_unit = units_dt,
                                                ratios = ratios,
                                                lookbacks = lookbacks,
                                                agent = None,
                                                daily_close = daily_close,
                                                chan_func = chan_func,
                                                open_period = [300, 2115],
                                                email_notify = [],
                                                min_rng = [0.002])
    ins_setup = {
                 'cs1605': (1, 1.1, 0.0, 3, False),
                 'l1605':  (0, 0.7, 0.0, 1, False),
                 'i1605':  (0, 0.7, 0.0, 2, False),
                 'j1605':  (2, 0.35,0.0, 2, False),
                 'cu1603': (1, 0.6, 0.0, 1, False),
                }
    insts = ins_setup.keys()
    units_dt = [ins_setup[inst][3] for inst in insts]
    under_dt = [[inst] for inst in insts]
    vol_dt = [[1] for inst in insts]
    ratios = [[ins_setup[inst][1], ins_setup[inst][2]] for inst in insts]
    lookbacks = [ins_setup[inst][0] for inst in insts]
    daily_close = [ins_setup[inst][4] for inst in insts]
    chan_func ={'func_high': [data_handler.DONCH_H, data_handler.donch_h], 'high_name': 'DONCH_H', \
                'func_low': [data_handler.DONCH_L, data_handler.donch_l],  'low_name': 'DONCH_L',  \
                'func_args': {'n': 10}}
    dtchan10_sp1 = dt_chansplit.DTChanSplitTrader('DTChan10Sp1',
                                                under_dt,
                                                vol_dt,
                                                trade_unit = units_dt,
                                                ratios = ratios,
                                                lookbacks = lookbacks,
                                                agent = None,
                                                daily_close = daily_close,
                                                chan_func = chan_func,
                                                open_period = [300, 2115],
                                                email_notify = [],
                                                min_rng = [0.002])
    ins_setup = {
                 'cs1605': (1, 1.0, 0.0, 3, False),
                 'l1605':  (2, 0.4, 0.0, 1, False),
                 'i1605':  (0, 0.9, 0.0, 2, False),
                 'j1605':  (2, 0.4, 0.0, 2, False),
                 'cu1603': (2,0.35, 0.0, 1, False),
                }
    insts = ins_setup.keys()
    units_dt = [ins_setup[inst][3] for inst in insts]
    under_dt = [[inst] for inst in insts]
    vol_dt = [[1] for inst in insts]
    ratios = [[ins_setup[inst][1], ins_setup[inst][2]] for inst in insts]
    lookbacks = [ins_setup[inst][0] for inst in insts]
    daily_close = [ins_setup[inst][4] for inst in insts]
    chan_func ={'func_high': [data_handler.DONCH_H, data_handler.donch_h], 'high_name': 'DONCH_H', \
                'func_low': [data_handler.DONCH_L, data_handler.donch_l],  'low_name': 'DONCH_L',  \
                'func_args': {'n': 10}}
    dtchan10_sp2 = dt_chansplit.DTChanSplitTrader('DTChan10Sp2',
                                                under_dt,
                                                vol_dt,
                                                trade_unit = units_dt,
                                                ratios = ratios,
                                                lookbacks = lookbacks,
                                                agent = None,
                                                daily_close = daily_close,
                                                chan_func = chan_func,
                                                open_period = [300, 2115],
                                                email_notify = [],
                                                min_rng = [0.002])
    ins_setup = {
                 'm1605':  (1, 0.7, 0.0, 3, False),
                 'RM605':  (2,0.25, 0.0, 3, False),
                 'y1605':  (1, 0.8, 0.0, 2, False),
                 'l1605':  (0, 0.7, 0.0, 1, False),
                 'TF1603': (2, 0.45,0.0, 1, False),
                 'TA605' : (0, 0.7, 0.0, 2, False),
                 'i1605' : (2, 0.35,0.0, 2, False),
                }
    insts = ins_setup.keys()
    units_dt = [ins_setup[inst][3] for inst in insts]
    under_dt = [[inst] for inst in insts]
    vol_dt = [[1] for inst in insts]
    ratios = [[ins_setup[inst][1], ins_setup[inst][2]] for inst in insts]
    lookbacks = [ins_setup[inst][0] for inst in insts]
    daily_close = [ins_setup[inst][4] for inst in insts]
    chan_func ={'func_high': [data_handler.DONCH_H, data_handler.donch_h], 'high_name': 'DONCH_H', \
                'func_low': [data_handler.DONCH_L, data_handler.donch_l],  'low_name': 'DONCH_L',  \
                'func_args': {'n': 20}}
    dtchan20_sp1 = dt_chansplit.DTChanSplitTrader('DTChan20Sp1',
                                                under_dt,
                                                vol_dt,
                                                trade_unit = units_dt,
                                                ratios = ratios,
                                                lookbacks = lookbacks,
                                                agent = None,
                                                daily_close = daily_close,
                                                chan_func = chan_func,
                                                open_period = [300, 2115],
                                                email_notify = [],
                                                min_rng = [0.002])
    ins_setup = {
                 'm1605':  (1, 0.8, 0.0, 3, False),
                 'RM605':  (2, 0.3, 0.0, 3, False),
                 'y1605':  (1, 1.0, 0.0, 2, False),
                 'l1605':  (0, 1.0, 0.0, 1, False),
                 'TF1603': (2, 0.5, 0.0, 1, False),
                 'TA605' : (1, 0.8, 0.0, 2, False),
                 'i1605' : (2, 0.4, 0.0, 2, False),
                }
    insts = ins_setup.keys()
    units_dt = [ins_setup[inst][3] for inst in insts]
    under_dt = [[inst] for inst in insts]
    vol_dt = [[1] for inst in insts]
    ratios = [[ins_setup[inst][1], ins_setup[inst][2]] for inst in insts]
    lookbacks = [ins_setup[inst][0] for inst in insts]
    daily_close = [ins_setup[inst][4] for inst in insts]
    chan_func ={'func_high': [data_handler.DONCH_H, data_handler.donch_h], 'high_name': 'DONCH_H', \
                'func_low': [data_handler.DONCH_L, data_handler.donch_l],  'low_name': 'DONCH_L',  \
                'func_args': {'n': 20}}
    dtchan20_sp2 = dt_chansplit.DTChanSplitTrader('DTChan20Sp2',
                                                under_dt,
                                                vol_dt,
                                                trade_unit = units_dt,
                                                ratios = ratios,
                                                lookbacks = lookbacks,
                                                agent = None,
                                                daily_close = daily_close,
                                                chan_func = chan_func,
                                                open_period = [300, 2115],
                                                email_notify = [],
                                                min_rng = [0.002])
    ins_setup = {
                 'bu1601':[2, 1, 1],
                 'i1605': [1, 1, 2],
                 'TA605': [2, 2, 2],
                 'ZC605': [2, 3, 1],
                 }
    insts = ins_setup.keys()
    units_tl = [ins_setup[inst][2] for inst in insts]
    under_tl = [[inst] for inst in insts]
    vol_tl = [[1] for inst in insts]
    trail_loss = [ins_setup[inst][0] for inst in insts]
    max_pos = [ins_setup[inst][1] for inst in insts]
    tl_strat = strat_tl.TurtleTrader('ProdTL', under_tl, vol_tl, trade_unit = units_tl,
                                    agent = None, email_notify = ['*****@*****.**'],
                                     windows = [5, 15],
                                     max_pos = max_pos,
                                     trail_loss = trail_loss)
    ins_setup = {
                 'j1605': [1, 2, 1],
                 'ZC605': [2, 3, 2],
                 'i1605': [2, 2, 1],
                 }
    insts = ins_setup.keys()
    units_tl = [ins_setup[inst][2] for inst in insts]
    under_tl = [[inst] for inst in insts]
    vol_tl = [[1] for inst in insts]
    trail_loss = [ins_setup[inst][0] for inst in insts]
    max_pos = [ins_setup[inst][1] for inst in insts]
    tl_strat2 = strat_tl.TurtleTrader('ProdTL2', under_tl, vol_tl, trade_unit = units_tl,
                                    agent = None, email_notify = ['*****@*****.**'],
                                    windows = [10, 20],
                                    max_pos = max_pos,
                                    trail_loss = trail_loss )
    strategies = [rb_strat, dt_strat, dtma_strat,\
                  tl_strat, tl_strat2, \
                  dtsplit_strat1, dtsplit_strat2, \
                  dtchan5_sp1, dtchan5_sp2, \
                  dtchan10_sp1, dtchan10_sp2, \
                  dtchan20_sp1, dtchan20_sp2]
    folder = misc.get_prod_folder()
    strat_cfg = {'strategies': strategies, \
                 'folder': folder, \
                 'daily_data_days':22, \
                 'min_data_days':4 }
    myApp = MainApp(name, trader_cfg, user_cfg, strat_cfg, tday, master = None, save_test = False)
    myGui = Gui(myApp)
    #myGui.iconbitmap(r'c:\Python27\DLLs\thumbs-up-emoticon.ico')
    myGui.mainloop()