Skip to content

Commit

Permalink
add MAX_ASK_PRICE to listing sniper to abort a sniping when the marke…
Browse files Browse the repository at this point in the history
…t price already is above a given price
  • Loading branch information
AntoineLep committed Oct 18, 2022
1 parent 15d9d76 commit 556d140
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion strategies/listing_sniper/listing_sniper.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# the order fill price can be higher than the computed one based on last stock data
AMOUNT_TO_INVEST = 2000

MAX_ASK_PRICE = 50 # If the price is already above MAX_ASK_PRICE, the sniping will be aborted

# First take profit
TP1_TARGET_PERCENTAGE = 500
TP1_SIZE_RATIO = 0.3
Expand All @@ -25,7 +27,7 @@
# TP3_SIZE_RATIO Will be filled with remaining position size

# Stop loss
SL_PERCENTAGE = 50
SL_PERCENTAGE = 20


class ListingSniper(Strategy):
Expand Down Expand Up @@ -67,6 +69,11 @@ def loop(self) -> None:
raise Exception(f"Order computed size {order_size} is less than the minimum size "
f"{m_response['minProvideSize']}")

if m_response["ask"] is not None and m_response["ask"] > MAX_ASK_PRICE:
self._sniped = True
logging.info(f"Sniping Aborted (price pumped too much) !")
return

opening_order_params = {
"market": MARKET_PAIR_TO_SNIPE,
"side": "buy",
Expand Down

0 comments on commit 556d140

Please sign in to comment.