You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
1.1 KiB

from import Backtest
from auto_trading.strat.all_in import AllIn
from auto_trading.ptf.in_memory import InMemoryPortfolio
from auto_trading.predictor.mean_agg import MeanAggregator
from auto_trading.predictor.normalized import NormalizedPredictor
from auto_trading.predictor.selector import SelectorPredictor
from auto_trading.predictor.random_predictor import RandomPredictor
from auto_trading.main import Bot
from tqdm import tqdm # type: ignore
import pandas as pd # type: ignore
pd.options.plotting.backend = "plotly"
if __name__ == "__main__":
csv = "data/gold.csv"
bt = Backtest(csv, start=10, index_col=0)
start = {
"USD": 10_000,
"Gold": 0,
pred = MeanAggregator([RandomPredictor(), SelectorPredictor({"USD": -0.1}), RandomPredictor()])
bot = Bot(
ptf=InMemoryPortfolio(start.copy()), strategy=AllIn(), broker=bt, predictor=pred
data = pd.DataFrame(,
for date in tqdm(data.index):
data.loc[date] = bot.ptf.content()