示例#1
0
def index():
    json_scorecards = retrieve_all_scorecards(db[BKT_SCORECARDS])
    json_ptrading = json.dumps(get_traded_strategies(db[PAPER_TRADING], True),
                               default=to_json)
    response.set_header('Content-Type', 'text/html')
    return template('templates/backtests',
                    json_scorecards=json_scorecards,
                    json_ptrading=json_ptrading)
示例#2
0
def main(args):
    db = MongoClient(args.host, args.port)[args.db]

    now = datetime.datetime.utcnow()
    markets = list(islice(get_future_markets(hours=args.hours), 0, 1))
    logging.info('Found %d horse races in the next %d hours' % (len(markets), args.hours))
    strats = get_traded_strategies(db[args.paper_trading], True)
    for s in strats:
        strat = Balius.from_dict(db[BKT_STRATEGIES].find_one({'_id': s['strategy_id']}))
        strat.max_expsoure = 1e6
        ex = PaperExecutionService()
        backtest(ex, strat, markets)

        bets = ex.get_mu_bets()[0]
        if len(bets) == 0:
            logging.info('Strategy with id=%s did not place any bets.' % s['strategy_id'])
            continue
        for bet in bets:
            bet['strategy_id'] = s['strategy_id']
            bet['timestamp'] = now
        db[args.paper_bets].insert(bets)
        logging.info('Successfully insert %d bets for strategy with id=%s' % (len(bets), s['strategy_id']))
示例#3
0
def index():
    json_scorecards = retrieve_all_scorecards(db[BKT_SCORECARDS])
    json_ptrading = json.dumps(get_traded_strategies(db[PAPER_TRADING], True), default=to_json)
    response.set_header('Content-Type', 'text/html')
    return template('templates/backtests', json_scorecards=json_scorecards, json_ptrading=json_ptrading)
示例#4
0
def paper_strategies_trading():
    strats = get_traded_strategies(db[PAPER_TRADING], True)
    response.set_header('Content-Type', 'application/json')
    return json.dumps(strats, default=to_json)
示例#5
0
def paper_summary():
    json_strats = json.dumps(get_traded_strategies(db[PAPER_TRADING]), default=to_json)
    response.set_header('Content-Type', 'text/html')
    return template('templates/paper', json_strats=json_strats)
示例#6
0
def paper_strategies_trading():
    strats = get_traded_strategies(db[PAPER_TRADING], True)
    response.set_header('Content-Type', 'application/json')
    return json.dumps(strats, default=to_json)
示例#7
0
def paper_summary():
    json_strats = json.dumps(get_traded_strategies(db[PAPER_TRADING]),
                             default=to_json)
    response.set_header('Content-Type', 'text/html')
    return template('templates/paper', json_strats=json_strats)