Document optimal strategy for project 6

This commit is contained in:
2020-10-13 19:40:43 -04:00
parent f53f6a4d40
commit 7481b2d6cc
2 changed files with 58 additions and 3 deletions

View File

@@ -1,5 +1,6 @@
import pandas as pd
import datetime as dt
import matplotlib.pyplot as plt
import TheoreticallyOptimalStrategy as tos
from util import plot_data, get_data
from marketsim.marketsim import compute_portvals
@@ -14,7 +15,6 @@ def test_policy():
symbol = "JPM"
start_value = 100000
sd = dt.datetime(2008, 1, 1)
# ed = dt.datetime(2008, 1, 30)
ed = dt.datetime(2009, 12, 31)
orders = tos.testPolicy(symbol=symbol, sd=sd, ed=ed, sv=start_value)
@@ -55,8 +55,9 @@ def test_policy():
portvals["Bench"] = bench["Portval"]
portvals.drop(columns=["Portval"], inplace=True)
#XXX: Save to file instead.
plot_data(portvals)
ax = portvals.plot(title="Optimal strategy versus 1000 shares of JPM")
plt.savefig('figure_5.png')
def normalize(timeseries):
return timeseries / timeseries.iloc[0]