가격 정보를 텔레그램으로 보내

저자:초목, 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
    }
}

관련

더 많은

슈퍼맨의 문왜 로봇이 탐사 대상자와 연결할 수 없는지?

노력하는 양성외국인들이 쉽게 읽을 수 있도록 영어 제목을 추가하는 것이 좋습니다.

감시이 사이트는 다른 사이트와 비교해 볼 수 있습니다.

초목이럴 수 없어, 이럴 수 없어, 이럴 수 없어, 이럴 수 없어.