0bps

Strategy vault / Other

Binance Withdrawal Sample Code

JavaScript strategy by 发明者量化-小小梦.

JavaScriptOther
Author
发明者量化-小小梦
Complexity
Starter · 44 lines
Parameters
0

The original spec has no written description. Read the source below.

Source JavaScript

String.prototype.format= function(){
    var args = Array.prototype.slice.call(arguments);
    var count=0;
    return this.replace(/%s/g,function(s,i){
        return args[count++];
    });
}

function WithdrawForBinance (accessKey, currency, address, addressTag, amount) {
    /* Withdraw API desc on Binance API doc
        query string :
            asset=ETH&address=0x6915f16f8791d0a1cc2bf47c13a6b2a92000504b&amount=1&recvWindow=5000&name=test&timestamp=1510903211000
        HMAC SHA256 signature:
            [linux]$ echo -n "asset=ETH&address=0x6915f16f8791d0a1cc2bf47c13a6b2a92000504b&amount=1&recvWindow=5000&timestamp=1510903211000" | 
            openssl dgst -sha256 -hmac "NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j"
            (stdin)= 157fb937ec848b5f802daa4d9f62bea08becbf4f311203bda2bd34cd9853e320
        curl command:
            (HMAC SHA256)
            [linux]$ curl -H "X-MBX-APIKEY: vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A" -X 
            POST 'https://www.binance.com/wapi/v3/withdraw.html?
            asset=ETH&address=0x6915f16f8791d0a1cc2bf47c13a6b2a92000504b&amount=1&recvWindow=5000&name=addressName&timestamp=1510903211000&
            signature=157fb937ec848b5f802daa4d9f62bea08becbf4f311203bda2bd34cd9853e320'
    */
    
    var timeStamp = new Date().getTime()
    var queryString = "asset=%s&address=%s&amount=%s&name=%s&timestamp=%s"
    queryString = queryString.format(currency, address, amount, addressTag, timeStamp)
    
    // sign
    var signature = exchange.HMAC("sha256", "hex", queryString, "{{secretkey}}")
    var uri = "https://www.binance.com/wapi/v3/withdraw.html?" + queryString + "&signature=" + signature
    
    // request
    var ret = HttpQuery(uri, "", "", "X-MBX-APIKEY: " + accessKey, true)
    
    Log(ret)
}




function main() {
    WithdrawForBinance("your accessKey", "ETH", "the address that you want to send", "test", "0.01")
}

Published by 发明者量化-小小梦 on the FMZ strategy square · last modified 2019-05-16. 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.

in Claude Code, Cursor, Codex & 4 more
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Binance-Withdrawal-Sample-Code.md
  1. npx agenkit install engineering-kit in your project
  2. Paste the command into your agent and approve each phase
  3. 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

esc

Try , , or .

↑↓ move↵ open