Ejemplo n.º 1
0
def main(job_id, D):
    print "job_id", job_id, " params:", D

    equities1 = {}
    register(
        'my-db-bundle',  # name this whatever you like
        viadb(equities1),
        calendar='SHSZ')

    parsed = {}
    parsed['initialize'] = None
    parsed['handle_data'] = None
    parsed['before_trading_start'] = None
    parsed['analyze'] = None
    parsed['algotext'] = None
    parsed['defines'] = ()
    parsed['capital_base'] = 1000000
    parsed['data'] = None

    parsed['bundle'] = 'my-db-bundle'
    #parsed['bundle']='YAHOO'
    #parsed['bundle_timestamp']=None
    parsed['bundle_timestamp'] = pd.Timestamp.utcnow()
    parsed['start'] = Timestamp('2017-03-01 13:30:00+0000', tz='UTC')
    parsed['end'] = Timestamp('2017-06-01 13:30:00+0000', tz='UTC')
    parsed['algofile'] = open(
        '/data/kanghua/workshop/strategy/campaign/hyperparam/example-new/zipline_strategy.py'
    )
    parsed['data_frequency'] = 'daily'

    parsed['print_algo'] = False
    parsed['output'] = 'os.devnull'
    parsed['local_namespace'] = None
    parsed['environ'] = os.environ
    parsed['bm_symbol'] = None

    # Below what we expect spearmint to pass us
    # parsed['algo_params']=[47,88.7,7.7]
    # D={}
    # D['timeperiod']=10
    # D['nbdevup']=1.00
    # D['nbdevdn']=1.00
    parsed['algo_params'] = D
    perf = _run(**parsed)
    StartV = perf['portfolio_value'][0]
    EndV = perf['portfolio_value'][-1]
    # spearmint wants to minimize so return negative profit
    OPTIM = (StartV - EndV)
    return OPTIM
Ejemplo n.º 2
0
        'longs': longs.downsample('week_start'),
        'shorts': shorts.downsample('week_start'),
        'predict_rank': predict_rank.downsample('week_start'),
    }
    pipe = Pipeline(
        columns=pipe_final_columns,
        screen=long_short_screen,
    )
    return pipe


############################################# bundle #############################################
equities1 = {}
register(
    'my-db-bundle',  # name this whatever you like
    viadb(equities1),
    calendar='SHSZ')
bundle = 'my-db-bundle'
bundle_timestamp = pd.Timestamp.utcnow()
environ = os.environ
bundle_data = load(
    bundle,
    environ,
    bundle_timestamp,
)
prefix, connstr = re.split(
    r'sqlite:///',
    str(bundle_data.asset_finder.engine.url),
    maxsplit=1,
)
#print prefix, connstr
Ejemplo n.º 3
0
import os