Fix price bound logic
This commit is contained in:
parent
46bba54cb7
commit
3f8fb66656
|
@ -253,14 +253,15 @@ def get_price_bound(direction, strategy, price, current_price):
|
|||
current_price_slippage = D(current_price) * D(price_slippage_as_ratio)
|
||||
log.debug(f"Maximum deviation from current price: {current_price_slippage}")
|
||||
|
||||
# Subtract slippage for buys, since we lose money if the price goes down
|
||||
# Price bound is the worst price we are willing to pay for the trade
|
||||
# For buys, a higher price is worse
|
||||
if direction == "buy":
|
||||
price_bound = D(current_price) - D(price_slippage)
|
||||
|
||||
# Add slippage for sells, since we lose money if the price goes up
|
||||
elif direction == "sell":
|
||||
price_bound = D(current_price) + D(price_slippage)
|
||||
|
||||
# For sells, a lower price is worse
|
||||
elif direction == "sell":
|
||||
price_bound = D(current_price) - D(price_slippage)
|
||||
|
||||
log.debug(f"Price bound: {price_bound}")
|
||||
return price_bound
|
||||
|
||||
|
|
Loading…
Reference in New Issue