From cb564f08ddac9cfd74ae2761e70ae700eb8c29b5 Mon Sep 17 00:00:00 2001 From: cardosofede Date: Mon, 25 Nov 2024 21:38:38 -0300 Subject: [PATCH 1/2] (feat) use new bt interface --- routers/manage_backtesting.py | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/routers/manage_backtesting.py b/routers/manage_backtesting.py index 1c0f9ea..812f1fa 100644 --- a/routers/manage_backtesting.py +++ b/routers/manage_backtesting.py @@ -3,23 +3,13 @@ from fastapi import APIRouter from hummingbot.data_feed.candles_feed.candles_factory import CandlesFactory from hummingbot.strategy_v2.backtesting.backtesting_engine_base import BacktestingEngineBase -from hummingbot.strategy_v2.backtesting.controllers_backtesting.directional_trading_backtesting import ( - DirectionalTradingBacktesting, -) -from hummingbot.strategy_v2.backtesting.controllers_backtesting.market_making_backtesting import MarketMakingBacktesting from pydantic import BaseModel from config import CONTROLLERS_MODULE, CONTROLLERS_PATH router = APIRouter(tags=["Market Backtesting"]) candles_factory = CandlesFactory() -directional_trading_backtesting = DirectionalTradingBacktesting() -market_making_backtesting = MarketMakingBacktesting() - -BACKTESTING_ENGINES = { - "directional_trading": directional_trading_backtesting, - "market_making": market_making_backtesting -} +backtesting_engine = BacktestingEngineBase() class BacktestingConfig(BaseModel): @@ -34,19 +24,16 @@ class BacktestingConfig(BaseModel): async def run_backtesting(backtesting_config: BacktestingConfig): try: if isinstance(backtesting_config.config, str): - controller_config = BacktestingEngineBase.get_controller_config_instance_from_yml( + controller_config = backtesting_engine.get_controller_config_instance_from_yml( config_path=backtesting_config.config, controllers_conf_dir_path=CONTROLLERS_PATH, controllers_module=CONTROLLERS_MODULE ) else: - controller_config = BacktestingEngineBase.get_controller_config_instance_from_dict( + controller_config = backtesting_engine.get_controller_config_instance_from_dict( config_data=backtesting_config.config, controllers_module=CONTROLLERS_MODULE ) - backtesting_engine = BACKTESTING_ENGINES.get(controller_config.controller_type) - if not backtesting_engine: - raise ValueError(f"Backtesting engine for controller type {controller_config.controller_type} not found.") backtesting_results = await backtesting_engine.run_backtesting( controller_config=controller_config, trade_cost=backtesting_config.trade_cost, start=int(backtesting_config.start_time), end=int(backtesting_config.end_time), From 6c70c3c1594a5748317f03bfff309d5a04c5b6af Mon Sep 17 00:00:00 2001 From: cardosofede Date: Tue, 26 Nov 2024 16:07:57 -0300 Subject: [PATCH 2/2] (feat) add accounts router back --- main.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index b5ce723..f3bf194 100644 --- a/main.py +++ b/main.py @@ -6,8 +6,16 @@ from fastapi import Depends, FastAPI, HTTPException, status from fastapi.security import HTTPBasic, HTTPBasicCredentials -from routers import manage_accounts, manage_backtesting, manage_broker_messages, manage_docker, manage_files, \ - manage_market_data, manage_databases, manage_performance +from routers import ( + manage_accounts, + manage_backtesting, + manage_broker_messages, + manage_databases, + manage_docker, + manage_files, + manage_market_data, + manage_performance, +) load_dotenv() security = HTTPBasic() @@ -47,3 +55,4 @@ def auth_user( app.include_router(manage_backtesting.router, dependencies=[Depends(auth_user)]) app.include_router(manage_databases.router, dependencies=[Depends(auth_user)]) app.include_router(manage_performance.router, dependencies=[Depends(auth_user)]) +app.include_router(manage_accounts.router, dependencies=[Depends(auth_user)])