Removed use of abs() to get a Decimal absolute value - now use the copy_abs() method instead.
This commit is contained in:
parent
9f66be9807
commit
790f379867
|
@ -852,7 +852,7 @@ class Account(AddressableAccount):
|
|||
slot.net_value.value + spot_open_orders.base_token_free
|
||||
)
|
||||
|
||||
if abs(spot_bids_base_net) > abs(spot_asks_base_net):
|
||||
if spot_bids_base_net.copy_abs() > spot_asks_base_net.copy_abs():
|
||||
spot_health_base = spot_bids_base_net
|
||||
spot_health_quote = spot_open_orders.quote_token_free
|
||||
else:
|
||||
|
@ -951,7 +951,7 @@ class Account(AddressableAccount):
|
|||
quote_pos = slot.perp_account.quote_position / (
|
||||
10**self.shared_quote_token.decimals
|
||||
)
|
||||
if abs(perp_bids_base_net) > abs(perp_asks_base_net):
|
||||
if perp_bids_base_net.copy_abs() > perp_asks_base_net.copy_abs():
|
||||
perp_health_base = perp_bids_base_net
|
||||
perp_health_quote = (
|
||||
(quote_pos + unsettled_funding)
|
||||
|
|
|
@ -127,7 +127,7 @@ class PerpToSpotHedger(Hedger):
|
|||
f"Delta from {self.underlying_market.fully_qualified_symbol} to {self.hedging_market.fully_qualified_symbol} is {delta:,.8f} {basket_token.base_instrument.symbol}, action threshold is: {self.action_threshold}"
|
||||
)
|
||||
|
||||
if abs(delta) > self.action_threshold:
|
||||
if delta.copy_abs() > self.action_threshold:
|
||||
side: mango.Side = mango.Side.BUY if delta < 0 else mango.Side.SELL
|
||||
up_or_down: str = "up to" if side == mango.Side.BUY else "down to"
|
||||
price_adjustment_factor: Decimal = (
|
||||
|
@ -139,7 +139,7 @@ class PerpToSpotHedger(Hedger):
|
|||
adjusted_price: Decimal = (
|
||||
model_state.price.mid_price * price_adjustment_factor
|
||||
)
|
||||
quantity: Decimal = abs(delta)
|
||||
quantity: Decimal = delta.copy_abs()
|
||||
if (self.max_hedge_chunk_quantity > 0) and (
|
||||
quantity > self.max_hedge_chunk_quantity
|
||||
):
|
||||
|
|
Loading…
Reference in New Issue