- বর্গক্ষেত্র
- বিএনএ-র নতুন লেনদেনের উপর নজরদারি
বিএনএ-র নতুন লেনদেনের উপর নজরদারি
লেখক:
চাওঝাং, তারিখঃ ২০২৪-০১-২৩ ১৬ঃ০৭ঃ২৮
ট্যাগঃ
let SaveSymbol = _G("SaveSymbol") || [];
//定义一个变量,保存已经通知过的项目
var Notified = _G("Notified") || [];
function TimeBetween(startDate, endDate) {
let delta = Math.abs(endDate - startDate) / 1000;
const isNegative = startDate > endDate ? -1 : 1;
return [
["days", 24 * 60 * 60],
["hours", 60 * 60],
["minutes", 60],
["seconds", 1],
].reduce((acc, [key, value]) => ((acc[key] = Math.floor(delta / value) * isNegative), (delta -= acc[key] * isNegative * value), acc), {});
}
function getLaunchpad() {
var Launchpad = {
coming: {}, //即将开始的项目
tracking: {}, //正在进行的项目
};
let data = HttpQuery("https://launchpad.binance.com/bapi/lending/v1/friendly/launchpool/project/listV3?pageIndex=1&pageSize=5");
if (!data) {
Log("获取数据失败");
return false;
}
try {
data = JSON.parse(data);
} catch (e) {
Log("解析JSON数据失败: ", e.message, "原始数据: ", data);
return false;
}
// return data
if (!data.data) {
Log("Data错误", data)
return false;
}
let tracking = data.data.tracking;
let coming = data.data.coming;
for (let i = 0; i < tracking.length; i++) {
let item = tracking[i];
if (!Launchpad.tracking[item.rebateCoin]) {
Launchpad.tracking[item.rebateCoin] = item;
//如果没有通知过,则通知
// if (Notified.indexOf(item.rebateCoin) == -1) {
// Notified.push(item.rebateCoin);
// Log("发现挖矿中新项目", item.rebateCoin, item.detailAbstract);
// }
// Log("挖矿中新项目", item.rebateCoin, item.detailAbstract);
}
}
if (coming.length > 0) {
// Log("即将开始的项目", coming.length, coming);
for (let i = 0; i < coming.length; i++) {
let item = coming[i];
if (!Launchpad.coming[item.rebateCoin]) {
Launchpad.coming[item.rebateCoin] = item;
//如果没有通知过,则通知
if (Notified.indexOf(item.rebateCoin) == -1) {
Notified.push(item.rebateCoin);
Log("发现即将开始新项目", item.rebateCoin, item.detailAbstract, "@");
}
// Log("即将开始新项目", item.rebateCoin, item.detailAbstract);
}
}
}
return Launchpad;
}
function onTick() {
// 获取交易所信息
let exchangeInfo = exchange.IO("api", "GET", "/fapi/v1/exchangeInfo");
let symbolList = exchangeInfo.symbols;
// 初始化交易对信息表格
let symbolTable = {
type: "table",
title: "币种信息",
cols: ["编号", "币种", "交易对", "交割日期", "上线日期"],
rows: [],
};
let trackingTable = {
type: "table",
title: "挖矿中",
cols: ["币种", "总奖励", "挖币周期", "开始时间", "结束时间", "剩余时间", "状态"],
rows: [],
};
let comingTable = {
type: "table",
title: "即将开始",
cols: ["币种", "总奖励", "挖币周期", "开始时间", "结束时间", "上线倒计时"],
rows: [],
};
let Launchpad = getLaunchpad();
for (let key in Launchpad.tracking) {
let item = Launchpad.tracking[key];
let row = [
item.rebateCoin, //币种
_N(parseInt(item.rebateTotalAmount), 0),
item.duration + " 天",
_D(parseInt(item.investStartTime)), //格式化为北京时间
_D(parseInt(item.mineEndTime)),
//剩余时间倒计时,计算方式为:结束时间-当前时间,结束时间是毫秒时间戳
JSON.stringify(TimeBetween(Date.now(), item.mineEndTime)),
item.status,
];
trackingTable.rows.push(row);
}
for (let key in Launchpad.coming) {
let item = Launchpad.coming[key];
let row = [
item.rebateCoin, //币种
_N(parseInt(item.rebateTotalAmount), 0),
item.duration + " 天",
_D(parseInt(item.investStartTime)), //格式化为北京时间
_D(parseInt(item.mineEndTime)),
//剩余时间倒计时,计算方式为:结束时间-当前时间,结束时间是毫秒时间戳
Math.floor((item.investStartTime - Date.now()) / 1000 / 3600) + " 小时",
];
comingTable.rows.push(row);
}
let isNewRun = SaveSymbol.length === 0;
let symbolCount = 0;
// 遍历交易对列表并筛选
symbolList.forEach((symbol) => {
// 筛选条件:交易中,永续合约,计价货币为USDT,非指数类型
if (symbol.status === "TRADING" && symbol.contractType === "PERPETUAL" && symbol.quoteAsset === "USDT" && symbol.underlyingType !== "INDEX") {
// 向表格中添加符合条件的交易对
symbolTable.rows.unshift([
++symbolCount, // 编号
symbol.baseAsset,
symbol.symbol,
_D(symbol.deliveryDate),
_D(symbol.onboardDate),
]);
// 检查并记录新的交易对
if (!SaveSymbol.includes(symbol.symbol)) {
SaveSymbol.push(symbol.symbol);
if (!isNewRun) {
Log("新增交易对", symbol.symbol, "@");
}
}
}
});
// 记录交易对信息表格
LogStatus("`" + JSON.stringify([trackingTable, comingTable, symbolTable]) + "`");
}
function main() {
while (true) {
try {
onTick();
Sleep(1000 * 60 * 1);
} catch (e) {
Log("e.name:", e.name, "e.stack:", e.stack, "e.message:", e.message)
}
}
}
function saveData() {
_G("SaveSymbol", SaveSymbol);
_G("Notified", Notified);
}
function onexit() {
saveData();
}
function onerror() {
saveData();
}
আরো