hummingbot / hummingbot

Open source software that helps you create and deploy high-frequency crypto trading bots
https://hummingbot.org
Apache License 2.0
8.1k stars 2.81k forks source link

[BUG] Paper trade not placing sell orders on certain spread #1617

Closed rennel-tabing closed 4 years ago

rennel-tabing commented 4 years ago

Describe the bug // A clear and concise description of what the bug is. There is an unusual case where in the bot will only place buy orders

Steps To Reproduce // A concise description of the steps to reproduce the buggy behavior:

  1. Run a Pure Market making on Paper Trade mode using a sample config below
  2. Update the bid/ask spread and restart the strategy

** It seems that the issue is more likely to happen if you are using a spread that is less than 0.1%

Here are the results that I have run

Running on Version 0.25.0

Some configs wherein BOTH buy and sell are placed on the order book
bid 0.002 
ask 0.002

bid 0.001
ask 0.002

bid 0.002
ask 0.1

bid  0.005 
ask 0.005 
========================================================
Some configs wherein ONLY buy is placed on the order book

bid 0.001
ask 0.001

bid 0.0005
ask 0.002

bid 0.005 
ask 0.0005
On dev 0.26.0 (build e80c8f90a285fca5a971be576bb4010c19e17447)

bid 0.1%
ask 0.1 %
only bid is placed

bid at 0.05%
ask at 0.2%
both orders are placed

bid 0.005%
ask 0.005%
only bid is placed

bid 1%
ask 1%
both orders are placed

bid 0.2%
ask 0.2%
both order are placed

bid 0.5 %
ask 0.05 %
only bid order is placed

Screenshots // If applicable, add screenshots to help explain your problem.


Only bid order was placed even if there is enough inventory image

Release version // Include your bot's version number (Can be found at the upper left corner of your CLI). 0.25.0 dev-0.26.0

Attachments

########################################################
###       Pure market making strategy config         ###
########################################################

template_version: 10

############  Basic configuration section  ############

# Exchange and token parameters.
maker_market: binance
maker_market_trading_pair: ZIL-ETH

# Size of your bid and ask order.
order_amount: 2000.0

# How far away from mid price to place the bid order.
# Expressed in decimals : 0.01 = 1% away from mid price at that time.
# Example if mid price is 100 and bid_place threshold is 0.01.
# Your bid is placed at 99.
bid_place_threshold: 0.0005

# How far away from mid price to place the ask order.
# Expressed in decimals : 0.01 = 1% away from mid price at that time.
# Example if mid price is 100 and ask_place threshold is 0.01.
# Your bid is placed at 101.
ask_place_threshold: 0.0005

# Time in seconds before cancelling and rerunning strategy.
# If tick size is 60, the bot cancels active orders and reruns after a minute.
cancel_order_wait_time: 60.0

# Whether to enable advanced configuration setting (true/false).
# Only used when creating a new configuration file.
advanced_mode: false

############  Advanced configuration section  ############

# Ox ONLY - Sets the expiration of limit orders. Minimum is 130 seconds.
expiration_seconds: 130.0

# Whether to single or multiple bids and asks.
mode: single

# Number of orders to place on each side of the order book (for multiple orders mode).
number_of_orders: 3

# Size of the first bid and ask order (for multiple orders mode).
order_start_size: 2000.0

# Increment size of consecutive orders after the first order (for multiple orders mode).
order_step_size: 0.0

# Order price space between orders (for multiple orders mode).
order_interval_percent: 0.00025

# Whether to enable Inventory skew feature (true/false).
inventory_skew_enabled: false

# Target base asset inventory percentage target to be maintained (for Inventory skew feature).
inventory_target_base_percent: 50.0

# The range around the inventory target base percent to maintain, expressed in multiples of total order size (for
# inventory skew feature).
inventory_range_multiplier: 0.25

# How long to wait before placing the next order in case your order gets filled.
filled_order_replenish_wait_time: 10.0

# Whether to stop cancellations of orders on the other side when one side is filled (hanging orders feature) (true/false).
enable_order_filled_stop_cancellation: false

# Spread (from mid price, in percentage) hanging orders will be canceled (Enter 0.01 to indicate 1%)
cancel_hanging_order_pct: 0.01

# Whether to enable best bid ask jumping mode (true/false).
best_bid_ask_jump_mode: false

# The depth in base asset amount to be used for finding top bid and ask (for best bid ask jumping mode).
best_bid_ask_jump_orders_depth: 0.0005

# Whether to enable adding transaction costs to order price calculation (true/false).
add_transaction_costs: false

# Whether to use external pricing source for the mid price (true/false).
external_pricing_source: false

# The type of external pricing source (exchange/feed/custom_api).
external_price_source_type:

# An external exchange name (for external exchange pricing source).
external_price_source_exchange:

# A trading pair for the external exchange (for external exchange pricing source).
external_price_source_exchange_trading_pair:

# A base asset, e.g. ETH (for external feed pricing source).
external_price_source_feed_base_asset:

# A quote asset, e.g. USD (for external feed pricing source).
external_price_source_feed_quote_asset:

# An external api that returns price (for external custom_api pricing source).
external_price_source_custom_api:

# For more detailed information, see:
# https://docs.hummingbot.io/strategies/pure-market-making/#configuration-parameters

WARNING: Do NOT publish any exchange API keys or your wallet's private key. Whoever has access to them may steal your assets!

Optional: your discord username: Optional: your ETH address: (If you want to participate in the bug bounty)

RC-13 commented 4 years ago

After a series of tests on different pairs, we have confirmed that this behavior occurs on token pairs that have price with 8 decimal digit (price is below 1000 Satoshi) and the issue is linked to bug #1618. Since bot detects up to 7 decimal digit, it affects the mid-price and calculation of orders. The ask/sell price is affected, as most of the time, it's hitting the same price as the mid-price or within the midprice range. Increasing the ask threshold will allow the creation of sell orders.

RC-13 commented 4 years ago

Confirm fix on PR #1624, use different bid and ask threshold and verified that sell orders are created as long as the balance is enough and within the target base percentage.

Inventory skew = False ZIL

Inventory skew = True ZIL

dennisocana commented 4 years ago

Fix will be in the upcoming 0.26.0 release.