Strategy vault / Tools & templates
Binance Trading Terminal Fund Transfer Widget
JavaScript strategy by 高频量化.
JavaScriptTools & templates
The original spec has no written description. Read the source below.
Parameters
| Name | Default | What it controls |
|---|---|---|
| assets | USDT | Transfer Currency |
| amount | 10 | Transfer Quantity |
| typeIndex | 0 | Transfer type: Transfer from spot account to USDT contract account | Transfer from USDT contract account to spot account | Transfer from spot account to currency-standard contract account | Transfer from currency-standard contract account to spot account |
Source JavaScript
var type = 1;
assets = "USDT" //Prevent missing parameters
amount = "10" //Prevent missing parameters
//var type = [1, 2, 3, 4][typeIndex]
function UsdtTransfer(e, cur, amount, type) {
try {
var base = ''
var params = ''
var Currency = cur
var Transfer Quantity = amount
var exname = e.GetName() //Obtain the marker of the exchange interface
if (exname == 'Binance') {
Log("exname=", exname)
// 1: Spot account toUSDTContract account transfer
// 2: USDTTransfer from contract account to spot account
// 3: Transfer from spot account to currency-based contract account
// 4: Transfer from currency-based contract account to spot account
var Transfer type = type
//Transfer to spot
//POST /sapi/v1/futures/transfer
base ="https://api.binance.com"
e.SetBase(base)
var timestamp = new Date().getTime()
params = "asset=" + Currency + "&amount=" + Transfer Quantity + "&type=" + Transfer type + "×tamp" + timestamp
Log("trading pair:", Currency, "Transfer Quantity:", Transfer Quantity, "Transfer type:", Transfer type)
var ret1 = e.IO("api", "POST", "/sapi/v1/futures/transfer", params)
Log(ret1)
return ret1
} else if (exname == 'Futures_Binance') {
Log("exname=", exname)
// 1: Spot account toUSDTContract account transfer
// 2: USDTTransfer from contract account to spot account
// 3: Transfer from spot account to currency-based contract account
// 4: Transfer from currency-based contract account to spot account
var xTransfer type = type
//Transfer to spot
//POST /sapi/v1/futures/transfer
base ="https://api.binance.com"
e.SetBase(base) //Set in the spot interface
var xtimestamp = new Date().getTime()
params = "asset=" + Currency + "&amount=" + Transfer Quantity + "&type=" + xTransfer type + "&xtimestamp" + xtimestamp
Log("trading pair:", Currency, "Transfer Quantity:", Transfer Quantity, "xTransfer type:", xTransfer type)
//var ret1 = e.IO("api", "POST", "/sapi/v1/futures/transfer" ,"", JSON.stringify( params ) )
var ret2 = e.IO("api", "POST", "/sapi/v1/futures/transfer", params) //Send transfer
Log(ret2)
//Need to switch back to the originalAPIInterface, otherwise it may affect subsequent account trading
base = "https://fapi.binance.com" //Futures interface
e.SetBase(base)
return ret2
}
//Log("Loop once")
} catch (error) {
Log(error)
}
}
function GetCom() {
var cmd = GetCommand()
if (cmd) {
var arr = cmd.split(":")
Log(arr)
if (arr[0] == "assets") {
assets = arr[1]
Log("Switch toassets:", assets)
}
if (arr[0] == "amount") {
amount = arr[1]
Log("Switch toamount:", amount)
}
if (arr[0] == "typeIndex") {
type = Number(arr[1]) + 1
Log("Switch totype:", type)
var feedback = UsdtTransfer(exchange, assets, amount, type)
if(feedback){
Log("Fund transfer successful")
//Sleep(1000 * 3); // Sleep for 3 seconds
}
}
}
}
function main() {
while (true) {
GetCom()
Sleep(1000 * 1); // Sleep for 3 seconds
}
}Published by 高频量化 on the FMZ strategy square · last modified 2021-12-24. 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 tested, production-ready module from strategies/Binance-Trading-Terminal-Fund-Transfer-Widget.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
- Binance Account Cross Transfer Small ToolJavaScript · Tools & templates
- Get cryptocurrency current and max supplyJavaScript · Tools & templates
- Interaction TemplateJavaScript · Tools & templates
- KuCoin Fund Transfer PluginJavaScript · Tools & templates
- Moving Average Bot 30 linesJavaScript · Tools & templates · 1d
- OKEx V5 Candlestick Data Paginated Query ExampleJavaScript · Tools & templates