Start to implement testPolicy
This commit is contained in:
@@ -1,18 +1,17 @@
|
|||||||
import pandas as pd
|
import pandas as pd
|
||||||
import datetime as dt
|
from util import get_data
|
||||||
from util import get_data, plot_data
|
from marketsim.marketsim import compute_portvals
|
||||||
|
from optimize_something.optimization import calculate_stats
|
||||||
|
|
||||||
|
|
||||||
def author():
|
def author():
|
||||||
return "felixm"
|
return "felixm"
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def testPolicy(symbol, sd, ed, sv):
|
||||||
start_date = dt.datetime(2008, 1, 1)
|
print(f"{symbol=} {sd} - {ed} {sv=}")
|
||||||
end_date = dt.datetime(2009, 12, 31)
|
# trade = date, shares (-2000, -1000, 0, 1000, 2000)
|
||||||
prices = get_data(['JPM'], pd.date_range(start_date, end_date))
|
prices = get_data([symbol], pd.date_range(sd, ed))
|
||||||
print(prices)
|
print(prices.index)
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
|
|||||||
@@ -1,5 +1,37 @@
|
|||||||
|
import datetime as dt
|
||||||
|
import TheoreticallyOptimalStrategy as tos
|
||||||
|
|
||||||
|
|
||||||
def author():
|
def author():
|
||||||
return "felixm"
|
return "felixm"
|
||||||
|
|
||||||
|
|
||||||
|
def test_policy():
|
||||||
|
sd = dt.datetime(2008, 1, 1)
|
||||||
|
ed = dt.datetime(2009, 12, 31)
|
||||||
|
tos.testPolicy(symbol="JPM", sd=sd, ed=ed, sv=100000)
|
||||||
|
|
||||||
|
|
||||||
|
def normalize(timeseries):
|
||||||
|
return timeseries / timeseries.iloc[0]
|
||||||
|
|
||||||
|
|
||||||
|
def bollinger_band(prices):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
test_policy()
|
||||||
|
# sd = dt.datetime(2008, 1, 1)
|
||||||
|
# ed = dt.datetime(2009, 12, 31)
|
||||||
|
# prices = get_data(['JPM'], pd.date_range(sd, ed))
|
||||||
|
# prices['JPM'] = normalize(prices['JPM'])
|
||||||
|
# print(prices)
|
||||||
|
|
||||||
|
# plot_data(prices)
|
||||||
|
# prices_appl = get_data(['AAPL'], pd.date_range(sd, ed), 'High')
|
||||||
|
# prices['AAPL'] = prices_appl['AAPL']
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user