-
Notifications
You must be signed in to change notification settings - Fork 0
/
crypto.py
36 lines (29 loc) · 976 Bytes
/
crypto.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
class Crypto():
def __init__(self, rsiMax=70, rsiMin=30, rsiPeriod=14):
self.balance = 129.02
self.startBalance = self.balance
self.position = False
self.closes = []
self.belowRsiMin = False
self.rsiPeriod = rsiPeriod
self.rsiMax = rsiMax
self.rsiMin = rsiMin
self.binanceFee = 0.001
self.numTrades = 0
self.tradeCost = 0
def buy(self, amount):
self.balance -= amount
self.numTrades += 1
self.tradeCost += amount * self.binanceFee
def sell(self, amount):
self.balance += amount
self.numTrades += 1
self.tradeCost += amount * self.binanceFee
def setPosition(self, newPos):
self.position = newPos
def addClose(self, newClose):
if (len(self.closes) > 14):
self.closes.pop(0)
self.closes.append(newClose)
def setBelowRsiMin(self, newBelow):
self.belowRsiMin = newBelow