Skip to content

Commit b3765a2

Browse files
committed
chore: revert changes in margin utils
1 parent 54ec904 commit b3765a2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pyinjective/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ def binary_options_quantity_to_backend(quantity, denom) -> int:
5757

5858
def derivative_margin_to_backend(price, quantity, leverage, denom) -> int:
5959
price_tick_size = Decimal(denom.min_price_tick_size) / pow(10, denom.quote)
60-
margin = Decimal(str(price)) * Decimal(str(quantity)) / Decimal(str(leverage))
61-
exchange_margin = margin * pow(10, 18 + denom.quote)
60+
margin = (price * quantity) / leverage
61+
exchange_margin = floor_to(margin, float(price_tick_size)) * pow(10, 18 + denom.quote)
6262
return int(exchange_margin)
6363

6464
def binary_options_buy_margin_to_backend(price, quantity, denom) -> int:
6565
price_tick_size = Decimal(denom.min_price_tick_size) / pow(10, denom.quote)
6666
margin = Decimal(str(price)) * Decimal(str(quantity))
67-
exchange_margin = margin * pow(10, 18 + denom.quote)
67+
exchange_margin = floor_to(margin, float(price_tick_size)) * pow(10, 18 + denom.quote)
6868
return int(exchange_margin)
6969

7070
def binary_options_sell_margin_to_backend(price, quantity, denom) -> int:

0 commit comments

Comments
 (0)