-
Notifications
You must be signed in to change notification settings - Fork 2
/
strategy.py
36 lines (31 loc) · 1.38 KB
/
strategy.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 numpy
class Strategy:
def __init__(self, executor, verbose = False):
self.executor = executor
self.verbose = verbose
def logVerbose(self, msg):
if self.verbose:
print msg
def decide(self, price, predict):
if self.verbose:
self.logVerbose("Price is: " + str(price) + " and next predict is: " + str(predict))
if predict > price and self.executor.getAvailableFiat() == 0.0:
self.logVerbose("Hold, since no fiat")
if predict > price and self.executor.getAvailableFiat() > 0.0:
self.logVerbose("Buy")
self.executor.buy(price)
elif predict < price and self.executor.getAvailableCrypto() == 0.0:
self.logVerbose("Hold, since no crypto")
elif predict < price and self.executor.getAvailableCrypto() > 0.0:
self.logVerbose("Sell")
self.executor.sell(price)
elif predict == price:
self.logVerbose("Predicion eq current Price")
def closeFiat(self, price):
if self.executor.getAvailableFiat() > 0.0:
self.logVerbose("Buy remaining")
self.executor.buy(price)
def closeCrypto(self, price):
if self.executor.getAvailableCrypto() > 0.0:
self.logVerbose("Sell remaining")
self.executor.sell(price)