|
|
@ -10,30 +10,64 @@ from auto_trading.main import Bot |
|
|
|
import matplotlib.pyplot as plt # type: ignore |
|
|
|
from tqdm import tqdm |
|
|
|
import pandas as pd |
|
|
|
pd.options.plotting.backend = "plotly" |
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
|
csv = "data/gold.csv" |
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
|
csv = "data/cac40.csv" |
|
|
|
bt = Backtest(csv, start=10, index_col=0) |
|
|
|
|
|
|
|
start = {"USD":10_000, "Gold": 0} |
|
|
|
start = { |
|
|
|
"AXA": 10_000, |
|
|
|
"Accor": 0, |
|
|
|
"Air Liquide": 0, |
|
|
|
"Airbus": 0, |
|
|
|
"ArcelorMittal": 0, |
|
|
|
"Atos": 0, |
|
|
|
"BNP Paribas": 0, |
|
|
|
"Bouygues": 0, |
|
|
|
"Cap Gemini": 0, |
|
|
|
"Crédit Agricole": 0, |
|
|
|
"Danone": 0, |
|
|
|
"Dassault Systèmes": 0, |
|
|
|
"Engie": 0, |
|
|
|
"EssilorLuxottica": 0, |
|
|
|
"Hermes": 0, |
|
|
|
"Kering": 0, |
|
|
|
"LEGRAND": 0, |
|
|
|
"LOréal": 0, |
|
|
|
"LVMH Moet Hennessy Louis Vuitton": 0, |
|
|
|
"Michelin": 0, |
|
|
|
"Orange": 0, |
|
|
|
"Pernod Ricard": 0, |
|
|
|
"Peugeot": 0, |
|
|
|
"Publicis": 0, |
|
|
|
"Renault": 0, |
|
|
|
"SAFRAN": 0, |
|
|
|
"STMicroelectronics": 0, |
|
|
|
"Saint-Gobain": 0, |
|
|
|
"Sanofi": 0, |
|
|
|
"Schneider Electric": 0, |
|
|
|
"Société Générale": 0, |
|
|
|
"Sodexo": 0, |
|
|
|
"TOTAL": 0, |
|
|
|
"Unibail-Rodamco": 0, |
|
|
|
"VINCI": 0, |
|
|
|
"Veolia Environnement": 0, |
|
|
|
"Vivendi": 0, |
|
|
|
"Worldline SA": 0, |
|
|
|
} |
|
|
|
# pred = MeanAggregator([RandomPredictor(), SelectorPredictor({"USD": -0.1}), RandomPredictor()]) |
|
|
|
pred = Derivate(-1) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bot = Bot( |
|
|
|
ptf=InMemoryPortfolio(start.copy()), |
|
|
|
strategy=AllIn(), |
|
|
|
broker=bt, |
|
|
|
predictor=pred |
|
|
|
ptf=InMemoryPortfolio(start.copy()), strategy=AllIn(), broker=bt, predictor=pred |
|
|
|
) |
|
|
|
|
|
|
|
data = pd.DataFrame(index=bt.data.index, columns=bt.data.columns) |
|
|
|
|
|
|
|
|
|
|
|
for date in tqdm(data.index): |
|
|
|
bot.run_once() |
|
|
|
data.loc[date] = bot.ptf.content() |
|
|
|
bot.print_results() |
|
|
|
|
|
|
|
|
|
|
|
data.plot() |
|
|
|
plt.show() |
|
|
|
|
|
|
|
data.plot().show() |
|
|
|