例如 A 交易所 : ETH_BTC B 交易所 : ETH_USDT C 交易所(其实为 B交易所 另一个交易对而已,逻辑上认为是C。) : BTC_USDT
B 、C 交易所交易对组合成 ETH_BTC 和A 交易所对冲。这样BC实际是一个交易所账户。
// 交易对以 ETH_BTC , ETH_USDT , BTC_USDT 为例 // 教学策略,还有很大优化空间,例如:币平衡模块,根据手续费率控制对冲差价,硬搬砖等等。 function main () { if (exchanges[0].GetQuoteCurrency() != exchanges[2].GetCurrency().split("_")[0] || exchanges[0].GetCurrency().split("_")[0] != exchanges[1].GetCurrency().split("_")[0]) { throw "交易所 交易对 配置错误。" } var marketSlideRate = 1 // 1.02 var hedgeDiff = 0.0007 var hedgeAmount = 0.1 var isFirst = true var concurrenter = function (funcName, isWait, tasks, amounts) { for (var i = 0 ; i < exchanges.length; i++) { if (isFirst) { exchanges[i].acc = _C(exchanges[i].GetAccount) exchanges[i].initAcc = exchanges[i].acc } if (isWait) { var a = funcName == "GetTicker" ? exchanges[i].ticker = exchanges[i].tiR.wait() : exchanges[i].id = exchanges[i].trR.wait() if (funcName == "trade") { exchanges[i].acc = _C(exchanges[i].GetAccount) } } else { var b = funcName == "GetTicker" ? exchanges[i].tiR = exchanges[i].Go(funcName) : exchanges[i].trR = exchanges[i].Go(tasks[i], -1, amounts[i], exchanges[i].GetCurrency()) } } if (funcName == "trade" && isWait) { Log("BTC:", exchange.BTC = exchanges[0].acc.Balance + exchanges[2].acc.Stocks, "ETH:", exchange.ETH = exchanges[0].acc.Stocks + exchanges[1].acc.Stocks, "USDT:", exchange.USDT = exchanges[1].acc.Balance + exchanges[2].acc.Balance, "#FF0000") LogProfit(exchange.USDT - (exchanges[1].initAcc.Balance + exchanges[2].initAcc.Balance) - (exchanges[0].initAcc.Balance + exchanges[2].initAcc.Stocks - exchange.BTC) * exchanges[2].ticker.Last - (exchanges[0].initAcc.Stocks + exchanges[1].initAcc.Stocks - exchange.ETH) * exchanges[1].ticker.Last) } isFirst = false } while (1) { concurrenter("GetTicker", false) concurrenter("GetTicker", true) var tickerA = exchanges[0].ticker var tickerB = exchanges[1].ticker var tickerC = exchanges[2].ticker var tickerBC = { Buy : tickerB.Buy / tickerC.Sell, Sell : tickerB.Sell / tickerC.Buy, } if (tickerA.Buy - tickerBC.Sell > hedgeDiff && exchanges[0].acc.Stocks > 0.2 && exchanges[1].acc.Balance > 500 && exchanges[2].acc.Stocks > 0.03) { // Sell A , Buy BC (Buy B Sell C) concurrenter("trade", false, ["Sell", "Buy", "Sell"], [hedgeAmount, marketSlideRate * tickerB.Sell * hedgeAmount, tickerB.Sell * hedgeAmount / tickerC.Buy]) concurrenter("trade", true) } if (tickerBC.Buy - tickerA.Sell > hedgeDiff && exchanges[0].acc.Balance > 0.03 && exchanges[1].acc.Stocks > 0.2 && exchanges[2].acc.Balance > 500) { // Buy A , Sell BC (...) concurrenter("trade", false, ["Buy", "Sell", "Buy"], [marketSlideRate * hedgeAmount * tickerA.Sell, hedgeAmount, marketSlideRate * hedgeAmount * tickerA.Sell * tickerC.Sell]) concurrenter("trade", true) } Sleep(500) } }
BNMBNM pro: TypeError: cannot read property 'Sell' of null at main (__FILE__:45) pro: GetTicker: 429: {"msg":"Requests too frequent.","code":"50011"}
BNMBNM 你好 这个是要有三种币才能跑 还是只要有USDT就能跑了
BNMBNM 怎么跑不起
fmzero 教学视频在哪里啊
发明者量化-小小梦 三种币需要。
发明者量化-小小梦 Requests too frequent!
BNMBNM 你好 这个是要有三种币才能跑 还是只要有USDT就能跑了
BNMBNM 交易量可以设置0.03吗 那个0.0007和1//1.02代表的是什么
BNMBNM 好 我再重新跑一下
发明者量化-小小梦 报错信息这里发下, 或者是加FMZ官方群@梦回。
BNMBNM 就是不能跑起来 报错 可以加下你微信吗
发明者量化-小小梦 发下具体问题,或者加FMZ官方微信群 @ 梦回
BNMBNM 就是跑现货 可以加你微信吗
发明者量化-小小梦 这是现货的策略,如果有问题,需要发具体问题。