investing-algorithm-framework 3.3.0__tar.gz → 3.3.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/PKG-INFO +1 -1
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/app/app.py +7 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/dependency_container.py +2 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/config.py +1 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/models/order/order.py +1 -5
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/services/market_data_sources.py +21 -7
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/infrastructure/models/market_data_sources/ccxt.py +36 -15
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/infrastructure/services/market_service/ccxt_market_service.py +26 -12
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/services/backtesting/backtest_service.py +5 -2
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/services/market_data_source_service/backtest_market_data_source_service.py +1 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/services/order_service/order_backtest_service.py +0 -3
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/services/order_service/order_service.py +2 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/pyproject.toml +1 -1
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/LICENSE +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/README.md +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/__init__.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/app/__init__.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/app/algorithm.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/app/stateless/__init__.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/app/stateless/action_handlers/__init__.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/app/stateless/action_handlers/action_handler_strategy.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/app/stateless/action_handlers/check_online_handler.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/app/stateless/action_handlers/run_strategy_handler.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/app/stateless/exception_handler.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/app/strategy.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/app/task.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/app/web/__init__.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/app/web/controllers/__init__.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/app/web/controllers/orders.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/app/web/controllers/portfolio.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/app/web/controllers/positions.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/app/web/create_app.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/app/web/error_handler.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/app/web/responses.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/app/web/run_strategies.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/app/web/schemas/__init__.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/app/web/schemas/order.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/app/web/schemas/portfolio.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/app/web/schemas/position.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/app/web/setup_cors.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/create_app.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/__init__.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/constants.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/data_structures.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/decimal_parsing.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/exceptions.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/models/__init__.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/models/app_mode.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/models/backtesting/__init__.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/models/backtesting/backtest_position.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/models/backtesting/backtest_report.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/models/backtesting/backtest_reports_evaluation.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/models/base_model.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/models/market/__init__.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/models/market/market_credential.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/models/order/__init__.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/models/order/order_fee.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/models/order/order_side.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/models/order/order_status.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/models/order/order_type.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/models/portfolio/__init__.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/models/portfolio/portfolio.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/models/portfolio/portfolio_configuration.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/models/portfolio/portfolio_snapshot.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/models/position/__init__.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/models/position/position.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/models/position/position_snapshot.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/models/strategy_profile.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/models/time_frame.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/models/time_interval.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/models/time_unit.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/models/trade/__init__.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/models/trade/trade.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/models/trade/trade_status.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/models/trading_data_types.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/models/trading_time_frame.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/services/__init__.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/services/market_credential_service.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/services/market_service.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/services/portfolios/__init__.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/services/portfolios/portfolio_sync_service.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/singleton.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/stateless_actions.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/strategy.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/utils/__init__.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/utils/backtesting.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/utils/csv.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/utils/random.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/utils/signatures.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/utils/stoppable_thread.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/domain/utils/synchronized.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/infrastructure/__init__.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/infrastructure/database/__init__.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/infrastructure/database/sql_alchemy.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/infrastructure/models/__init__.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/infrastructure/models/decimal_parser.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/infrastructure/models/market_data_sources/__init__.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/infrastructure/models/market_data_sources/csv.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/infrastructure/models/model_extension.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/infrastructure/models/order/__init__.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/infrastructure/models/order/order.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/infrastructure/models/order/order_fee.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/infrastructure/models/portfolio/__init__.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/infrastructure/models/portfolio/portfolio.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/infrastructure/models/portfolio/portfolio_snapshot.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/infrastructure/models/position/__init__.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/infrastructure/models/position/position.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/infrastructure/models/position/position_snapshot.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/infrastructure/repositories/__init__.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/infrastructure/repositories/order_fee_repository.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/infrastructure/repositories/order_repository.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/infrastructure/repositories/portfolio_repository.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/infrastructure/repositories/portfolio_snapshot_repository.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/infrastructure/repositories/position_repository.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/infrastructure/repositories/position_snapshot_repository.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/infrastructure/repositories/repository.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/infrastructure/services/__init__.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/infrastructure/services/market_service/__init__.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/infrastructure/services/performance_service/__init__.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/infrastructure/services/performance_service/backtest_performance_service.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/infrastructure/services/performance_service/performance_service.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/services/__init__.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/services/backtesting/__init__.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/services/backtesting/backtest_report_writer_service.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/services/configuration_service.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/services/market_credential_service.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/services/market_data_source_service/__init__.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/services/market_data_source_service/market_data_source_service.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/services/order_service/__init__.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/services/portfolios/__init__.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/services/portfolios/backtest_portfolio_service.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/services/portfolios/portfolio_configuration_service.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/services/portfolios/portfolio_service.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/services/portfolios/portfolio_snapshot_service.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/services/portfolios/portfolio_sync_service.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/services/position_service.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/services/position_snapshot_service.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/services/repository_service.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/services/strategy_orchestrator_service.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/services/trade_service/__init__.py +0 -0
- {investing_algorithm_framework-3.3.0 → investing_algorithm_framework-3.3.1}/investing_algorithm_framework/services/trade_service/trade_service.py +0 -0
|
@@ -278,7 +278,13 @@ class App:
|
|
|
278
278
|
backtest_market_data_sources = [
|
|
279
279
|
market_data_source.to_backtest_market_data_source()
|
|
280
280
|
for market_data_source in market_data_sources
|
|
281
|
+
if market_data_source is not None
|
|
281
282
|
]
|
|
283
|
+
|
|
284
|
+
for market_data_source in backtest_market_data_sources:
|
|
285
|
+
if market_data_source is not None:
|
|
286
|
+
market_data_source.config = self.config
|
|
287
|
+
|
|
282
288
|
self.container.market_data_source_service.override(
|
|
283
289
|
BacktestMarketDataSourceService(
|
|
284
290
|
market_data_sources=backtest_market_data_sources,
|
|
@@ -787,6 +793,7 @@ class App:
|
|
|
787
793
|
return reports
|
|
788
794
|
|
|
789
795
|
def add_market_data_source(self, market_data_source):
|
|
796
|
+
market_data_source.config = self.config
|
|
790
797
|
self._market_data_source_service.add(market_data_source)
|
|
791
798
|
|
|
792
799
|
def add_market_credential(self, market_credential: MarketCredential):
|
|
@@ -68,6 +68,7 @@ class DependencyContainer(containers.DeclarativeContainer):
|
|
|
68
68
|
)
|
|
69
69
|
order_service = providers.Factory(
|
|
70
70
|
OrderService,
|
|
71
|
+
configuration_service=configuration_service,
|
|
71
72
|
order_repository=order_repository,
|
|
72
73
|
order_fee_repository=order_fee_repository,
|
|
73
74
|
portfolio_repository=portfolio_repository,
|
|
@@ -125,6 +126,7 @@ class DependencyContainer(containers.DeclarativeContainer):
|
|
|
125
126
|
)
|
|
126
127
|
backtest_service = providers.Factory(
|
|
127
128
|
BacktestService,
|
|
129
|
+
configuration_service=configuration_service,
|
|
128
130
|
order_service=order_service,
|
|
129
131
|
portfolio_repository=portfolio_repository,
|
|
130
132
|
performance_service=performance_service,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
|
|
3
3
|
from dateutil.parser import parse
|
|
4
|
-
from dateutil.tz import gettz
|
|
5
4
|
|
|
6
5
|
from investing_algorithm_framework.domain.exceptions import \
|
|
7
6
|
OperationalException
|
|
@@ -308,10 +307,7 @@ class Order(BaseModel):
|
|
|
308
307
|
remaining=ccxt_order.get("remaining", None),
|
|
309
308
|
cost=ccxt_order.get("cost", None),
|
|
310
309
|
fee=OrderFee.from_ccxt_fee(ccxt_order.get("fee", None)),
|
|
311
|
-
created_at=parse(
|
|
312
|
-
ccxt_order.get("datetime", None),
|
|
313
|
-
tzinfos={"UTC": gettz("UTC")}
|
|
314
|
-
)
|
|
310
|
+
created_at=parse(ccxt_order.get("datetime", None))
|
|
315
311
|
)
|
|
316
312
|
|
|
317
313
|
def __repr__(self):
|
|
@@ -34,6 +34,14 @@ class BacktestMarketDataSource(ABC):
|
|
|
34
34
|
self._backtest_data_start_date = backtest_data_start_date
|
|
35
35
|
self._backtest_data_index_date = backtest_data_index_date
|
|
36
36
|
|
|
37
|
+
@property
|
|
38
|
+
def config(self):
|
|
39
|
+
return self._config
|
|
40
|
+
|
|
41
|
+
@config.setter
|
|
42
|
+
def config(self, value):
|
|
43
|
+
self._config = value
|
|
44
|
+
|
|
37
45
|
def _data_source_exists(self, file_path):
|
|
38
46
|
"""
|
|
39
47
|
Function to check if the data source exists.
|
|
@@ -60,9 +68,7 @@ class BacktestMarketDataSource(ABC):
|
|
|
60
68
|
return False
|
|
61
69
|
|
|
62
70
|
return True
|
|
63
|
-
except Exception
|
|
64
|
-
logger.error(f"Error reading {file_path}")
|
|
65
|
-
logger.error(e)
|
|
71
|
+
except Exception:
|
|
66
72
|
return False
|
|
67
73
|
|
|
68
74
|
def write_data_to_file_path(self, data_file, data):
|
|
@@ -151,10 +157,10 @@ class BacktestMarketDataSource(ABC):
|
|
|
151
157
|
class MarketDataSource(ABC):
|
|
152
158
|
|
|
153
159
|
def __init__(
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
160
|
+
self,
|
|
161
|
+
identifier,
|
|
162
|
+
market,
|
|
163
|
+
symbol,
|
|
158
164
|
):
|
|
159
165
|
self._identifier = identifier
|
|
160
166
|
self._market = market
|
|
@@ -168,6 +174,14 @@ class MarketDataSource(ABC):
|
|
|
168
174
|
def identifier(self):
|
|
169
175
|
return self._identifier
|
|
170
176
|
|
|
177
|
+
@property
|
|
178
|
+
def config(self):
|
|
179
|
+
return self._config
|
|
180
|
+
|
|
181
|
+
@config.setter
|
|
182
|
+
def config(self, value):
|
|
183
|
+
self._config = value
|
|
184
|
+
|
|
171
185
|
def get_identifier(self):
|
|
172
186
|
return self.identifier
|
|
173
187
|
|
|
@@ -3,6 +3,7 @@ import os
|
|
|
3
3
|
from datetime import timedelta
|
|
4
4
|
|
|
5
5
|
import polars
|
|
6
|
+
from dateutil import parser
|
|
6
7
|
|
|
7
8
|
from investing_algorithm_framework.domain import RESOURCE_DIRECTORY, \
|
|
8
9
|
BACKTEST_DATA_DIRECTORY_NAME, DATETIME_FORMAT_BACKTESTING, \
|
|
@@ -59,7 +60,7 @@ class CCXTOHLCVBacktestMarketDataSource(
|
|
|
59
60
|
start_date_func=start_date_func,
|
|
60
61
|
end_date=end_date,
|
|
61
62
|
end_date_func=end_date_func,
|
|
62
|
-
window_size=window_size
|
|
63
|
+
window_size=window_size,
|
|
63
64
|
)
|
|
64
65
|
|
|
65
66
|
def prepare_data(
|
|
@@ -80,7 +81,6 @@ class CCXTOHLCVBacktestMarketDataSource(
|
|
|
80
81
|
When downloading the data it will use the ccxt library.
|
|
81
82
|
"""
|
|
82
83
|
# Calculating the backtest data start date
|
|
83
|
-
|
|
84
84
|
difference = self.end_date - self.start_date
|
|
85
85
|
total_minutes = 0
|
|
86
86
|
|
|
@@ -127,7 +127,10 @@ class CCXTOHLCVBacktestMarketDataSource(
|
|
|
127
127
|
)
|
|
128
128
|
|
|
129
129
|
# Get the OHLCV data from the ccxt market service
|
|
130
|
-
market_service = CCXTMarketService(
|
|
130
|
+
market_service = CCXTMarketService(
|
|
131
|
+
market_credential_service=self.market_credential_service,
|
|
132
|
+
)
|
|
133
|
+
market_service.config = config
|
|
131
134
|
ohlcv = market_service.get_ohlcv(
|
|
132
135
|
symbol=self.symbol,
|
|
133
136
|
time_frame=self.timeframe,
|
|
@@ -171,6 +174,7 @@ class CCXTOHLCVBacktestMarketDataSource(
|
|
|
171
174
|
from_timestamp = backtest_index_date - timedelta(
|
|
172
175
|
minutes=self.total_minutes_timeframe
|
|
173
176
|
)
|
|
177
|
+
datetime_format = self._config["DATETIME_FORMAT"]
|
|
174
178
|
self.backtest_data_index_date = backtest_index_date\
|
|
175
179
|
.replace(microsecond=0)
|
|
176
180
|
from_timestamp = from_timestamp.replace(microsecond=0)
|
|
@@ -193,8 +197,8 @@ class CCXTOHLCVBacktestMarketDataSource(
|
|
|
193
197
|
file_path, columns=self.column_names, separator=","
|
|
194
198
|
)
|
|
195
199
|
df = df.filter(
|
|
196
|
-
(df['Datetime'] >= from_timestamp.strftime(
|
|
197
|
-
& (df['Datetime'] <= to_timestamp.strftime(
|
|
200
|
+
(df['Datetime'] >= from_timestamp.strftime(datetime_format))
|
|
201
|
+
& (df['Datetime'] <= to_timestamp.strftime(datetime_format))
|
|
198
202
|
)
|
|
199
203
|
return df
|
|
200
204
|
|
|
@@ -209,6 +213,9 @@ class CCXTOHLCVBacktestMarketDataSource(
|
|
|
209
213
|
def file_name(self):
|
|
210
214
|
return self._create_file_path().split("/")[-1]
|
|
211
215
|
|
|
216
|
+
def write_data_to_file_path(self, data_file, data: polars.DataFrame):
|
|
217
|
+
data.write_csv(data_file)
|
|
218
|
+
|
|
212
219
|
|
|
213
220
|
class CCXTTickerBacktestMarketDataSource(
|
|
214
221
|
TickerMarketDataSource, BacktestMarketDataSource
|
|
@@ -304,7 +311,10 @@ class CCXTTickerBacktestMarketDataSource(
|
|
|
304
311
|
)
|
|
305
312
|
|
|
306
313
|
# Get the OHLCV data from the ccxt market service
|
|
307
|
-
market_service = CCXTMarketService(
|
|
314
|
+
market_service = CCXTMarketService(
|
|
315
|
+
market_credential_service=self.market_credential_service
|
|
316
|
+
)
|
|
317
|
+
market_service.config = config
|
|
308
318
|
ohlcv = market_service.get_ohlcv(
|
|
309
319
|
symbol=self.symbol,
|
|
310
320
|
time_frame=self.timeframe,
|
|
@@ -363,13 +373,12 @@ class CCXTTickerBacktestMarketDataSource(
|
|
|
363
373
|
# Filter the data based on the backtest index date and the end date
|
|
364
374
|
df = polars.read_csv(file_path)
|
|
365
375
|
df = df.filter(
|
|
366
|
-
(df['Datetime'] >= backtest_index_date
|
|
367
|
-
.strftime(DATETIME_FORMAT))
|
|
376
|
+
(df['Datetime'] >= backtest_index_date.strftime(DATETIME_FORMAT))
|
|
368
377
|
)
|
|
369
|
-
|
|
370
378
|
first_row = df.head(1)[0]
|
|
379
|
+
first_row_datetime = parser.parse(first_row["Datetime"][0])
|
|
371
380
|
|
|
372
|
-
if
|
|
381
|
+
if first_row_datetime > end_date:
|
|
373
382
|
logger.warning(
|
|
374
383
|
f"No ticker data available for the given backtest "
|
|
375
384
|
f"index date {backtest_index_date} and symbol {self.symbol} "
|
|
@@ -386,12 +395,17 @@ class CCXTTickerBacktestMarketDataSource(
|
|
|
386
395
|
"datetime": first_row["Datetime"][0],
|
|
387
396
|
}
|
|
388
397
|
|
|
398
|
+
def write_data_to_file_path(self, data_file, data: polars.DataFrame):
|
|
399
|
+
data.write_csv(data_file)
|
|
400
|
+
|
|
389
401
|
|
|
390
402
|
class CCXTOHLCVMarketDataSource(OHLCVMarketDataSource):
|
|
391
403
|
|
|
392
404
|
def get_data(self, **kwargs):
|
|
393
|
-
market_service = CCXTMarketService(
|
|
394
|
-
|
|
405
|
+
market_service = CCXTMarketService(
|
|
406
|
+
market_credential_service=self.market_credential_service,
|
|
407
|
+
)
|
|
408
|
+
market_service.config = self.config
|
|
395
409
|
if self.start_date is None:
|
|
396
410
|
raise OperationalException(
|
|
397
411
|
"Either start_date or start_date_func should be set "
|
|
@@ -422,7 +436,10 @@ class CCXTOHLCVMarketDataSource(OHLCVMarketDataSource):
|
|
|
422
436
|
class CCXTOrderBookMarketDataSource(OrderBookMarketDataSource):
|
|
423
437
|
|
|
424
438
|
def get_data(self, **kwargs):
|
|
425
|
-
market_service = CCXTMarketService(
|
|
439
|
+
market_service = CCXTMarketService(
|
|
440
|
+
market_credential_service=self.market_credential_service
|
|
441
|
+
)
|
|
442
|
+
market_service.config = self.config
|
|
426
443
|
return market_service.get_order_book(
|
|
427
444
|
symbol=self.symbol, market=self.market
|
|
428
445
|
)
|
|
@@ -438,7 +455,8 @@ class CCXTTickerMarketDataSource(TickerMarketDataSource):
|
|
|
438
455
|
identifier,
|
|
439
456
|
market,
|
|
440
457
|
symbol=None,
|
|
441
|
-
backtest_timeframe=None
|
|
458
|
+
backtest_timeframe=None,
|
|
459
|
+
|
|
442
460
|
):
|
|
443
461
|
super().__init__(
|
|
444
462
|
identifier=identifier,
|
|
@@ -448,7 +466,10 @@ class CCXTTickerMarketDataSource(TickerMarketDataSource):
|
|
|
448
466
|
self._backtest_timeframe = backtest_timeframe
|
|
449
467
|
|
|
450
468
|
def get_data(self, **kwargs):
|
|
451
|
-
market_service = CCXTMarketService(
|
|
469
|
+
market_service = CCXTMarketService(
|
|
470
|
+
market_credential_service=self.market_credential_service
|
|
471
|
+
)
|
|
472
|
+
market_service.config = self.config
|
|
452
473
|
|
|
453
474
|
if self.market is None:
|
|
454
475
|
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import logging
|
|
2
|
-
from typing import Dict
|
|
3
2
|
from datetime import datetime
|
|
4
3
|
from time import sleep
|
|
5
|
-
|
|
4
|
+
from typing import Dict
|
|
5
|
+
|
|
6
6
|
import ccxt
|
|
7
|
+
import polars as pl
|
|
7
8
|
from dateutil import parser
|
|
8
|
-
from dateutil.tz import gettz
|
|
9
9
|
|
|
10
10
|
from investing_algorithm_framework.domain import OperationalException, Order, \
|
|
11
|
-
|
|
11
|
+
MarketService
|
|
12
12
|
|
|
13
13
|
logger = logging.getLogger(__name__)
|
|
14
14
|
|
|
@@ -20,6 +20,19 @@ class CCXTMarketService(MarketService):
|
|
|
20
20
|
msec = 1000
|
|
21
21
|
minute = 60 * msec
|
|
22
22
|
|
|
23
|
+
def __init__(self, market_credential_service):
|
|
24
|
+
super(CCXTMarketService, self).__init__(
|
|
25
|
+
market_credential_service=market_credential_service,
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
@property
|
|
29
|
+
def config(self):
|
|
30
|
+
return self._config
|
|
31
|
+
|
|
32
|
+
@config.setter
|
|
33
|
+
def config(self, config):
|
|
34
|
+
self._config = config
|
|
35
|
+
|
|
23
36
|
def initialize_exchange(self, market, market_credential):
|
|
24
37
|
market = market.lower()
|
|
25
38
|
if not hasattr(ccxt, market):
|
|
@@ -149,6 +162,7 @@ class CCXTMarketService(MarketService):
|
|
|
149
162
|
def get_orders(self, symbol, market, since: datetime = None):
|
|
150
163
|
market_credential = self.get_market_credential(market)
|
|
151
164
|
exchange = self.initialize_exchange(market, market_credential)
|
|
165
|
+
datetime_format = self.config["DATETIME_FORMAT"]
|
|
152
166
|
|
|
153
167
|
if not exchange.has['fetchOrders']:
|
|
154
168
|
raise OperationalException(
|
|
@@ -157,7 +171,7 @@ class CCXTMarketService(MarketService):
|
|
|
157
171
|
)
|
|
158
172
|
|
|
159
173
|
if since is not None:
|
|
160
|
-
since = exchange.parse8601(
|
|
174
|
+
since = exchange.parse8601(datetime_format)
|
|
161
175
|
|
|
162
176
|
try:
|
|
163
177
|
ccxt_orders = exchange.fetchOrders(symbol, since=since)
|
|
@@ -343,6 +357,7 @@ class CCXTMarketService(MarketService):
|
|
|
343
357
|
def get_ohlcv(
|
|
344
358
|
self, symbol, time_frame, from_timestamp, market, to_timestamp=None
|
|
345
359
|
) -> pl.DataFrame:
|
|
360
|
+
datetime_format = self.config["DATETIME_FORMAT"]
|
|
346
361
|
market_credential = self.get_market_credential(market)
|
|
347
362
|
exchange = self.initialize_exchange(market, market_credential)
|
|
348
363
|
|
|
@@ -353,14 +368,14 @@ class CCXTMarketService(MarketService):
|
|
|
353
368
|
)
|
|
354
369
|
|
|
355
370
|
from_time_stamp = exchange.parse8601(
|
|
356
|
-
from_timestamp.strftime(
|
|
371
|
+
from_timestamp.strftime(datetime_format)
|
|
357
372
|
)
|
|
358
373
|
|
|
359
374
|
if to_timestamp is None:
|
|
360
375
|
to_timestamp = exchange.milliseconds()
|
|
361
376
|
else:
|
|
362
377
|
to_timestamp = exchange.parse8601(
|
|
363
|
-
to_timestamp.strftime(
|
|
378
|
+
to_timestamp.strftime(datetime_format)
|
|
364
379
|
)
|
|
365
380
|
data = []
|
|
366
381
|
|
|
@@ -374,17 +389,16 @@ class CCXTMarketService(MarketService):
|
|
|
374
389
|
from_time_stamp = to_timestamp
|
|
375
390
|
|
|
376
391
|
for candle in ohlcv:
|
|
377
|
-
datetime_stamp = parser.parse(
|
|
378
|
-
exchange.iso8601(candle[0]),
|
|
379
|
-
tzinfos={"UTC": gettz("UTC")}
|
|
392
|
+
datetime_stamp = parser.parse(exchange.iso8601(candle[0]))
|
|
380
393
|
|
|
381
|
-
)
|
|
382
394
|
to_timestamp_datetime = parser.parse(
|
|
383
395
|
exchange.iso8601(to_timestamp),
|
|
384
|
-
tzinfos={"UTC": gettz("UTC")}
|
|
385
396
|
)
|
|
386
397
|
|
|
387
398
|
if datetime_stamp <= to_timestamp_datetime:
|
|
399
|
+
datetime_stamp = datetime_stamp\
|
|
400
|
+
.strftime(datetime_format)
|
|
401
|
+
|
|
388
402
|
data.append([datetime_stamp] + candle[1:])
|
|
389
403
|
|
|
390
404
|
sleep(exchange.rateLimit / 1000)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from datetime import datetime, timedelta
|
|
2
|
-
|
|
2
|
+
from dateutil import parser
|
|
3
3
|
import pandas as pd
|
|
4
4
|
from tqdm import tqdm
|
|
5
5
|
|
|
@@ -22,6 +22,7 @@ class BacktestService:
|
|
|
22
22
|
portfolio_repository,
|
|
23
23
|
position_repository,
|
|
24
24
|
performance_service,
|
|
25
|
+
configuration_service
|
|
25
26
|
):
|
|
26
27
|
self._resource_directory = None
|
|
27
28
|
self._order_service = order_service
|
|
@@ -35,6 +36,7 @@ class BacktestService:
|
|
|
35
36
|
self._market_data_source_service: MarketDataSourceService \
|
|
36
37
|
= market_data_source_service
|
|
37
38
|
self._backtest_market_data_sources = []
|
|
39
|
+
self._configuration_service = configuration_service
|
|
38
40
|
|
|
39
41
|
@property
|
|
40
42
|
def resource_directory(self):
|
|
@@ -96,10 +98,11 @@ class BacktestService:
|
|
|
96
98
|
strategy_profile = self.get_strategy_from_strategy_profiles(
|
|
97
99
|
strategy_profiles, row['id']
|
|
98
100
|
)
|
|
101
|
+
index_date = parser.parse(str(index))
|
|
99
102
|
self.run_backtest_for_profile(
|
|
100
103
|
algorithm=algorithm,
|
|
101
104
|
strategy=algorithm.get_strategy(strategy_profile.strategy_id),
|
|
102
|
-
index_date=
|
|
105
|
+
index_date=index_date,
|
|
103
106
|
)
|
|
104
107
|
return self.create_backtest_report(
|
|
105
108
|
algorithm, len(schedule), start_date, end_date, initial_unallocated
|
|
@@ -49,6 +49,7 @@ class BacktestMarketDataSourceService(MarketDataSourceService):
|
|
|
49
49
|
if backtest_market_data_source is not None:
|
|
50
50
|
backtest_market_data_source.market_credentials_service = \
|
|
51
51
|
self._market_credential_service
|
|
52
|
+
|
|
52
53
|
backtest_market_data_source.prepare_data(
|
|
53
54
|
config=configuration_service.get_config(),
|
|
54
55
|
backtest_start_date=configuration_service
|
|
@@ -161,9 +161,6 @@ class OrderBacktestService(OrderService):
|
|
|
161
161
|
order_side = order.get_order_side()
|
|
162
162
|
order_price = order.get_price()
|
|
163
163
|
|
|
164
|
-
# Convert 'created_at' to pandas Timestamp for easier comparison
|
|
165
|
-
created_at = pd.Timestamp(created_at, tz='UTC')
|
|
166
|
-
|
|
167
164
|
# Filter OHLCV data after the order creation time
|
|
168
165
|
ohlcv_data_after_order = ohlcv_data_frame.loc[created_at:]
|
|
169
166
|
|
|
@@ -15,6 +15,7 @@ class OrderService(RepositoryService):
|
|
|
15
15
|
|
|
16
16
|
def __init__(
|
|
17
17
|
self,
|
|
18
|
+
configuration_service,
|
|
18
19
|
order_repository,
|
|
19
20
|
order_fee_repository,
|
|
20
21
|
market_service: MarketService,
|
|
@@ -25,6 +26,7 @@ class OrderService(RepositoryService):
|
|
|
25
26
|
market_credential_service
|
|
26
27
|
):
|
|
27
28
|
super(OrderService, self).__init__(order_repository)
|
|
29
|
+
self.configuration_service = configuration_service
|
|
28
30
|
self.order_repository = order_repository
|
|
29
31
|
self.order_fee_repository = order_fee_repository
|
|
30
32
|
self.market_service: MarketService = market_service
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|