Fix price bound logic

This commit is contained in:
Mark Veidemanis 2022-11-22 08:10:38 +00:00
parent 46bba54cb7
commit 3f8fb66656
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
1 changed files with 6 additions and 5 deletions

View File

@ -253,14 +253,15 @@ def get_price_bound(direction, strategy, price, current_price):
current_price_slippage = D(current_price) * D(price_slippage_as_ratio) current_price_slippage = D(current_price) * D(price_slippage_as_ratio)
log.debug(f"Maximum deviation from current price: {current_price_slippage}") 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": 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) 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}") log.debug(f"Price bound: {price_bound}")
return price_bound return price_bound