21jake/Binance-volatility-trading-bot-JS

Multiple orders for a single symbol

Closed this issue · 6 comments

When a price continues to rise the bot will purchase further orders of a single symbol. This is recorded correctly in the current-orders.json but when it comes to selling it does not appear to process all orders.

Suggested behaviour: when a stop loss is triggered for a symbol then all current orders for that symbol should be closed, not just the first on the list.

Just had a sell order with two entries for a single symbol and this appears to have worked OK. Previous example had three entries I think.

This is weird since if the bot has successfully bought enough according to the QUANTITY, theoretically it won't buy the same symbol or any other symbol unless the initial asset is sold. Can you provide some settings / variables so I can reproduce the bug?

Here are the sell logs for an overlapping pair of the same symbol.

{
"symbol": "XVSUSDT",
"quantity": 0.2,
"orderId": 193782324,
"bought_at": 124.527,
"TP_Threshold": 146.45488,
"SL_Threshold": 136.59734,
"purchase_time": "18/05/2021, 17:06:19",
"updated_at": "18/05/2021, 17:36:18",
"sell_time": "18/05/2021, 18:04:16",
"sell_at": "131.63900000",
"profit": "5.71%"
},
{
"symbol": "XVSUSDT",
"quantity": 0.428,
"orderId": 193547730,
"bought_at": 117.195,
"TP_Threshold": 146.45488,
"SL_Threshold": 136.59734,
"purchase_time": "18/05/2021, 16:45:12",
"updated_at": "18/05/2021, 17:36:18",
"sell_time": "18/05/2021, 18:04:16",
"sell_at": "131.63900000",
"profit": "12.32%"
},

Settings were

# PRICE CHECKING INTERVAL, MEASURED IN MINUTES
INTERVAL = 5

# SET USDT AS THE DEFAULT PAIR-ER
PAIR_WITH = 'USDT'

# THE MAXIMUM AMOUNT THE BOT CAN SPEND
QUANTITY = 50

# MINIMUM AMOUNT TO PLACE AN ORDER, BINANCE WOULDN'T ALLOW A LOWER QUANTITY.
MIN_QUANTITY = 11

# IF THE PRICE OF A COIN INCREASES BY THIS PERCENTAGE, THE BOT PROCEEDS TO BUY IT. DEFAULT TO 3
VOLATILE_TRIGGER = 3

# TAKE PROFIT THRESHOLD
TP_THRESHOLD = 6

# STOP LOSS THRESHOLD
SL_THRESHOLD = 3

Couldn't reproduce on the Testnet. Just curious, were the QUANTITY or the TRAILING_MODE changed while the first asset wasn't sold? My only assumption is the increase in QUANTITY allowed the bot to buy spend more even if the first asset wasn't sold first. Right now I can't run a test on Mainnet since I spend all on shopping today. Happy red day :D.

Edit: Alright I figured out the potential cause, my calculatePortfolioValue function doesn't work as expected and allows the bot to buy more than the initial QUANTITY. After 8ca1161 this should be fixed, please report if this persists.

OK, will give it a test. Hope you shopped at the right time! BTC at 30k USDT!!

The issue seems to be fixed since 8ca1161