Example #1
0
def archive_models():

    df = pd.DataFrame(columns=['id', 'model_name', 'ref_object_type'])
    df.loc[0] = [1, 'vix_curve', 'strategy']
    df.loc[1] = [2, 'equity_vs_vol', 'strategy']
    df.loc[2] = [3, 'vol_rv', 'equity']

    existing_data = get_models()
    ind = df.index[~df['model_name'].isin(existing_data['model_name'].tolist()
                                          )]
    df = df.loc[ind]

    table = db.get_table('models')
    db.execute_bulk_insert(df=df, table=table)
Example #2
0
def archive_model_param_config(model_name=None, settings=None):

    export_settings = model_settings_to_json(settings)

    model_id = get_model_id(model_name)
    model_params = get_model_param_configs(model_name)

    if export_settings not in model_params['model_params'].tolist():
        new_id = db.read_sql('select max(id) from model_param_config')
        try:
            new_id = new_id['max'][0] + 1
        except:
            new_id = 0
        model_params = pd.DataFrame(columns=['id', 'model_id', 'model_params'])
        model_params.loc[0] = [new_id, model_id, export_settings]
        table = db.get_table('model_param_config')
        db.execute_bulk_insert(df=model_params, table=table)
Example #3
0
def archive_strategy_signals(model=None, signal_data=None):

    signal_names = signal_data.columns
    model_id = get_model_id(model.name)
    existing_signals = get_strategy_signals(model_name=model.name)

    df = pd.DataFrame(columns=['model_id', 'signal_name'])
    df['signal_name'] = signal_names
    df['model_id'] = model_id

    # Filter down now
    ind = df.index[~df['signal_name'].isin(existing_signals['signal_name'].
                                           tolist())]
    df = df.loc[ind]

    if len(df) > 0:
        table = db.get_table('model_signals')
        db.execute_bulk_insert(df=df, table=table)