예제 #1
0
def test_creation_and_logging():
    b = Memory(db_path=':memory:')
    arg = 1, 2, 3, 'red', 100, 'red', 0.456, 4, 5, 'blue', 0.678, 5, 6, True
    b.log_balance(*arg)
    log = b.get_balance_log(1)
    assert len(log) == 1
    assert tuple(log[0].__dict__.values())[2:] == arg
from fftbg.betting import expected_payoff
from fftbg.bird.memory import Memory

LIMIT = 5000
mem = Memory()
log = mem.get_balance_log(limit=LIMIT)

count = 0
payout_bet_sum = 0
payout_sum = 0
neg_sum = 0
for entry in log:
    if entry.bet_on == entry.left_team:
        payoff_on_bet = expected_payoff(entry.left_prediction, entry.wager,
                                        entry.left_total_on_bet,
                                        entry.right_total_on_bet)
    else:
        payoff_on_bet = expected_payoff(entry.right_prediction, entry.wager,
                                        entry.right_total_on_bet,
                                        entry.left_total_on_bet)

    if entry.bet_on == entry.left_team:
        payoff_on_final = expected_payoff(entry.left_prediction, entry.wager,
                                          entry.left_total_final,
                                          entry.right_total_final)
    else:
        payoff_on_final = expected_payoff(entry.right_prediction, entry.wager,
                                          entry.right_total_final,
                                          entry.left_total_final)

    # print(f'payoff bet: {int(payoff_on_bet):d}, final: {int(payoff_on_final):d}')