This commit is contained in:
Ichinga Samuel
2024-11-04 00:32:51 +01:00
parent 2c46e18528
commit d65a8db1a2
85 changed files with 5071 additions and 2512 deletions
+31 -14
View File
@@ -2,27 +2,44 @@ import asyncio
import logging
from datetime import datetime, UTC
from aiomql.lib.backtest_runner import BackTestRunner
from aiomql.lib.backtester import BackTester
from aiomql.core import Config
from aiomql.contrib.strategies import FingerTrap, Chaos
from aiomql.contrib.strategies import Chaos
from aiomql.contrib.symbols import ForexSymbol
from aiomql.contrib.backtesting import BackTestEngine
from aiomql.core.backtesting import BackTestEngine
async def back_tester():
config = Config()
config.mode = 'backtest'
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
syms = ['Volatility 75 Index', 'Volatility 100 Index', 'Volatility 50 Index']
config.mode = "backtest"
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
)
syms = [
"Volatility 75 Index",
"Volatility 100 Index",
"Volatility 25 Index",
"Volatility 10 Index",
]
symbols = [ForexSymbol(name=sym) for sym in syms]
stgs = [Chaos(symbol=symbol) for symbol in symbols]
start = datetime(2021, 1, 1, tzinfo=UTC)
end = datetime(2021, 1, 7, tzinfo=UTC)
back_test_engine = BackTestEngine(start=start, end=end)
await back_test_engine.setup_account(balance=100)
back_test_runner = BackTestRunner(strategies=stgs, backtest_engine=back_test_engine)
await back_test_runner.run()
strategies = [Chaos(symbol=symbol) for symbol in symbols]
start = datetime(2024, 5, 1, tzinfo=UTC)
stop_time = datetime(2024, 5, 2, tzinfo=UTC)
end = datetime(2024, 5, 7, tzinfo=UTC)
back_test_engine = BackTestEngine(
start=start,
end=end,
speed=300,
stop_time=stop_time,
close_open_positions_on_exit=True,
assign_to_config=True,
preload=True,
)
await back_test_engine.setup_account(balance=350)
backtester = BackTester(backtest_engine=back_test_engine)
backtester.add_strategies(strategies=strategies)
await backtester.start()
asyncio.run(back_tester())
print("Bot executed successfully")