-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bank.py
52 lines (35 loc) · 1.26 KB
/
Bank.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from GDAX import GDAX
class Bank(object):
"""docstring foBankme"""
def __init__(self, USD, Crypto, Coin = 'BTC-USD'):
self.USD = USD
self.Crypto = Crypto
self.dead = False
self.coin = Coin
def current_info(self):
return "=======Bank Info: ======== \n" + "Current USD: " + str(self.USD) + "\n" + "Current Crypto: " + str(self.Crypto) + "\n" +"==============="
# Buy Crypto based off current price
def buy(self, price_crypto):
if self.USD < 25:
print "Insuffecient USD to make Purchase"
self.dead = True
return
# The amount used to purchase BTC
purchase_amount = (self.USD/2.0) - ((self.USD/2.0) * GDAX.fee(self.coin))
# Gained Crypto = purchase_amount / (price of one coin)
self.Crypto = self.Crypto + (purchase_amount/(price_crypto * 1.0))
# Loss USD = USD - Purchase amount
self.USD = self.USD - purchase_amount
return (self.current_info())
# Sell Crypto based off current price
def sell(self, price_crypto):
if self.Crypto <= 0:
print "Insuffecient Crypto to make Sale"
self.dead = True
return
gain_amount = (self.Crypto * price_crypto)
self.USD = self.USD + gain_amount - gain_amount * GDAX.fee(self.coin)
self.Crypto = 0
return (self.current_info())
def spending_money(self):
return self.USD/2