设定比特币价格并微信推送(教学)

教学 推送
创建日期: 2018-11-09 15:55:30 最后修改: 2019-07-03 16:18:51
复制: 952 点击次数: 6645
3
关注
1237
关注者

教学策略: 当币价高于或低于设定值后,自动推送一条消息到微信。可设定最小推送间隔。

When the price of the currency is higher or lower than the set value, a message is automatically pushed to WeChat or telegram. The minimum push interval can be set.

策略源码
/*
This stragegy will sent a message to your telegram when the price is higher or lower than
the set price.
All stragegy must has a main function as the entrance.
*/
function main() {
     //change symbol,will cover the default exchange which was set when start a bot.Currency is a strategy arguments
    exchange.IO("currency", Currency)   
    var lastPushTime = 0    //the variable of last push timestamp.
    while(true){    //run a infinite loop, which is the basic structure
        var ticker = _C(exchange.GetTicker) // for information about GetTicker, check on https://fmz-docs.readthedocs.io/en/latest/code_Instruction/Market%20API.html#getticker
        if(ticker.Last > UpPrice || ticker.Last < LowPrice){    //ticker.Last represents the last deal price
            if(Date.now() - lastPushTime > 300*1000){    //only push once in 5 mins, Date.now() return ms.
                lastPushTime = Date.now()    //update lastPushTime
                Log(Currency, 'Price is: ', ticker.Last, '@')    //Log the price on the bot's page and sent the message. '@' in the end means push message
            }
        }
        Log(Currency, 'Price is: ', ticker.Last) //just log the price
        Sleep(Interval*1000)    //check the last price again after Interval seconds
    }
}
相关推荐
更多内容
全部留言
avatar of 做了个超人门缝
做了个超人门缝
大佬为什么机器人运行时显示无法与被测者建立联系啊
2021-04-13 12:35:47
avatar of 韬奋量化
韬奋量化
建议增加英文标题,方便外国朋友阅读
2021-02-01 09:51:59
avatar of moniteryao
moniteryao
回测时,平台怎么选择,小白有点懵逼了^^
2020-04-22 20:56:39
avatar of 小草
小草
不能回测,回测要啥价格推送啊
2020-04-22 23:07:19