Finish project 8 and course!

This commit is contained in:
2020-11-10 12:33:42 -05:00
parent 6e1f70bcba
commit 063d9a75ae
7 changed files with 147 additions and 19 deletions

View File

@@ -14,13 +14,13 @@ class Holding:
class QLearner(object):
def __init__(self, verbose=False, impact=0.0, commission=0.0, testing=False):
def __init__(self, verbose=False, impact=0.0, commission=0.0, testing=False, n_bins=5):
self.verbose = verbose
self.impact = impact
self.commission = commission
self.testing = testing # Decides which type of order df to return.
self.indicators = ['macd_diff', 'rsi', 'price_sma_8']
self.n_bins = 5
self.n_bins = n_bins
self.bins = {}
self.num_states = self.get_num_states()
self.num_actions = 3 # buy, sell, hold
@@ -134,7 +134,7 @@ class QLearner(object):
self.add_indicators(df, symbol)
self.bin_indicators(df)
for _ in range(10):
for _ in range(15):
self.train(df, symbol, sv)
def testPolicy(self, symbol="IBM", sd=dt.datetime(2009, 1, 1), ed=dt.datetime(2010, 1, 1), sv=10000):