investing-algorithm-framework 3.2.0__tar.gz → 3.3.0__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.2.0 → investing_algorithm_framework-3.3.0}/PKG-INFO +16 -16
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/README.md +15 -15
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/models/trade/trade.py +44 -9
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/infrastructure/models/market_data_sources/csv.py +46 -53
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/services/trade_service/trade_service.py +13 -15
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/pyproject.toml +1 -1
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/LICENSE +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/__init__.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/app/__init__.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/app/algorithm.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/app/app.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/app/stateless/__init__.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/app/stateless/action_handlers/__init__.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/app/stateless/action_handlers/action_handler_strategy.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/app/stateless/action_handlers/check_online_handler.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/app/stateless/action_handlers/run_strategy_handler.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/app/stateless/exception_handler.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/app/strategy.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/app/task.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/app/web/__init__.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/app/web/controllers/__init__.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/app/web/controllers/orders.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/app/web/controllers/portfolio.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/app/web/controllers/positions.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/app/web/create_app.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/app/web/error_handler.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/app/web/responses.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/app/web/run_strategies.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/app/web/schemas/__init__.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/app/web/schemas/order.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/app/web/schemas/portfolio.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/app/web/schemas/position.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/app/web/setup_cors.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/create_app.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/dependency_container.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/__init__.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/config.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/constants.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/data_structures.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/decimal_parsing.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/exceptions.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/models/__init__.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/models/app_mode.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/models/backtesting/__init__.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/models/backtesting/backtest_position.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/models/backtesting/backtest_report.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/models/backtesting/backtest_reports_evaluation.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/models/base_model.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/models/market/__init__.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/models/market/market_credential.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/models/order/__init__.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/models/order/order.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/models/order/order_fee.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/models/order/order_side.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/models/order/order_status.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/models/order/order_type.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/models/portfolio/__init__.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/models/portfolio/portfolio.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/models/portfolio/portfolio_configuration.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/models/portfolio/portfolio_snapshot.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/models/position/__init__.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/models/position/position.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/models/position/position_snapshot.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/models/strategy_profile.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/models/time_frame.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/models/time_interval.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/models/time_unit.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/models/trade/__init__.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/models/trade/trade_status.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/models/trading_data_types.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/models/trading_time_frame.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/services/__init__.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/services/market_credential_service.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/services/market_data_sources.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/services/market_service.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/services/portfolios/__init__.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/services/portfolios/portfolio_sync_service.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/singleton.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/stateless_actions.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/strategy.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/utils/__init__.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/utils/backtesting.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/utils/csv.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/utils/random.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/utils/signatures.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/utils/stoppable_thread.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/domain/utils/synchronized.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/infrastructure/__init__.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/infrastructure/database/__init__.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/infrastructure/database/sql_alchemy.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/infrastructure/models/__init__.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/infrastructure/models/decimal_parser.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/infrastructure/models/market_data_sources/__init__.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/infrastructure/models/market_data_sources/ccxt.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/infrastructure/models/model_extension.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/infrastructure/models/order/__init__.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/infrastructure/models/order/order.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/infrastructure/models/order/order_fee.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/infrastructure/models/portfolio/__init__.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/infrastructure/models/portfolio/portfolio.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/infrastructure/models/portfolio/portfolio_snapshot.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/infrastructure/models/position/__init__.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/infrastructure/models/position/position.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/infrastructure/models/position/position_snapshot.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/infrastructure/repositories/__init__.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/infrastructure/repositories/order_fee_repository.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/infrastructure/repositories/order_repository.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/infrastructure/repositories/portfolio_repository.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/infrastructure/repositories/portfolio_snapshot_repository.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/infrastructure/repositories/position_repository.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/infrastructure/repositories/position_snapshot_repository.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/infrastructure/repositories/repository.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/infrastructure/services/__init__.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/infrastructure/services/market_service/__init__.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/infrastructure/services/market_service/ccxt_market_service.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/infrastructure/services/performance_service/__init__.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/infrastructure/services/performance_service/backtest_performance_service.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/infrastructure/services/performance_service/performance_service.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/services/__init__.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/services/backtesting/__init__.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/services/backtesting/backtest_report_writer_service.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/services/backtesting/backtest_service.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/services/configuration_service.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/services/market_credential_service.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/services/market_data_source_service/__init__.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/services/market_data_source_service/backtest_market_data_source_service.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/services/market_data_source_service/market_data_source_service.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/services/order_service/__init__.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/services/order_service/order_backtest_service.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/services/order_service/order_service.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/services/portfolios/__init__.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/services/portfolios/backtest_portfolio_service.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/services/portfolios/portfolio_configuration_service.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/services/portfolios/portfolio_service.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/services/portfolios/portfolio_snapshot_service.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/services/portfolios/portfolio_sync_service.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/services/position_service.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/services/position_snapshot_service.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/services/repository_service.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/services/strategy_orchestrator_service.py +0 -0
- {investing_algorithm_framework-3.2.0 → investing_algorithm_framework-3.3.0}/investing_algorithm_framework/services/trade_service/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: investing-algorithm-framework
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.3.0
|
|
4
4
|
Summary: A framework for creating trading bots
|
|
5
5
|
Author: MDUYN
|
|
6
6
|
Requires-Python: >=3.8.1,<4.0.0
|
|
@@ -174,20 +174,20 @@ you will get the following backtesting report:
|
|
|
174
174
|
====================Portfolio overview============================
|
|
175
175
|
* Number of orders: 10
|
|
176
176
|
* Initial balance: 400.0000 EUR
|
|
177
|
-
* Final balance:
|
|
178
|
-
* Total net gain:
|
|
179
|
-
* Total net gain percentage:
|
|
180
|
-
* Growth rate:
|
|
181
|
-
* Growth
|
|
177
|
+
* Final balance: 431.8837 EUR
|
|
178
|
+
* Total net gain: 28.4171 EUR
|
|
179
|
+
* Total net gain percentage: 7.1043%
|
|
180
|
+
* Growth rate: 7.9709%
|
|
181
|
+
* Growth 31.8837 EUR
|
|
182
182
|
====================Positions overview========================
|
|
183
183
|
╭────────────┬──────────┬──────────────────────┬───────────────────────┬──────────────┬───────────────┬───────────────────────────┬────────────────┬───────────────╮
|
|
184
184
|
│ Position │ Amount │ Pending buy amount │ Pending sell amount │ Cost (EUR) │ Value (EUR) │ Percentage of portfolio │ Growth (EUR) │ Growth_rate │
|
|
185
185
|
├────────────┼──────────┼──────────────────────┼───────────────────────┼──────────────┼───────────────┼───────────────────────────┼────────────────┼───────────────┤
|
|
186
|
-
│ EUR │
|
|
186
|
+
│ EUR │ 214.219 │ 0 │ 0 │ 214.219 │ 214.219 │ 49.6010% │ 0 │ 0.0000% │
|
|
187
187
|
├────────────┼──────────┼──────────────────────┼───────────────────────┼──────────────┼───────────────┼───────────────────────────┼────────────────┼───────────────┤
|
|
188
|
-
│ BTC │ 0.
|
|
188
|
+
│ BTC │ 0.0031 │ 0 │ 0 │ 107.095 │ 110.401 │ 25.5627% │ 3.3066 │ 3.0875% │
|
|
189
189
|
├────────────┼──────────┼──────────────────────┼───────────────────────┼──────────────┼───────────────┼───────────────────────────┼────────────────┼───────────────┤
|
|
190
|
-
│ DOT │ 21.
|
|
190
|
+
│ DOT │ 21.3291 │ 0 │ 0 │ 107.104 │ 107.264 │ 24.8363% │ 0.16 │ 0.1494% │
|
|
191
191
|
╰────────────┴──────────┴──────────────────────┴───────────────────────┴──────────────┴───────────────┴───────────────────────────┴────────────────┴───────────────╯
|
|
192
192
|
====================Trades overview===========================
|
|
193
193
|
* Number of trades closed: 4
|
|
@@ -195,21 +195,21 @@ you will get the following backtesting report:
|
|
|
195
195
|
* Percentage of positive trades: 60.0%
|
|
196
196
|
* Percentage of negative trades: 20.0%
|
|
197
197
|
* Average trade size: 98.8728 EUR
|
|
198
|
-
* Average trade duration:
|
|
198
|
+
* Average trade duration: 183.5 hours
|
|
199
199
|
╭─────────┬─────────────────────┬─────────────────────┬────────────────────┬──────────────┬──────────────────┬───────────────────────┬────────────────────┬─────────────────────╮
|
|
200
200
|
│ Pair │ Open date │ Close date │ Duration (hours) │ Size (EUR) │ Net gain (EUR) │ Net gain percentage │ Open price (EUR) │ Close price (EUR) │
|
|
201
201
|
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
|
|
202
|
-
│ DOT-EUR │ 2023-11-30 20:00:00 │ │
|
|
202
|
+
│ DOT-EUR │ 2023-11-30 20:00:00 │ │ 2976.65 │ 107.104 │ 0 │ 0.0000% │ 5.0215 │ │
|
|
203
203
|
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
|
|
204
|
-
│ BTC-EUR │ 2023-11-29 14:00:00 │ │
|
|
204
|
+
│ BTC-EUR │ 2023-11-29 14:00:00 │ │ 3006.65 │ 107.095 │ 0 │ 0.0000% │ 34546.6 │ │
|
|
205
205
|
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
|
|
206
|
-
│ BTC-EUR │ 2023-11-08 00:00:00 │ 2023-11-14 16:00:00 │ 160 │ 99.2265 │ 1.3352 │ 1.3456% │ 33075.5 │
|
|
206
|
+
│ BTC-EUR │ 2023-11-08 00:00:00 │ 2023-11-14 16:00:00 │ 160 │ 99.2265 │ 1.3352 │ 1.3456% │ 33075.5 │ 33520.6 │
|
|
207
207
|
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
|
|
208
|
-
│ BTC-EUR │ 2023-11-06 16:00:00 │ 2023-11-06 20:00:00 │ 4 │ 97.8607 │ -0.0026 │ -0.0026% │ 32620.2 │
|
|
208
|
+
│ BTC-EUR │ 2023-11-06 16:00:00 │ 2023-11-06 20:00:00 │ 4 │ 97.8607 │ -0.0026 │ -0.0026% │ 32620.2 │ 32619.4 │
|
|
209
209
|
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
|
|
210
|
-
│ DOT-EUR │ 2023-10-30 06:00:00 │ 2023-11-
|
|
210
|
+
│ DOT-EUR │ 2023-10-30 06:00:00 │ 2023-11-14 00:00:00 │ 354 │ 100.551 │ 24.8794 │ 24.7430% │ 4.0375 │ 5.0365 │
|
|
211
211
|
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
|
|
212
|
-
│ BTC-EUR │ 2023-09-13 16:00:00 │ 2023-09-22 16:00:00 │ 216 │ 97.8529 │ 2.2051 │ 2.2534% │ 24463.2 │
|
|
212
|
+
│ BTC-EUR │ 2023-09-13 16:00:00 │ 2023-09-22 16:00:00 │ 216 │ 97.8529 │ 2.2051 │ 2.2534% │ 24463.2 │ 25014.5 │
|
|
213
213
|
╰─────────┴─────────────────────┴─────────────────────┴────────────────────┴──────────────┴──────────────────┴───────────────────────┴────────────────────┴─────────────────────╯
|
|
214
214
|
==================================================================
|
|
215
215
|
```
|
|
@@ -147,20 +147,20 @@ you will get the following backtesting report:
|
|
|
147
147
|
====================Portfolio overview============================
|
|
148
148
|
* Number of orders: 10
|
|
149
149
|
* Initial balance: 400.0000 EUR
|
|
150
|
-
* Final balance:
|
|
151
|
-
* Total net gain:
|
|
152
|
-
* Total net gain percentage:
|
|
153
|
-
* Growth rate:
|
|
154
|
-
* Growth
|
|
150
|
+
* Final balance: 431.8837 EUR
|
|
151
|
+
* Total net gain: 28.4171 EUR
|
|
152
|
+
* Total net gain percentage: 7.1043%
|
|
153
|
+
* Growth rate: 7.9709%
|
|
154
|
+
* Growth 31.8837 EUR
|
|
155
155
|
====================Positions overview========================
|
|
156
156
|
╭────────────┬──────────┬──────────────────────┬───────────────────────┬──────────────┬───────────────┬───────────────────────────┬────────────────┬───────────────╮
|
|
157
157
|
│ Position │ Amount │ Pending buy amount │ Pending sell amount │ Cost (EUR) │ Value (EUR) │ Percentage of portfolio │ Growth (EUR) │ Growth_rate │
|
|
158
158
|
├────────────┼──────────┼──────────────────────┼───────────────────────┼──────────────┼───────────────┼───────────────────────────┼────────────────┼───────────────┤
|
|
159
|
-
│ EUR │
|
|
159
|
+
│ EUR │ 214.219 │ 0 │ 0 │ 214.219 │ 214.219 │ 49.6010% │ 0 │ 0.0000% │
|
|
160
160
|
├────────────┼──────────┼──────────────────────┼───────────────────────┼──────────────┼───────────────┼───────────────────────────┼────────────────┼───────────────┤
|
|
161
|
-
│ BTC │ 0.
|
|
161
|
+
│ BTC │ 0.0031 │ 0 │ 0 │ 107.095 │ 110.401 │ 25.5627% │ 3.3066 │ 3.0875% │
|
|
162
162
|
├────────────┼──────────┼──────────────────────┼───────────────────────┼──────────────┼───────────────┼───────────────────────────┼────────────────┼───────────────┤
|
|
163
|
-
│ DOT │ 21.
|
|
163
|
+
│ DOT │ 21.3291 │ 0 │ 0 │ 107.104 │ 107.264 │ 24.8363% │ 0.16 │ 0.1494% │
|
|
164
164
|
╰────────────┴──────────┴──────────────────────┴───────────────────────┴──────────────┴───────────────┴───────────────────────────┴────────────────┴───────────────╯
|
|
165
165
|
====================Trades overview===========================
|
|
166
166
|
* Number of trades closed: 4
|
|
@@ -168,21 +168,21 @@ you will get the following backtesting report:
|
|
|
168
168
|
* Percentage of positive trades: 60.0%
|
|
169
169
|
* Percentage of negative trades: 20.0%
|
|
170
170
|
* Average trade size: 98.8728 EUR
|
|
171
|
-
* Average trade duration:
|
|
171
|
+
* Average trade duration: 183.5 hours
|
|
172
172
|
╭─────────┬─────────────────────┬─────────────────────┬────────────────────┬──────────────┬──────────────────┬───────────────────────┬────────────────────┬─────────────────────╮
|
|
173
173
|
│ Pair │ Open date │ Close date │ Duration (hours) │ Size (EUR) │ Net gain (EUR) │ Net gain percentage │ Open price (EUR) │ Close price (EUR) │
|
|
174
174
|
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
|
|
175
|
-
│ DOT-EUR │ 2023-11-30 20:00:00 │ │
|
|
175
|
+
│ DOT-EUR │ 2023-11-30 20:00:00 │ │ 2976.65 │ 107.104 │ 0 │ 0.0000% │ 5.0215 │ │
|
|
176
176
|
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
|
|
177
|
-
│ BTC-EUR │ 2023-11-29 14:00:00 │ │
|
|
177
|
+
│ BTC-EUR │ 2023-11-29 14:00:00 │ │ 3006.65 │ 107.095 │ 0 │ 0.0000% │ 34546.6 │ │
|
|
178
178
|
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
|
|
179
|
-
│ BTC-EUR │ 2023-11-08 00:00:00 │ 2023-11-14 16:00:00 │ 160 │ 99.2265 │ 1.3352 │ 1.3456% │ 33075.5 │
|
|
179
|
+
│ BTC-EUR │ 2023-11-08 00:00:00 │ 2023-11-14 16:00:00 │ 160 │ 99.2265 │ 1.3352 │ 1.3456% │ 33075.5 │ 33520.6 │
|
|
180
180
|
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
|
|
181
|
-
│ BTC-EUR │ 2023-11-06 16:00:00 │ 2023-11-06 20:00:00 │ 4 │ 97.8607 │ -0.0026 │ -0.0026% │ 32620.2 │
|
|
181
|
+
│ BTC-EUR │ 2023-11-06 16:00:00 │ 2023-11-06 20:00:00 │ 4 │ 97.8607 │ -0.0026 │ -0.0026% │ 32620.2 │ 32619.4 │
|
|
182
182
|
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
|
|
183
|
-
│ DOT-EUR │ 2023-10-30 06:00:00 │ 2023-11-
|
|
183
|
+
│ DOT-EUR │ 2023-10-30 06:00:00 │ 2023-11-14 00:00:00 │ 354 │ 100.551 │ 24.8794 │ 24.7430% │ 4.0375 │ 5.0365 │
|
|
184
184
|
├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
|
|
185
|
-
│ BTC-EUR │ 2023-09-13 16:00:00 │ 2023-09-22 16:00:00 │ 216 │ 97.8529 │ 2.2051 │ 2.2534% │ 24463.2 │
|
|
185
|
+
│ BTC-EUR │ 2023-09-13 16:00:00 │ 2023-09-22 16:00:00 │ 216 │ 97.8529 │ 2.2051 │ 2.2534% │ 24463.2 │ 25014.5 │
|
|
186
186
|
╰─────────┴─────────────────────┴─────────────────────┴────────────────────┴──────────────┴──────────────────┴───────────────────────┴────────────────────┴─────────────────────╯
|
|
187
187
|
==================================================================
|
|
188
188
|
```
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
from typing import List
|
|
2
|
+
from polars import DataFrame
|
|
3
|
+
import polars as pl
|
|
1
4
|
from datetime import datetime
|
|
2
5
|
from investing_algorithm_framework.domain.models.base_model import BaseModel
|
|
6
|
+
from investing_algorithm_framework.domain.exceptions import \
|
|
7
|
+
OperationalException
|
|
8
|
+
from investing_algorithm_framework.domain.constants import DATETIME_FORMAT
|
|
3
9
|
|
|
4
10
|
|
|
5
11
|
class Trade(BaseModel):
|
|
@@ -164,22 +170,51 @@ class Trade(BaseModel):
|
|
|
164
170
|
return self.absolute_change
|
|
165
171
|
|
|
166
172
|
def is_manual_stop_loss_trigger(
|
|
167
|
-
self,
|
|
173
|
+
self,
|
|
174
|
+
current_price,
|
|
175
|
+
stop_loss_percentage,
|
|
176
|
+
prices: List[float] = None,
|
|
177
|
+
ohlcv_df: DataFrame = None
|
|
168
178
|
):
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
179
|
+
"""
|
|
180
|
+
Function to check if the stop loss is triggered for a given trade.
|
|
181
|
+
|
|
182
|
+
You can use either the prices list or the ohlcv_df DataFrame to
|
|
183
|
+
calculate the stop loss. The dataframe needs to be a Polars
|
|
184
|
+
DataFrame with the following columns: "Datetime" and "Close".
|
|
185
|
+
|
|
186
|
+
You can use the default CCXTOHLCVMarketDataSource to get the ohlcv_df
|
|
187
|
+
DataFrame.
|
|
188
|
+
|
|
189
|
+
Stop loss is triggered when the current price is lower than the
|
|
190
|
+
calculated stop loss price. The stop loss price is calculated by
|
|
191
|
+
taking the highest price of the given range. If the highest price
|
|
192
|
+
is lower than the open price, the stop loss price is calculated by
|
|
193
|
+
taking the open price and subtracting the stop loss percentage.
|
|
194
|
+
If the highest price is higher than the open price, the stop loss
|
|
195
|
+
price is calculated by taking the open price and adding the stop
|
|
196
|
+
loss percentage.
|
|
197
|
+
"""
|
|
198
|
+
|
|
199
|
+
if prices is None and ohlcv_df is None:
|
|
200
|
+
raise OperationalException(
|
|
201
|
+
"Either prices or a polars ohlcv dataframe must be provided"
|
|
202
|
+
)
|
|
177
203
|
|
|
178
204
|
if current_price < self.open_price:
|
|
179
205
|
stop_loss_price = self.open_price * \
|
|
180
206
|
(1 - stop_loss_percentage / 100)
|
|
181
207
|
return current_price <= stop_loss_price
|
|
182
208
|
else:
|
|
209
|
+
# If dataframes are provided, we use the dataframe to calculate
|
|
210
|
+
# the stop loss price
|
|
211
|
+
if ohlcv_df is not None:
|
|
212
|
+
filtered_df = ohlcv_df.filter(
|
|
213
|
+
pl.col('Datetime') >= self.opened_at.strftime(
|
|
214
|
+
DATETIME_FORMAT
|
|
215
|
+
)
|
|
216
|
+
)
|
|
217
|
+
prices = filtered_df['Close'].to_numpy()
|
|
183
218
|
highest_price = max(prices)
|
|
184
219
|
stop_loss_price = highest_price * (1 - stop_loss_percentage / 100)
|
|
185
220
|
return current_price <= stop_loss_price
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
from datetime import datetime
|
|
2
|
+
import polars
|
|
3
|
+
import logging
|
|
2
4
|
|
|
3
|
-
import pandas as pd
|
|
4
5
|
from dateutil.parser import parse
|
|
5
6
|
|
|
6
7
|
from investing_algorithm_framework.domain import OHLCVMarketDataSource, \
|
|
7
|
-
BacktestMarketDataSource, OperationalException, TickerMarketDataSource
|
|
8
|
+
BacktestMarketDataSource, OperationalException, TickerMarketDataSource, \
|
|
9
|
+
DATETIME_FORMAT
|
|
10
|
+
|
|
11
|
+
logger = logging.getLogger(__name__)
|
|
8
12
|
|
|
9
13
|
|
|
10
14
|
class CSVOHLCVMarketDataSource(OHLCVMarketDataSource):
|
|
@@ -44,8 +48,9 @@ class CSVOHLCVMarketDataSource(OHLCVMarketDataSource):
|
|
|
44
48
|
self._columns = [
|
|
45
49
|
"Datetime", "Open", "High", "Low", "Close", "Volume"
|
|
46
50
|
]
|
|
47
|
-
df =
|
|
51
|
+
df = polars.read_csv(csv_file_path)
|
|
48
52
|
|
|
53
|
+
# Check if all column names are in the csv file
|
|
49
54
|
if not all(column in df.columns for column in self._columns):
|
|
50
55
|
# Identify missing columns
|
|
51
56
|
missing_columns = [column for column in self._columns if
|
|
@@ -56,10 +61,10 @@ class CSVOHLCVMarketDataSource(OHLCVMarketDataSource):
|
|
|
56
61
|
f"Missing columns: {missing_columns}"
|
|
57
62
|
)
|
|
58
63
|
|
|
59
|
-
first_row = df.
|
|
60
|
-
last_row = df.
|
|
61
|
-
self._start_date = parse(first_row[0])
|
|
62
|
-
self._end_date = parse(last_row[0])
|
|
64
|
+
first_row = df.head(1)
|
|
65
|
+
last_row = df.tail(1)
|
|
66
|
+
self._start_date = parse(first_row["Datetime"][0])
|
|
67
|
+
self._end_date = parse(last_row["Datetime"][0])
|
|
63
68
|
|
|
64
69
|
@property
|
|
65
70
|
def csv_file_path(self):
|
|
@@ -67,40 +72,25 @@ class CSVOHLCVMarketDataSource(OHLCVMarketDataSource):
|
|
|
67
72
|
|
|
68
73
|
def get_data(
|
|
69
74
|
self,
|
|
70
|
-
|
|
71
|
-
|
|
75
|
+
from_timestamp=None,
|
|
76
|
+
to_timestamp=None,
|
|
72
77
|
**kwargs
|
|
73
78
|
):
|
|
74
79
|
|
|
75
|
-
if
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
if to_time_stamp is None:
|
|
79
|
-
to_time_stamp = self.end_date
|
|
80
|
-
|
|
81
|
-
df = pd.read_csv(self._csv_file_path)
|
|
82
|
-
|
|
83
|
-
# Convert the 'Datetime' column to datetime type if
|
|
84
|
-
# it's not already
|
|
85
|
-
if 'Datetime' in df.columns and pd.api.types.is_string_dtype(
|
|
86
|
-
df['Datetime']):
|
|
87
|
-
df['Datetime'] = pd.to_datetime(df['Datetime'], utc=True)
|
|
88
|
-
|
|
89
|
-
# Filter rows based on the start and end dates
|
|
90
|
-
filtered_df = df[
|
|
91
|
-
(df['Datetime'] >= from_time_stamp)
|
|
92
|
-
& (df['Datetime'] <= to_time_stamp)
|
|
93
|
-
]
|
|
94
|
-
|
|
95
|
-
# Specify the columns you want in the inner lists
|
|
96
|
-
selected_columns = ["Datetime", "Open", "High", "Low", "Close",
|
|
97
|
-
"Volume"]
|
|
80
|
+
if from_timestamp is None:
|
|
81
|
+
from_timestamp = self.start_date
|
|
98
82
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
self.dataframe_to_list_of_lists(filtered_df, selected_columns)
|
|
83
|
+
if to_timestamp is None:
|
|
84
|
+
to_timestamp = self.end_date
|
|
102
85
|
|
|
103
|
-
|
|
86
|
+
df = polars.read_csv(
|
|
87
|
+
self.csv_file_path, columns=self._columns, separator=","
|
|
88
|
+
)
|
|
89
|
+
df = df.filter(
|
|
90
|
+
(df['Datetime'] >= from_timestamp.strftime(DATETIME_FORMAT))
|
|
91
|
+
& (df['Datetime'] <= to_timestamp.strftime(DATETIME_FORMAT))
|
|
92
|
+
)
|
|
93
|
+
return df
|
|
104
94
|
|
|
105
95
|
def dataframe_to_list_of_lists(self, dataframe, columns):
|
|
106
96
|
# Extract selected columns from DataFrame and convert
|
|
@@ -130,7 +120,7 @@ class CSVTickerMarketDataSource(TickerMarketDataSource):
|
|
|
130
120
|
self._columns = [
|
|
131
121
|
"Datetime", "Open", "High", "Low", "Close", "Volume"
|
|
132
122
|
]
|
|
133
|
-
df =
|
|
123
|
+
df = polars.read_csv(self._csv_file_path)
|
|
134
124
|
|
|
135
125
|
if not all(column in df.columns for column in self._columns):
|
|
136
126
|
# Identify missing columns
|
|
@@ -151,27 +141,30 @@ class CSVTickerMarketDataSource(TickerMarketDataSource):
|
|
|
151
141
|
if index_datetime is None:
|
|
152
142
|
index_datetime = datetime.utcnow()
|
|
153
143
|
|
|
154
|
-
|
|
155
|
-
df =
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
df['Datetime']):
|
|
161
|
-
df['Datetime'] = pd.to_datetime(df['Datetime'], utc=True)
|
|
144
|
+
# Filter the data based on the backtest index date and the end date
|
|
145
|
+
df = polars.read_csv(self._csv_file_path)
|
|
146
|
+
df = df.filter(
|
|
147
|
+
(df['Datetime'] >= index_datetime
|
|
148
|
+
.strftime(DATETIME_FORMAT))
|
|
149
|
+
)
|
|
162
150
|
|
|
163
|
-
#
|
|
164
|
-
|
|
151
|
+
# Check if the dataframe is empty
|
|
152
|
+
if df.shape[0] == 0:
|
|
153
|
+
raise OperationalException(
|
|
154
|
+
f"No ticker data found for {self.symbol} "
|
|
155
|
+
f"at {index_datetime}"
|
|
156
|
+
)
|
|
165
157
|
|
|
166
|
-
|
|
167
|
-
return None
|
|
158
|
+
first_row = df.head(1)[0]
|
|
168
159
|
|
|
169
|
-
|
|
160
|
+
# Calculate the bid and ask price based on the high and low price
|
|
170
161
|
return {
|
|
171
162
|
"symbol": self.symbol,
|
|
172
|
-
"bid":
|
|
173
|
-
|
|
174
|
-
"
|
|
163
|
+
"bid": float((first_row["Low"][0])
|
|
164
|
+
+ float(first_row["High"][0])) / 2,
|
|
165
|
+
"ask": float((first_row["Low"][0])
|
|
166
|
+
+ float(first_row["High"][0])) / 2,
|
|
167
|
+
"datetime": first_row["Datetime"][0],
|
|
175
168
|
}
|
|
176
169
|
|
|
177
170
|
def dataframe_to_list_of_lists(self, dataframe, columns):
|
|
@@ -98,22 +98,14 @@ class TradeService:
|
|
|
98
98
|
|
|
99
99
|
for buy_order in buy_orders_queue:
|
|
100
100
|
symbol = buy_order.get_symbol()
|
|
101
|
-
|
|
101
|
+
current_price = buy_order.get_price()
|
|
102
102
|
try:
|
|
103
103
|
ticker = self.market_data_source_service.get_ticker(
|
|
104
104
|
symbol=symbol, market=market
|
|
105
105
|
)
|
|
106
|
+
current_price = ticker["bid"]
|
|
106
107
|
except Exception as e:
|
|
107
108
|
logger.error(e)
|
|
108
|
-
raise OperationalException(
|
|
109
|
-
f"Error getting ticker data for "
|
|
110
|
-
f"trade {buy_order.get_target_symbol()}"
|
|
111
|
-
f"-{buy_order.get_trading_symbol()}. Make sure you "
|
|
112
|
-
f"have registered a ticker market data source for "
|
|
113
|
-
f"{buy_order.get_target_symbol()}"
|
|
114
|
-
f"-{buy_order.get_trading_symbol()} "
|
|
115
|
-
f"for market {portfolio.market}"
|
|
116
|
-
)
|
|
117
109
|
|
|
118
110
|
amount = buy_order.get_filled()
|
|
119
111
|
closed_amount = buy_order.get_trade_closed_amount()
|
|
@@ -129,7 +121,7 @@ class TradeService:
|
|
|
129
121
|
amount=amount,
|
|
130
122
|
open_price=buy_order.get_price(),
|
|
131
123
|
opened_at=buy_order.get_created_at(),
|
|
132
|
-
current_price=
|
|
124
|
+
current_price=current_price
|
|
133
125
|
)
|
|
134
126
|
)
|
|
135
127
|
|
|
@@ -156,9 +148,15 @@ class TradeService:
|
|
|
156
148
|
|
|
157
149
|
for buy_order in buy_orders:
|
|
158
150
|
symbol = buy_order.get_symbol()
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
151
|
+
current_price = buy_order.get_price()
|
|
152
|
+
try:
|
|
153
|
+
ticker = self.market_data_source_service.get_ticker(
|
|
154
|
+
symbol=symbol, market=market
|
|
155
|
+
)
|
|
156
|
+
current_price = ticker["bid"]
|
|
157
|
+
except Exception as e:
|
|
158
|
+
logger.error(e)
|
|
159
|
+
|
|
162
160
|
trades.append(
|
|
163
161
|
Trade(
|
|
164
162
|
buy_order_id=buy_order.id,
|
|
@@ -169,7 +167,7 @@ class TradeService:
|
|
|
169
167
|
closed_price=buy_order.get_trade_closed_price(),
|
|
170
168
|
closed_at=buy_order.get_trade_closed_at(),
|
|
171
169
|
opened_at=buy_order.get_created_at(),
|
|
172
|
-
current_price=
|
|
170
|
+
current_price=current_price
|
|
173
171
|
)
|
|
174
172
|
)
|
|
175
173
|
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|