-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPredictor.py
More file actions
52 lines (40 loc) · 1.64 KB
/
Copy pathPredictor.py
File metadata and controls
52 lines (40 loc) · 1.64 KB
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 BasicStuff import BasicSuper
from LocalBarSource import LocalBarSource
# from TechnicalIndicator import TechnicalIndicator
class Predictor(BasicSuper):
def __init__(self, localStorageConnection, barSource:LocalBarSource, outputRule):
super().__init__(localStorageConnection, barSource=barSource)
self.childPredictors = []
self.indicators = []
self.outputRule = outputRule
self.iterTerminationRule = None
def addPredictor(self, somePredictor):
self.childPredictors.append(somePredictor)
def addIndicator(self, someInd):
self.indicators.append(someInd)
def processOneBar(self):
raise NotImplementedError()
def long(self):
"""Call this to test whether stock might be going up."""
raise NotImplementedError()
def short(self):
"""Call this to test whether stock might be going down."""
raise NotImplementedError()
def __iter__(self):
return self
def __next__(self):
if self.iterTerminationRule is not None:
pass
class DummyPredictor(Predictor):
"""This implementation of Predictor returns alternating True/False regardless of whether you call long or short."""
def __init__(self, localStorageConnection, barSource:LocalBarSource, outputRule):
super().__init__(localStorageConnection, barSource=barSource, outputRule=outputRule)
self.state = False
def processOneBar(self):
"""Prevents you from getting the not implemented error."""
pass
def long(self):
self.state = not self.state
return self.state
def short(self):
return self.long()