Binance Multi Trading Pairs Spot Used for Market Liquidation
This is used to clear stock., For example, running multi-pair spot grids or Martingale strategies-if you no longer want to run them, but you hold numerous coins, selling them one by one is too troublesome, Just use…
This is used to clear stock., For example, running multi-pair spot grids or Martingale strategies-if you no longer want to run them, but you hold numerous coins, selling them one by one is too troublesome, Just use this; input the currency into the parameters, and all market prices will automatically be sold. However, sometimes after selling out, there will still be assets with a valuation less than 0.0012 BTC. At this time, you need to use [Small Assets Exchange for BNB] in the spot wallet., In other words, if you have BNB, it is best to sell it at the market price.

Parameters
| Name | Default | What it controls |
|---|---|---|
| B_Sleep_time | 5 | Polling interval (seconds)) |
| B_symbols | TRX_BUSD,LTC_BUSD,BCH_BUSD | trading pair |
| B_chongzhi | false | Reset |
Source JavaScript
//Global Variables
var arrSymbols = B_symbols.split(",") // Comma-separated transaction symbol string
//Get price precision quantity precision function
function GetPrecision() {
var precision = {
price: 0, //Precision-price
amount: 0 //Accuracy-quantity
}
var depth = _C(exchange.GetDepth)
if (!depth) {
throw 'Cannot connect to exchange market, need overseas custodian'
}
for (var i = 0; i < depth.Asks.length; i++) {
var amountPrecision = depth.Asks[i].Amount.toString().indexOf('.') > -1 ? depth.Asks[i].Amount.toString().split('.')[1].length : 0
precision.amount = Math.max(precision.amount, amountPrecision) //Quantity Precision
var pricePrecision = depth.Asks[i].Price.toString().indexOf('.') > -1 ? depth.Asks[i].Price.toString().split('.')[1].length : 0
precision.price = Math.max(precision.price, pricePrecision) //Price Precision
}
return precision
}
//Function to cancel all pending orders
//Parametere Yes/Is exchange.SetCurrency() of exchange
function cancelAll(e) {
while (true) {
var orders = _C(e.GetOrders)
if (orders.length == 0) {
break
} else {
for (var i = 0; i < orders.length; i++) {
e.CancelOrder(orders[i].Id, orders[i])
Sleep(200)
}
}
Sleep(200)
}
}
function Trad() {
for (var i = 0; i < arrSymbols.length; i++) {
Sleep(500)
symbol = arrSymbols[i]
exchange.SetCurrency(symbol)
var ticker = _C(exchange.GetTicker).Last //Latest price
var precision = GetPrecision() //Get quantity accuracy and price accuracy
var acc = _C(exchange.GetAccount)
var base_balance = acc.Stocks //Currency, available balance
var base_FrozenStocks = acc.FrozenStocks //The amount of currency frozen in pending orders
var holdAmount = _N(parseFloat(base_balance + base_FrozenStocks), precision.amount) //Position = Currency balance+Freeze quantity
if (holdAmount == 0 || holdAmount * ticker < 10) { //No position means the initial state,10USDTThe value is the minimum trading amount on Binance spot, less than10cannot be traded
cancelAll(exchange)
Log(symbol, "There is no position, or the number of positions is not enough for trading, the number of positions:", holdAmount)
}
if (holdAmount * ticker >= 10) { //Position Value >= USDTValue, then there is a position.
Log(symbol, "Has positions, position quantity:", holdAmount, "Market price clearance", "#B15BFF")
cancelAll(exchange)
Sleep(500)
var clearsell = exchange.Sell(-1, holdAmount) //close all positions
Sleep(500)
acc = _C(exchange.GetAccount)
base_balance = acc.Stocks //Currency, available balance
base_FrozenStocks = acc.FrozenStocks //The amount of currency frozen in pending orders
holdAmount = _N(parseFloat(base_balance + base_FrozenStocks), precision.amount) //Reacquire position quantity
Log(symbol, "Position Quantity:", holdAmount, "#B15BFF")
}
}
}
//Exit and cancel all pending orders
function onexit() {
Log("Stop the bot and cancel all pending orders", "#6F00D2")
for (var i = 0; i < arrSymbols.length; i++) {
symbol = arrSymbols[i]
exchange.SetCurrency(symbol)
cancelAll(exchange)
Sleep(200)
}
Sleep(200)
}
//Exit on error and cancel all pending orders
function onerror() {
Log("Bot error, cancel all pending orders", "#00BB00")
for (var i = 0; i < arrSymbols.length; i++) {
symbol = arrSymbols[i]
exchange.SetCurrency(symbol)
cancelAll(exchange)
Sleep(200)
}
Sleep(200)
}
function main() {
if (B_chongzhi) {
// LogProfitReset() //Clear the income chart, only clear the chart, but not the log information
LogReset() //Clear logs. Only clear logs, do not clear charts.
LogVacuum()
Log("Reset all data", "#FF0000")
}
while (true) {
Trad()
Sleep(B_Sleep_time * 1000)
}
}
Published by 轻轻的云 on the FMZ strategy square · last modified 2022-05-02. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.
Build this with AgenKit
A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Binance-Multi-Trading-Pairs-Spot-Used-for-Market-Liquidation.md- npx agenkit install engineering-kit in your project
- Paste the command into your agent and approve each phase
- Get tests, backtest, risk controls and a paper-trading switch
Understand it first
Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.
Related specs
- CTA Strategy Commodity Futures Simple MartingaleJavaScript · Martingale · 1d
- Fibonacci Sequence StrategyJavaScript · Martingale · 1d
- MartinGale Strategy1JavaScript · Martingale
- Simple Martingale Long and Short Position Increase Ratio ModificationJavaScript · Martingale · 1d
- Random Number Martingale StrategyJavaScript · Martingale
- Simple Martingale BTC Contract Modify Add Position MultiplierJavaScript · Martingale · 1d