策略知识库.EN
策略

币安出售所有山寨币

Zero · javascript · 工具与附录 · 2018-06-11 17:56:50

全部策略 →

背景术语

源码摘要 自动提取 · 未经作者说明

源码,检测到 开仓;无作者说明,内容由代码自动提取。

交易源码开仓

识别到的术语

无

操作术语

无

代码注释

  • 无注释

代码行 41 · 函数 1 · 类 0 · 参数 1

参数

参数默认值说明
quoteZone0交易区: BTC
源码(41 行)
function main() {
    var quoteCurrency = ['BTC', 'ETH', 'BNB', 'USDT'][quoteZone];
    Log("当前交易区", quoteCurrency);
    var symbols = JSON.parse(_C(HttpQuery, "https://api.binance.com/api/v1/exchangeInfo")).symbols;
    _.each(_C(exchange.GetAccount).Info.balances, function(ele) {
        if (ele.asset == quoteCurrency) {
            return
        }
        var totalV = parseFloat(ele.free) + parseFloat(ele.locked);
        if (totalV == 0) {
            return;
        }
        var cfg = _.findWhere(symbols, {symbol: ele.asset+quoteCurrency});
        if (!cfg) {
            Log("没有找到", ele.asset, "交易对的配置", ele);
            return;
        }
        var filter = _.findWhere(cfg.filters, {filterType: "LOT_SIZE"});
        if (!filter) {
            return;
        }
        
        var v = _N(parseInt(totalV/filter.stepSize)*filter.stepSize, cfg.baseAssetPrecision);
        if (v > 0) {
            Log(ele, "stepSize", filter.stepSize);
            exchange.IO("currency", ele.asset + "_"+quoteCurrency);
            while (true) {
                var orders = _C(exchange.GetOrders);
                _.each(orders, function(order) {
                    exchange.CancelOrder(order.Id);
                });
                if (orders.length == 0) {
                    break;
                }
            }
            exchange.Sell(-1, v);
            Log(ele);
        }
    });
    Log("操作完成, 当前", quoteCurrency, "数量", _C(exchange.GetAccount).Balance);
}