-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_Bankroll.py
36 lines (28 loc) · 1.21 KB
/
test_Bankroll.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import unittest
from keeks.bankroll import BankRoll
from keeks.utils import RuinException
class TestBankroll(unittest.TestCase):
def test_Transactions(self):
br = BankRoll(initial_funds=1000, percent_bettable=1, max_draw_down=1)
self.assertEqual(br.bettable_funds, 1000)
self.assertEqual(br.total_funds, 1000)
br.deposit(1000)
self.assertEqual(br.bettable_funds, 2000)
self.assertEqual(br.total_funds, 2000)
br.withdraw(500)
self.assertEqual(br.bettable_funds, 1500)
self.assertEqual(br.total_funds, 1500)
def test_PercentBettable(self):
br = BankRoll(initial_funds=1000, percent_bettable=0.5, max_draw_down=1)
self.assertEqual(br.bettable_funds, 500)
self.assertEqual(br.total_funds, 1000)
br.deposit(1000)
self.assertEqual(br.bettable_funds, 1000)
self.assertEqual(br.total_funds, 2000)
br.withdraw(500)
self.assertEqual(br.bettable_funds, 750)
self.assertEqual(br.total_funds, 1500)
def test_Drawdown_Limit(self):
br = BankRoll(initial_funds=1000, percent_bettable=0.5, max_draw_down=0.3)
with self.assertRaises(RuinException):
br.withdraw(500)