Skip to content

Commit

Permalink
Fix/percentage order (#246)
Browse files Browse the repository at this point in the history
* Fix percentage order

* Remove debug

* Bump version
  • Loading branch information
MDUYN authored Oct 15, 2023
1 parent edeca54 commit 79c7200
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
3 changes: 1 addition & 2 deletions investing_algorithm_framework/app/algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,13 @@ def create_limit_order(
portfolio = self.portfolio_service.find({"market": market})

if percentage_of_portfolio is not None:

if not OrderSide.BUY.equals(side):
raise ApiException(
"Percentage of portfolio is only supported for BUY orders."
)

size = float(portfolio.net_size) * (percentage_of_portfolio / 100)
amount = floor(size / price)
amount = size / price

elif percentage_of_position is not None:

Expand Down
1 change: 1 addition & 0 deletions investing_algorithm_framework/app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ def create_portfolios(self):
continue

balances = market_service.get_balance()

if portfolio_configuration.trading_symbol.upper() not in balances:
raise OperationalException(
f"Trading symbol balance not available "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def _apply_query_params(self, db, query, query_params):
"position", query_params, many=True
)
target_symbol_query_param = self.get_query_param(
"symbol", query_params
"target_symbol", query_params
)
trading_symbol_query_param = self.get_query_param(
"trading_symbol", query_params
Expand Down
2 changes: 1 addition & 1 deletion version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION = (1, 4, 3, 'alpha', 0)
VERSION = (1, 4, 4, 'alpha', 0)


def get_version(version=None):
Expand Down

0 comments on commit 79c7200

Please sign in to comment.