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.
 
 

40 lines
1.2 KiB

from auto_trading.broker.backtest 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.main import Bot
import matplotlib.pyplot as plt
if __name__ == '__main__':
csv = "data/price_history.csv"
with open(csv, 'r') as f:
head = f.readline().replace("\n", "").split(",")[1:]
pred = MeanAggregator([NormalizedPredictor(),SelectorPredictor({"Tether": 0.7})])
bot = Bot(
ptf=InMemoryPortfolio({k:1 for k in head}),
strategy=AllIn(),
broker=Backtest(csv, index_col=0, skiprows=1600, names=head),
predictor=pred
)
bot.print_results()
print("\n")
TIME = range(400)
B = []
for _ in TIME:
bot.run_once()
#bot.print_results()
assets = bot.ptf.content()
spread=1/100
for k in assets.keys():
assets[k]=(1-spread)*assets[k]
B.append( bot.balance() )
print(B[-1])
print("\n")
plt.plot(TIME,B)
plt.show()