- Square
- 数字货币现货打新抢币策略(教学)
数字货币现货打新抢币策略(教学)
Author:
发明者量化-小小梦, Date: 2022-04-20 14:36:55
Tags:
function pendingOrders(ordersNum, price, amount, deltaPrice, deltaAmount) {
var routineOrders = []
var ordersIDs = []
for (var i = 0 ; i < ordersNum ; i++) {
var routine = exchange.Go("Buy", price + i * deltaPrice, amount + i * deltaAmount)
routineOrders.push(routine)
Sleep(ApiReqInterval)
}
for (var i = 0 ; i < routineOrders.length ; i++) {
var orderId = routineOrders[i].wait()
if (orderId) {
ordersIDs.push(orderId)
Log("成功挂单", orderId)
}
}
return ordersIDs
}
function main() {
if (symbol == "null" || pendingPrice == -1 || pendingAmount == -1 || pendingPrice == -1 || deltaPrice == -1 || deltaAmount == -1) {
throw "参数设置错误"
}
exchange.SetCurrency(symbol)
// 屏蔽错误信息
SetErrorFilter("GetDepth")
while (true) {
var msg = ""
var depth = exchange.GetDepth()
if (!depth || (depth.Bids.length == 0 && depth.Asks.length == 0)) {
// 没有深度
msg = "没有深度数据,等待!"
Sleep(500)
} else {
// 获取到深度
Log("并发下单!")
var ordersIDs = pendingOrders(ordersNum, pendingPrice, pendingAmount, deltaPrice, deltaAmount)
while (true) {
var orders = _C(exchange.GetOrders)
if (orders.length == 0) {
Log("当前挂单个数0,停止运行")
return
}
var tbl = {
type: "table",
title: "当前挂单",
cols: ["id", "价格", "数量"],
rows: []
}
_.each(orders, function(order) {
tbl.rows.push([order.Id, order.Price, order.Amount])
})
LogStatus(_D(), "\n`" + JSON.stringify(tbl) + "`")
Sleep(500)
}
}
LogStatus(_D(), msg)
}
}
template: strategy.tpl:40:21: executing "strategy.tpl" at <.api.GetStrategyListByName>: wrong number of args for GetStrategyListByName: want 7 got 6