parent
be0652581e
commit
c99c22de3c
@ -0,0 +1,39 @@
|
||||
import datetime
|
||||
import lib
|
||||
from matplotlib import pyplot as plt
|
||||
import strategies as st
|
||||
import pandas as pd
|
||||
|
||||
if __name__ == "__main__":
|
||||
stockList = ["^GSPC"]
|
||||
monthly_params = dict(sum=100000, coef=1.005, t_rate=1 + 0.02 / 12)
|
||||
# startDate = datetime.datetime.fromisoformat("2000-01-01")
|
||||
# endDate = datetime.datetime.fromisoformat("2022-01-01")
|
||||
print(stockList[0])
|
||||
stockData = lib.get_data(
|
||||
stockList[0],
|
||||
)
|
||||
print(
|
||||
"Investing monthly, increasing {:.2f}%, starting from ${}".format(
|
||||
(monthly_params["coef"] * 100) - 100,
|
||||
monthly_params["sum"],
|
||||
)
|
||||
)
|
||||
for period_years in (10, 20):
|
||||
end = datetime.date.today()
|
||||
start = end - datetime.timedelta(days=period_years * 365)
|
||||
stockData = lib.get_data(stockList[0], start, end)
|
||||
print(
|
||||
"{} to {}, {:.1f} years".format(
|
||||
start,
|
||||
end,
|
||||
(end - start).days / 365,
|
||||
)
|
||||
)
|
||||
newdf = pd.concat(
|
||||
[
|
||||
lib.test_strategy(stockData, strategy, monthly_params)
|
||||
for strategy in (st.DCA, st.QDCA)
|
||||
]
|
||||
)
|
||||
print(newdf.to_string())
|
||||
Loading…
Reference in new issue