Ejemplo n.º 1
0
    print_summary_heading()

    for k in run_dict.keys():
        values = extract_print_values(run_dict, k, trading_days)
        print_values(values)


def backtest_main():
    start_time = time()
    bt = Backtester(update_stats=False)
    run_dict = run_back_set(bt)
    trading_days = len(bt.backtest_trading_dates)
    print_summary(trading_days, run_dict)

    log('')
    log('Done.')
    calc_runtime(start_time, True)


if __name__ == "__main__":

    log_fnm = "test" + get_current_day_and_time() + ".log"
    open_logfile(LOGPATH, log_fnm)

    if is_holiday() == True:
        log('Today is not a trading day!', True)
        log('', True)
        log('Done', True)
    else:
        backtest_main()
Ejemplo n.º 2
0

def stats_main():
    log("Starting stats.py")
    log('')
    stats = Stats(TRAIN_TRADE_FNM, TEST_TRADE_FNM, "24m")

    log('Calculating individual ticker stats...\n')
    stats.calc_stats()

    log('Setting threshold for pct_desired > 10...')
    stats.heuristic(10)

    log('Saving the ticker stats (including good)...')
    stats.save_good_tickers(STATS_FNM)

    test_add_day(stats)


if __name__ == "__main__":

    log_fnm = "stats" + get_current_day_and_time() + ".log"
    open_logfile(LOGPATH, log_fnm)

    if is_holiday() == True:
        log('Today is not a trading day!', True)
        log('', True)
        log('Done', True)
    else:
        stats_main()
Ejemplo n.º 3
0
    seconds, minutes, hours = calc_time_passed(stats_start_time)
    log(f'trade_main() took (hh:mm:ss) : {hours}:{minutes}:{seconds}')


    backtest_start_time = time()
    log('Starting backtest_main().')
    backtest_main()
    log('backtest_main() is done.')
    seconds, minutes, hours = calc_time_passed(backtest_start_time)
    log(f'trade_main() took (hh:mm:ss) : {hours}:{minutes}:{seconds}')


    log('')
    log('Done.')

    # needs to go into util.py as helper function
    sleep(60)
    seconds, minutes, hours = calc_time_passed(start_time)
    log(f'Run time (hh:mm:ss) : {hours}:{minutes}:{seconds}')

if __name__ == "__main__":

    log_fnm = "job"+ get_current_day_and_time() + ".log"
    open_logfile(LOGPATH, log_fnm)

    if is_holiday() == True:
        log('Today is not a trading day!', True)
        log('', True)
        log('Done', True)
    else:
        job_main()
Ejemplo n.º 4
0
    log(f"Saving buy opportunities to {BUY_FNM} ({len(buy_opportunities_df)})")
    buy_opportunities_df.to_csv(BUY_FNM, index=False)
    log('')


def trade_main():
    log("Generating possible trades")
    log('')

    tickers = build_ticker_list()
    train_possible_trades_df, test_possible_trades_df, buy_opportunities_df \
        = call_get_possible_trades(tickers)
    train_possible_trades_df = drop_suspicious_trades(train_possible_trades_df)
    test_possible_trades_df = drop_suspicious_trades(test_possible_trades_df)
    save_files(train_possible_trades_df, test_possible_trades_df, \
               buy_opportunities_df)
    log('Done.')


if __name__ == "__main__":

    log_fnm = "trade" + get_current_day_and_time() + ".log"
    open_logfile(LOGPATH, log_fnm)

    if is_holiday() == True:
        log('Today is not a trading day!', True)
        log('', True)
        log('Done', True)
    else:
        trade_main()