|
|
@ -1,9 +1,14 @@ |
|
|
|
import pandas as pd # type: ignore |
|
|
|
|
|
|
|
from auto_trading.broker.backtest import Backtest |
|
|
|
from auto_trading.strat.hold import Hold |
|
|
|
from auto_trading.ptf.in_memory import InMemoryPortfolio |
|
|
|
from auto_trading.bot import Bot |
|
|
|
|
|
|
|
|
|
|
|
pd.options.plotting.backend = "plotly" |
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
|
bt = Backtest("./data/NYSE_smallest.csv") |
|
|
|
ptf = InMemoryPortfolio( |
|
|
@ -19,3 +24,10 @@ if __name__ == "__main__": |
|
|
|
print(order) |
|
|
|
|
|
|
|
print(bot.ptf.total_balance(bot.broker.current_change)) |
|
|
|
|
|
|
|
ch_history: pd.DataFrame = bot.broker.change_rate_history # type: ignore |
|
|
|
st_history = pd.DataFrame( |
|
|
|
[s.stocks for s in bot.ptf.states_history], |
|
|
|
index=ch_history.index, |
|
|
|
) |
|
|
|
(st_history * ch_history).fillna(0).plot.area().show() |
|
|
|