価格情報をテレグラムに送る

作者: リン・ハーン小草, 日時: 2018-11-09 15:55:30
タグ:勉強プッシュメッセージ

教師は教育に力を入れます コイン価格が設定値以上または以下になると,WeChatに自動的にメッセージを送信します.最小推送間隔を設定できます.

通貨の価格が設定値より高くまたは低くなった場合,メッセージは自動的にWeChatまたは電信にプッシュされます.最小プッシュ間隔を設定できます.


/*
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
    }
}

関連性

もっと

スーパーマンへの門戸を作りましたなぜロボットが動作しているときに テスト対象と連絡を取れないのか?

努力して量化外国人の友人が読むように英語の字幕を追加することをお勧めします.

監視するレビューでは,プラットフォームの選択について,小白は少し頑固です^^

小草価格を推し進めるために,再測定できません.