Пример #1
0
def backtest(strategy_name):

    strategy = strategy_name.split('_', 1)[0]
    print(strategy)

    if strategy == 'netzero':
        backtest_strategies.backtest(netzero.netzero(), underlying,
                                     strategy_name, risk_capital, quantity,
                                     start, end, netzero.parameters,
                                     frequency_string)

    if strategy == 'the-bull':
        backtest_strategies.backtest(the_bull.bull(), underlying,
                                     strategy_name, risk_capital, quantity,
                                     start, end, the_bull.parameters,
                                     frequency_string)

    if strategy == 'bf70':
        backtest_strategies.backtest(bf70.bf70(), underlying, strategy_name,
                                     risk_capital, quantity, start, end,
                                     bf70.parameters, frequency_string)
Пример #2
0
    '^', '').lower() + '_' + frequency_string
if quantity is not None:
    strategy_name += "_q" + str(quantity)

backtest_strategies.backtest(bf70.bf70(), underlying, strategy_name,
                             risk_capital, quantity, start, end,
                             bf70.parameters, frequency_string,
                             include_underlying)
compute_stats.compute_stats(strategy_name, underlying, risk_capital)

strategy_name = 'the_bull_' + underlying.replace(
    '^', '').lower() + '_' + frequency_string
if quantity is not None:
    strategy_name += "_q" + str(quantity)

backtest_strategies.backtest(the_bull.bull(), underlying, strategy_name,
                             risk_capital, quantity, start, end,
                             the_bull.parameters, frequency_string,
                             include_underlying)
compute_stats.compute_stats(strategy_name, underlying, risk_capital)

strategy_name = 'netzero_' + underlying.replace(
    '^', '').lower() + '_' + frequency_string
if quantity is not None:
    strategy_name += "_q" + str(quantity)

backtest_strategies.backtest(netzero.netzero(), underlying, strategy_name,
                             risk_capital, quantity, start, end,
                             netzero.parameters, frequency_string,
                             include_underlying)
compute_stats.compute_stats(strategy_name, underlying, risk_capital)
Пример #3
0
start = datetime(2006, 11, 1).date()
# start = datetime(2010, 6, 1).date() # vxx options since: 2010-05-28
# start = datetime(2017, 1, 1).date()

end = datetime(2019, 7, 31).date()
# end = datetime.now().date()

connector = postgresql_connector.MyDB()

strategy = netzero.netzero(connector, "netzero", "^RUT", 0, 0, None, None,
                           None, None, None, None, None, None, None, None,
                           None, None, None, None, None)
backtest_strategies.backtest(strategy, "netzero", 100000, printalot, start,
                             end, netzero.parameters)

strategy = the_bull.bull(connector, "the_bull", "^RUT", 0, 0, None, None, None,
                         None, None, None, None, None, None, None, None, None,
                         None, None, None)
backtest_strategies.backtest(strategy, "the_bull", 100000, printalot, start,
                             end, the_bull.parameters)

strategy = bf70.bf70(connector, "bf70", "^RUT", 5, 5, None, None, None, None,
                     None, None, None, None, None, None, None, None, None,
                     None, None)
backtest_strategies.backtest(strategy, "bf70", 100000, printalot, start, end,
                             bf70.parameters)

print
print("--- %s seconds ---" % (time.time() - start_time))