investing-algorithm-framework 2.2__tar.gz → 2.2.2__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-2.2/investing_algorithm_framework.egg-info → investing_algorithm_framework-2.2.2}/PKG-INFO +1 -1
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/app/algorithm.py +16 -16
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/dependency_container.py +1 -1
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/domain/services/market_service.py +1 -4
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/services/market_data_source_service/market_data_source_service.py +53 -19
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2/investing_algorithm_framework.egg-info}/PKG-INFO +1 -1
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/AUTHORS.md +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/LICENSE +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/README.md +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/__init__.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/app/__init__.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/app/app.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/app/stateless/__init__.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/app/stateless/action_handlers/__init__.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/app/stateless/action_handlers/action_handler_strategy.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/app/stateless/action_handlers/check_online_handler.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/app/stateless/action_handlers/run_strategy_handler.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/app/stateless/exception_handler.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/app/strategy.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/app/task.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/app/web/__init__.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/app/web/controllers/__init__.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/app/web/controllers/orders.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/app/web/controllers/portfolio.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/app/web/controllers/positions.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/app/web/create_app.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/app/web/error_handler.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/app/web/responses.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/app/web/run_strategies.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/app/web/schemas/__init__.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/app/web/schemas/order.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/app/web/schemas/portfolio.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/app/web/schemas/position.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/app/web/setup_cors.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/create_app.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/domain/__init__.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/domain/config.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/domain/constants.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/domain/data_structures.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/domain/decimal_parsing.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/domain/exceptions.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/domain/models/__init__.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/domain/models/backtest_profile.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/domain/models/base_model.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/domain/models/market/__init__.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/domain/models/market/market_credential.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/domain/models/order/__init__.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/domain/models/order/order.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/domain/models/order/order_fee.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/domain/models/order/order_side.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/domain/models/order/order_status.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/domain/models/order/order_type.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/domain/models/portfolio/__init__.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/domain/models/portfolio/portfolio.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/domain/models/portfolio/portfolio_configuration.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/domain/models/portfolio/portfolio_snapshot.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/domain/models/position/__init__.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/domain/models/position/position.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/domain/models/position/position_snapshot.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/domain/models/strategy_profile.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/domain/models/time_frame.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/domain/models/time_interval.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/domain/models/time_unit.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/domain/models/trade.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/domain/models/trading_data_types.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/domain/models/trading_time_frame.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/domain/services/__init__.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/domain/services/market_data_sources.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/domain/singleton.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/domain/stateless_actions.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/domain/strategy.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/domain/utils/__init__.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/domain/utils/backtesting.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/domain/utils/csv.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/domain/utils/random.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/domain/utils/signatures.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/domain/utils/stoppable_thread.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/domain/utils/synchronized.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/infrastructure/__init__.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/infrastructure/database/__init__.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/infrastructure/database/sql_alchemy.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/infrastructure/models/__init__.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/infrastructure/models/decimal_parser.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/infrastructure/models/market_data_sources/__init__.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/infrastructure/models/market_data_sources/ccxt.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/infrastructure/models/market_data_sources/csv.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/infrastructure/models/model_extension.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/infrastructure/models/order/__init__.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/infrastructure/models/order/order.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/infrastructure/models/order/order_fee.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/infrastructure/models/portfolio/__init__.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/infrastructure/models/portfolio/portfolio.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/infrastructure/models/portfolio/portfolio_snapshot.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/infrastructure/models/position/__init__.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/infrastructure/models/position/position.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/infrastructure/models/position/position_snapshot.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/infrastructure/repositories/__init__.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/infrastructure/repositories/order_fee_repository.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/infrastructure/repositories/order_repository.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/infrastructure/repositories/portfolio_repository.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/infrastructure/repositories/portfolio_snapshot_repository.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/infrastructure/repositories/position_repository.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/infrastructure/repositories/position_snapshot_repository.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/infrastructure/repositories/repository.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/infrastructure/services/__init__.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/infrastructure/services/market_service/__init__.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/infrastructure/services/market_service/ccxt_market_service.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/infrastructure/services/performance_service/__init__.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/infrastructure/services/performance_service/backtest_performance_service.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/infrastructure/services/performance_service/performance_service.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/services/__init__.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/services/backtest_service.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/services/configuration_service.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/services/market_credential_service.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/services/market_data_source_service/__init__.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/services/market_data_source_service/backtest_market_data_source_service.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/services/order_service/__init__.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/services/order_service/order_backtest_service.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/services/order_service/order_service.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/services/portfolio_configuration_service.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/services/portfolio_service/__init__.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/services/portfolio_service/backtest_portfolio_service.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/services/portfolio_service/portfolio_service.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/services/portfolio_snapshot_service.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/services/position_service.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/services/position_snapshot_service.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/services/repository_service.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework/services/strategy_orchestrator_service.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework.egg-info/SOURCES.txt +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework.egg-info/dependency_links.txt +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework.egg-info/requires.txt +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/investing_algorithm_framework.egg-info/top_level.txt +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/setup.cfg +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/setup.py +0 -0
- {investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/tests/test_create_app.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: investing_algorithm_framework
|
|
3
|
-
Version: 2.2
|
|
3
|
+
Version: 2.2.2
|
|
4
4
|
Summary: A framework for creating an investment algorithm
|
|
5
5
|
Home-page: https://github.com/coding-kitties/investing-algorithm-framework.git
|
|
6
6
|
Download-URL: https://github.com/coding-kitties/investing-algorithm-framework/archive/v0.1.1.tar.gz
|
|
@@ -421,11 +421,9 @@ class Algorithm:
|
|
|
421
421
|
)
|
|
422
422
|
full_symbol = f"{position.symbol.upper()}/" \
|
|
423
423
|
f"{portfolio.trading_symbol.upper()}"
|
|
424
|
-
ticker = self.
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
.get(BACKTESTING_INDEX_DATETIME)
|
|
428
|
-
)
|
|
424
|
+
ticker = self._market_data_source_service.get_ticker(
|
|
425
|
+
symbol=full_symbol, market=market
|
|
426
|
+
)
|
|
429
427
|
total = self.get_unallocated() + self.get_allocated()
|
|
430
428
|
return (position.amount * ticker["bid"] / total) * 100
|
|
431
429
|
|
|
@@ -481,8 +479,9 @@ class Algorithm:
|
|
|
481
479
|
self.order_service.cancel_order(order)
|
|
482
480
|
|
|
483
481
|
symbol = f"{symbol.upper()}/{portfolio.trading_symbol.upper()}"
|
|
484
|
-
ticker = self._market_data_source_service
|
|
485
|
-
|
|
482
|
+
ticker = self._market_data_source_service.get_ticker(
|
|
483
|
+
symbol=symbol, market=market
|
|
484
|
+
)
|
|
486
485
|
self.create_limit_order(
|
|
487
486
|
target_symbol=position.symbol,
|
|
488
487
|
amount=position.get_amount(),
|
|
@@ -550,8 +549,8 @@ class Algorithm:
|
|
|
550
549
|
|
|
551
550
|
symbol = f"{position.symbol.upper()}/" \
|
|
552
551
|
f"{portfolio.trading_symbol.upper()}"
|
|
553
|
-
ticker = self.
|
|
554
|
-
|
|
552
|
+
ticker = self._market_data_source_service.get_ticker(
|
|
553
|
+
symbol=symbol, market=market,
|
|
555
554
|
).get_data(
|
|
556
555
|
backtest_index_date=self.config
|
|
557
556
|
.get(BACKTESTING_INDEX_DATETIME)
|
|
@@ -670,7 +669,7 @@ class Algorithm:
|
|
|
670
669
|
def check_pending_orders(self):
|
|
671
670
|
self.order_service.check_pending_orders()
|
|
672
671
|
|
|
673
|
-
def get_trades(self):
|
|
672
|
+
def get_trades(self, market=None):
|
|
674
673
|
portfolios = self.portfolio_service.get_all()
|
|
675
674
|
trades = []
|
|
676
675
|
|
|
@@ -684,7 +683,7 @@ class Algorithm:
|
|
|
684
683
|
for buy_order in buy_orders:
|
|
685
684
|
symbol = buy_order.get_symbol()
|
|
686
685
|
ticker = self._market_data_source_service.get_ticker(
|
|
687
|
-
symbol=symbol, market=
|
|
686
|
+
symbol=symbol, market=market
|
|
688
687
|
)
|
|
689
688
|
trades.append(
|
|
690
689
|
Trade(
|
|
@@ -738,7 +737,7 @@ class Algorithm:
|
|
|
738
737
|
else:
|
|
739
738
|
return 0
|
|
740
739
|
|
|
741
|
-
def get_open_trades(self, target_symbol=None):
|
|
740
|
+
def get_open_trades(self, target_symbol=None, market=None):
|
|
742
741
|
portfolios = self.portfolio_service.get_all()
|
|
743
742
|
trades = []
|
|
744
743
|
|
|
@@ -800,7 +799,7 @@ class Algorithm:
|
|
|
800
799
|
|
|
801
800
|
try:
|
|
802
801
|
ticker = self._market_data_source_service.get_ticker(
|
|
803
|
-
symbol=symbol, market=
|
|
802
|
+
symbol=symbol, market=market
|
|
804
803
|
)
|
|
805
804
|
except Exception as e:
|
|
806
805
|
logger.error(e)
|
|
@@ -828,7 +827,7 @@ class Algorithm:
|
|
|
828
827
|
|
|
829
828
|
return trades
|
|
830
829
|
|
|
831
|
-
def close_trade(self, trade):
|
|
830
|
+
def close_trade(self, trade, market):
|
|
832
831
|
|
|
833
832
|
if trade.closed_at is not None:
|
|
834
833
|
raise ApiException("Trade already closed.")
|
|
@@ -856,8 +855,9 @@ class Algorithm:
|
|
|
856
855
|
|
|
857
856
|
symbol = f"{order.get_target_symbol().upper()}" \
|
|
858
857
|
f"/{order.get_trading_symbol().upper()}"
|
|
859
|
-
ticker = self._market_data_source_service
|
|
860
|
-
|
|
858
|
+
ticker = self._market_data_source_service.get_ticker(
|
|
859
|
+
symbol=symbol, market=market
|
|
860
|
+
)
|
|
861
861
|
self.create_limit_order(
|
|
862
862
|
target_symbol=order.target_symbol,
|
|
863
863
|
amount=amount,
|
|
@@ -25,7 +25,7 @@ class DependencyContainer(containers.DeclarativeContainer):
|
|
|
25
25
|
ConfigurationService,
|
|
26
26
|
)
|
|
27
27
|
market_credential_service = providers.ThreadSafeSingleton(
|
|
28
|
-
MarketCredentialService
|
|
28
|
+
MarketCredentialService
|
|
29
29
|
)
|
|
30
30
|
order_repository = providers.Factory(SQLOrderRepository)
|
|
31
31
|
order_fee_repository = providers.Factory(SQLOrderFeeRepository)
|
|
@@ -7,10 +7,7 @@ logger = logging.getLogger("investing_algorithm_framework")
|
|
|
7
7
|
|
|
8
8
|
class MarketService(ABC):
|
|
9
9
|
|
|
10
|
-
def __init__(
|
|
11
|
-
self,
|
|
12
|
-
market_credential_service
|
|
13
|
-
):
|
|
10
|
+
def __init__(self, market_credential_service):
|
|
14
11
|
self._market_credential_service = market_credential_service
|
|
15
12
|
|
|
16
13
|
@abstractmethod
|
|
@@ -8,6 +8,15 @@ from investing_algorithm_framework.services.market_credential_service \
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
class MarketDataSourceService:
|
|
11
|
+
"""
|
|
12
|
+
This class is responsible for managing the market data sources.
|
|
13
|
+
|
|
14
|
+
It is used by the algorithm to get market data from different sources.
|
|
15
|
+
The MarketDataSourceService will first check if there is a market data
|
|
16
|
+
source that matches the symbol, market and time frame provided by the user.
|
|
17
|
+
If there is, it will use that market data source to get the data. If there
|
|
18
|
+
is not, it will use the MarketService to get the data.
|
|
19
|
+
"""
|
|
11
20
|
_market_data_sources: List[MarketDataSource] = []
|
|
12
21
|
|
|
13
22
|
def __init__(
|
|
@@ -25,7 +34,7 @@ class MarketDataSourceService:
|
|
|
25
34
|
self._market_credential_service: MarketCredentialService = \
|
|
26
35
|
market_credential_service
|
|
27
36
|
|
|
28
|
-
def get_ticker(self, symbol, market):
|
|
37
|
+
def get_ticker(self, symbol, market=None):
|
|
29
38
|
ticker_market_data_source = self.get_ticker_market_data_source(
|
|
30
39
|
symbol=symbol, market=market
|
|
31
40
|
)
|
|
@@ -37,7 +46,7 @@ class MarketDataSourceService:
|
|
|
37
46
|
|
|
38
47
|
return self._market_service.get_ticker(symbol, market)
|
|
39
48
|
|
|
40
|
-
def get_order_book(self, symbol, market):
|
|
49
|
+
def get_order_book(self, symbol, market=None):
|
|
41
50
|
order_book_market_data_source = self.get_order_book_market_data_source(
|
|
42
51
|
symbol=symbol, market=market
|
|
43
52
|
)
|
|
@@ -50,7 +59,12 @@ class MarketDataSourceService:
|
|
|
50
59
|
return self._market_service.get_order_book(symbol, market)
|
|
51
60
|
|
|
52
61
|
def get_ohlcv(
|
|
53
|
-
self,
|
|
62
|
+
self,
|
|
63
|
+
symbol,
|
|
64
|
+
time_frame,
|
|
65
|
+
from_timestamp,
|
|
66
|
+
market=None,
|
|
67
|
+
to_timestamp=None
|
|
54
68
|
):
|
|
55
69
|
ohlcv_market_data_source = self.get_ohlcv_market_data_source(
|
|
56
70
|
symbol=symbol, market=market, time_frame=time_frame
|
|
@@ -79,40 +93,60 @@ class MarketDataSourceService:
|
|
|
79
93
|
market_credential_service=self._market_credential_service
|
|
80
94
|
)
|
|
81
95
|
|
|
82
|
-
def get_ticker_market_data_source(self, symbol, market):
|
|
96
|
+
def get_ticker_market_data_source(self, symbol, market=None):
|
|
83
97
|
|
|
84
98
|
if self.market_data_sources is not None:
|
|
85
99
|
for market_data_source in self._market_data_sources:
|
|
86
100
|
if isinstance(market_data_source, TickerMarketDataSource):
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
101
|
+
|
|
102
|
+
if market is not None:
|
|
103
|
+
if market_data_source.market.lower() == market.lower()\
|
|
104
|
+
and market_data_source.symbol.lower() \
|
|
105
|
+
== symbol.lower():
|
|
106
|
+
return market_data_source
|
|
107
|
+
else:
|
|
108
|
+
if market_data_source.symbol.lower() \
|
|
109
|
+
== symbol.lower():
|
|
110
|
+
return market_data_source
|
|
91
111
|
|
|
92
112
|
return None
|
|
93
113
|
|
|
94
|
-
def get_ohlcv_market_data_source(self, symbol,
|
|
114
|
+
def get_ohlcv_market_data_source(self, symbol, time_frame, market=None):
|
|
95
115
|
|
|
96
116
|
if self.market_data_sources is not None:
|
|
97
117
|
for market_data_source in self._market_data_sources:
|
|
98
118
|
if isinstance(market_data_source, OHLCVMarketDataSource):
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
119
|
+
|
|
120
|
+
if market is not None:
|
|
121
|
+
|
|
122
|
+
if market_data_source.market.lower() == market.lower()\
|
|
123
|
+
and market_data_source.symbol.lower() \
|
|
124
|
+
== symbol.lower() and \
|
|
125
|
+
market_data_source.timeframe == time_frame:
|
|
126
|
+
return market_data_source
|
|
127
|
+
else:
|
|
128
|
+
if market_data_source.symbol.lower() \
|
|
129
|
+
== symbol.lower() and \
|
|
130
|
+
market_data_source.timeframe == time_frame:
|
|
131
|
+
return market_data_source
|
|
104
132
|
|
|
105
133
|
return None
|
|
106
134
|
|
|
107
|
-
def get_order_book_market_data_source(self, symbol, market):
|
|
135
|
+
def get_order_book_market_data_source(self, symbol, market=None):
|
|
108
136
|
|
|
109
137
|
if self.market_data_sources is not None:
|
|
110
138
|
for market_data_source in self._market_data_sources:
|
|
111
139
|
if isinstance(market_data_source, OrderBookMarketDataSource):
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
140
|
+
|
|
141
|
+
if market is not None:
|
|
142
|
+
if market_data_source.market.lower() == market.lower()\
|
|
143
|
+
and market_data_source.symbol.lower() \
|
|
144
|
+
== symbol.lower():
|
|
145
|
+
return market_data_source
|
|
146
|
+
else:
|
|
147
|
+
if market_data_source.symbol.lower() \
|
|
148
|
+
== symbol.lower():
|
|
149
|
+
return market_data_source
|
|
116
150
|
|
|
117
151
|
return None
|
|
118
152
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: investing_algorithm_framework
|
|
3
|
-
Version: 2.2
|
|
3
|
+
Version: 2.2.2
|
|
4
4
|
Summary: A framework for creating an investment algorithm
|
|
5
5
|
Home-page: https://github.com/coding-kitties/investing-algorithm-framework.git
|
|
6
6
|
Download-URL: https://github.com/coding-kitties/investing-algorithm-framework/archive/v0.1.1.tar.gz
|
|
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
|
{investing_algorithm_framework-2.2 → investing_algorithm_framework-2.2.2}/tests/test_create_app.py
RENAMED
|
File without changes
|