investing-algorithm-framework 3.3.1__tar.gz → 3.4.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.3.1 → investing_algorithm_framework-3.4.0}/PKG-INFO +1 -1
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/app/algorithm.py +11 -24
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/__init__.py +4 -2
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/services/__init__.py +3 -1
- investing_algorithm_framework-3.4.0/investing_algorithm_framework/domain/services/rounding_service.py +27 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/services/trade_service/trade_service.py +9 -5
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/pyproject.toml +1 -1
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/LICENSE +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/README.md +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/__init__.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/app/__init__.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/app/app.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/app/stateless/__init__.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/app/stateless/action_handlers/__init__.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/app/stateless/action_handlers/action_handler_strategy.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/app/stateless/action_handlers/check_online_handler.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/app/stateless/action_handlers/run_strategy_handler.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/app/stateless/exception_handler.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/app/strategy.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/app/task.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/app/web/__init__.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/app/web/controllers/__init__.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/app/web/controllers/orders.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/app/web/controllers/portfolio.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/app/web/controllers/positions.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/app/web/create_app.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/app/web/error_handler.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/app/web/responses.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/app/web/run_strategies.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/app/web/schemas/__init__.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/app/web/schemas/order.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/app/web/schemas/portfolio.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/app/web/schemas/position.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/app/web/setup_cors.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/create_app.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/dependency_container.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/config.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/constants.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/data_structures.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/decimal_parsing.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/exceptions.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/models/__init__.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/models/app_mode.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/models/backtesting/__init__.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/models/backtesting/backtest_position.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/models/backtesting/backtest_report.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/models/backtesting/backtest_reports_evaluation.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/models/base_model.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/models/market/__init__.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/models/market/market_credential.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/models/order/__init__.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/models/order/order.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/models/order/order_fee.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/models/order/order_side.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/models/order/order_status.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/models/order/order_type.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/models/portfolio/__init__.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/models/portfolio/portfolio.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/models/portfolio/portfolio_configuration.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/models/portfolio/portfolio_snapshot.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/models/position/__init__.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/models/position/position.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/models/position/position_snapshot.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/models/strategy_profile.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/models/time_frame.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/models/time_interval.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/models/time_unit.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/models/trade/__init__.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/models/trade/trade.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/models/trade/trade_status.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/models/trading_data_types.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/models/trading_time_frame.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/services/market_credential_service.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/services/market_data_sources.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/services/market_service.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/services/portfolios/__init__.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/services/portfolios/portfolio_sync_service.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/singleton.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/stateless_actions.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/strategy.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/utils/__init__.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/utils/backtesting.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/utils/csv.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/utils/random.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/utils/signatures.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/utils/stoppable_thread.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/domain/utils/synchronized.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/infrastructure/__init__.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/infrastructure/database/__init__.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/infrastructure/database/sql_alchemy.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/infrastructure/models/__init__.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/infrastructure/models/decimal_parser.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/infrastructure/models/market_data_sources/__init__.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/infrastructure/models/market_data_sources/ccxt.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/infrastructure/models/market_data_sources/csv.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/infrastructure/models/model_extension.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/infrastructure/models/order/__init__.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/infrastructure/models/order/order.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/infrastructure/models/order/order_fee.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/infrastructure/models/portfolio/__init__.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/infrastructure/models/portfolio/portfolio.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/infrastructure/models/portfolio/portfolio_snapshot.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/infrastructure/models/position/__init__.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/infrastructure/models/position/position.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/infrastructure/models/position/position_snapshot.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/infrastructure/repositories/__init__.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/infrastructure/repositories/order_fee_repository.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/infrastructure/repositories/order_repository.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/infrastructure/repositories/portfolio_repository.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/infrastructure/repositories/portfolio_snapshot_repository.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/infrastructure/repositories/position_repository.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/infrastructure/repositories/position_snapshot_repository.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/infrastructure/repositories/repository.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/infrastructure/services/__init__.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/infrastructure/services/market_service/__init__.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/infrastructure/services/market_service/ccxt_market_service.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/infrastructure/services/performance_service/__init__.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/infrastructure/services/performance_service/backtest_performance_service.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/infrastructure/services/performance_service/performance_service.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/services/__init__.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/services/backtesting/__init__.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/services/backtesting/backtest_report_writer_service.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/services/backtesting/backtest_service.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/services/configuration_service.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/services/market_credential_service.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/services/market_data_source_service/__init__.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/services/market_data_source_service/backtest_market_data_source_service.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/services/market_data_source_service/market_data_source_service.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/services/order_service/__init__.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/services/order_service/order_backtest_service.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/services/order_service/order_service.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/services/portfolios/__init__.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/services/portfolios/backtest_portfolio_service.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/services/portfolios/portfolio_configuration_service.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/services/portfolios/portfolio_service.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/services/portfolios/portfolio_snapshot_service.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/services/portfolios/portfolio_sync_service.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/services/position_service.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/services/position_snapshot_service.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/services/repository_service.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/services/strategy_orchestrator_service.py +0 -0
- {investing_algorithm_framework-3.3.1 → investing_algorithm_framework-3.4.0}/investing_algorithm_framework/services/trade_service/__init__.py +0 -0
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import inspect
|
|
2
2
|
import logging
|
|
3
3
|
from typing import List
|
|
4
|
-
import inspect
|
|
5
4
|
|
|
6
5
|
from investing_algorithm_framework.domain import OrderStatus, OrderFee, \
|
|
7
6
|
Position, Order, Portfolio, OrderType, OrderSide, \
|
|
8
7
|
BACKTESTING_FLAG, BACKTESTING_INDEX_DATETIME, MarketService, TimeUnit, \
|
|
9
|
-
OperationalException, random_string
|
|
8
|
+
OperationalException, random_string, RoundingService
|
|
10
9
|
from investing_algorithm_framework.services import MarketCredentialService, \
|
|
11
10
|
MarketDataSourceService, PortfolioService, PositionService, TradeService, \
|
|
12
11
|
OrderService, ConfigurationService, StrategyOrchestratorService, \
|
|
@@ -218,7 +217,7 @@ class Algorithm:
|
|
|
218
217
|
amount = position.get_amount() * (percentage_of_position / 100)
|
|
219
218
|
|
|
220
219
|
if precision is not None:
|
|
221
|
-
amount =
|
|
220
|
+
amount = RoundingService.round_down(amount, precision)
|
|
222
221
|
|
|
223
222
|
order_data = {
|
|
224
223
|
"target_symbol": target_symbol,
|
|
@@ -594,7 +593,9 @@ class Algorithm:
|
|
|
594
593
|
net_size = portfolio.get_net_size()
|
|
595
594
|
return (position.cost / net_size) * 100
|
|
596
595
|
|
|
597
|
-
def close_position(
|
|
596
|
+
def close_position(
|
|
597
|
+
self, symbol, market=None, identifier=None, precision=None
|
|
598
|
+
):
|
|
598
599
|
portfolio = self.portfolio_service.find(
|
|
599
600
|
{"market": market, "identifier": identifier}
|
|
600
601
|
)
|
|
@@ -623,6 +624,7 @@ class Algorithm:
|
|
|
623
624
|
amount=position.get_amount(),
|
|
624
625
|
order_side=OrderSide.SELL.value,
|
|
625
626
|
price=ticker["bid"],
|
|
627
|
+
precision=precision,
|
|
626
628
|
)
|
|
627
629
|
|
|
628
630
|
def add_strategies(self, strategies):
|
|
@@ -886,28 +888,13 @@ class Algorithm:
|
|
|
886
888
|
def get_closed_trades(self):
|
|
887
889
|
return self.trade_service.get_closed_trades()
|
|
888
890
|
|
|
889
|
-
def round_down(self, value, amount_of_decimals):
|
|
890
|
-
|
|
891
|
-
if self.count_decimals(value) <= amount_of_decimals:
|
|
892
|
-
return value
|
|
893
|
-
|
|
894
|
-
with decimal.localcontext() as ctx:
|
|
895
|
-
d = decimal.Decimal(value)
|
|
896
|
-
ctx.rounding = decimal.ROUND_DOWN
|
|
897
|
-
return float(round(d, amount_of_decimals))
|
|
898
|
-
|
|
899
|
-
def count_decimals(self, number):
|
|
900
|
-
decimal_str = str(number)
|
|
901
|
-
if '.' in decimal_str:
|
|
902
|
-
return len(decimal_str.split('.')[1])
|
|
903
|
-
else:
|
|
904
|
-
return 0
|
|
905
|
-
|
|
906
891
|
def get_open_trades(self, target_symbol=None, market=None):
|
|
907
892
|
return self.trade_service.get_open_trades(target_symbol, market)
|
|
908
893
|
|
|
909
|
-
def close_trade(self, trade, market=None):
|
|
910
|
-
self.trade_service.close_trade(
|
|
894
|
+
def close_trade(self, trade, market=None, precision=None) -> None:
|
|
895
|
+
self.trade_service.close_trade(
|
|
896
|
+
trade=trade, market=market, precision=precision
|
|
897
|
+
)
|
|
911
898
|
|
|
912
899
|
def get_number_of_positions(self):
|
|
913
900
|
"""
|
|
@@ -26,7 +26,8 @@ from .stateless_actions import StatelessActions
|
|
|
26
26
|
from .decimal_parsing import parse_decimal_to_string, parse_string_to_decimal
|
|
27
27
|
from .services import TickerMarketDataSource, OrderBookMarketDataSource, \
|
|
28
28
|
OHLCVMarketDataSource, BacktestMarketDataSource, MarketDataSource, \
|
|
29
|
-
MarketService, MarketCredentialService, AbstractPortfolioSyncService
|
|
29
|
+
MarketService, MarketCredentialService, AbstractPortfolioSyncService, \
|
|
30
|
+
RoundingService
|
|
30
31
|
from .data_structures import PeekableQueue
|
|
31
32
|
|
|
32
33
|
__all__ = [
|
|
@@ -109,5 +110,6 @@ __all__ = [
|
|
|
109
110
|
"RESERVED_BALANCES",
|
|
110
111
|
"AbstractPortfolioSyncService",
|
|
111
112
|
"APP_MODE",
|
|
112
|
-
"AppMode"
|
|
113
|
+
"AppMode",
|
|
114
|
+
"RoundingService",
|
|
113
115
|
]
|
|
@@ -3,6 +3,7 @@ from .market_data_sources import MarketDataSource, TickerMarketDataSource, \
|
|
|
3
3
|
from .market_service import MarketService
|
|
4
4
|
from .market_credential_service import MarketCredentialService
|
|
5
5
|
from .portfolios import AbstractPortfolioSyncService
|
|
6
|
+
from .rounding_service import RoundingService
|
|
6
7
|
|
|
7
8
|
__all__ = [
|
|
8
9
|
"MarketDataSource",
|
|
@@ -12,5 +13,6 @@ __all__ = [
|
|
|
12
13
|
"BacktestMarketDataSource",
|
|
13
14
|
"MarketService",
|
|
14
15
|
"MarketCredentialService",
|
|
15
|
-
"AbstractPortfolioSyncService"
|
|
16
|
+
"AbstractPortfolioSyncService",
|
|
17
|
+
"RoundingService",
|
|
16
18
|
]
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import decimal
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class RoundingService:
|
|
5
|
+
"""
|
|
6
|
+
Service to round numbers to a certain amount of decimals.
|
|
7
|
+
It will always round down.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
@staticmethod
|
|
11
|
+
def round_down(value, amount_of_decimals):
|
|
12
|
+
|
|
13
|
+
if RoundingService.count_decimals(value) <= amount_of_decimals:
|
|
14
|
+
return value
|
|
15
|
+
|
|
16
|
+
with decimal.localcontext() as ctx:
|
|
17
|
+
d = decimal.Decimal(value)
|
|
18
|
+
ctx.rounding = decimal.ROUND_DOWN
|
|
19
|
+
return float(round(d, amount_of_decimals))
|
|
20
|
+
|
|
21
|
+
@staticmethod
|
|
22
|
+
def count_decimals(number):
|
|
23
|
+
decimal_str = str(number)
|
|
24
|
+
if '.' in decimal_str:
|
|
25
|
+
return len(decimal_str.split('.')[1])
|
|
26
|
+
else:
|
|
27
|
+
return 0
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import logging
|
|
2
|
-
from typing import List
|
|
3
2
|
from queue import PriorityQueue
|
|
3
|
+
from typing import List
|
|
4
4
|
|
|
5
5
|
from investing_algorithm_framework.domain import OrderStatus, OrderSide, \
|
|
6
6
|
Trade, PeekableQueue, OrderType, TradeStatus, \
|
|
7
|
-
OperationalException, Order
|
|
8
|
-
from investing_algorithm_framework.services.position_service import \
|
|
9
|
-
PositionService
|
|
7
|
+
OperationalException, Order, RoundingService
|
|
10
8
|
from investing_algorithm_framework.services.market_data_source_service import \
|
|
11
9
|
MarketDataSourceService
|
|
10
|
+
from investing_algorithm_framework.services.position_service import \
|
|
11
|
+
PositionService
|
|
12
12
|
|
|
13
13
|
logger = logging.getLogger(__name__)
|
|
14
14
|
|
|
@@ -199,7 +199,7 @@ class TradeService:
|
|
|
199
199
|
if order.get_trade_closed_at() is not None
|
|
200
200
|
]
|
|
201
201
|
|
|
202
|
-
def close_trade(self, trade, market=None) -> None:
|
|
202
|
+
def close_trade(self, trade, market=None, precision=None) -> None:
|
|
203
203
|
"""
|
|
204
204
|
Close trade method
|
|
205
205
|
|
|
@@ -210,6 +210,7 @@ class TradeService:
|
|
|
210
210
|
|
|
211
211
|
return: None
|
|
212
212
|
"""
|
|
213
|
+
|
|
213
214
|
if trade.closed_at is not None:
|
|
214
215
|
raise OperationalException("Trade already closed.")
|
|
215
216
|
|
|
@@ -227,6 +228,9 @@ class TradeService:
|
|
|
227
228
|
)
|
|
228
229
|
amount = order.get_amount()
|
|
229
230
|
|
|
231
|
+
if precision is not None:
|
|
232
|
+
amount = RoundingService.round_down(amount, precision)
|
|
233
|
+
|
|
230
234
|
if position.get_amount() < amount:
|
|
231
235
|
logger.warning(
|
|
232
236
|
f"Order amount {amount} is larger then amount "
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|