Đưa thông tin về giá lên Telegram

Tác giả:Cỏ nhỏ, Ngày: 2018-11-09 15:55:30
Tags:Nghiên cứuPushMessage

Chiến lược dạy: Khi giá đồng xu cao hơn hoặc thấp hơn mức thiết lập, một tin nhắn sẽ tự động được đẩy đến WeChat.

Khi giá của đồng tiền cao hơn hoặc thấp hơn giá trị đặt, một tin nhắn sẽ tự động được đẩy đến WeChat hoặc Telegram.


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

Có liên quan

Thêm nữa

Làm ra một ngưỡng cửa cho SupermanTại sao robot không thể liên lạc với người được kiểm tra khi nó hoạt động?

Khả năng định lượngĐề nghị thêm các tiêu đề tiếng Anh để bạn bè nước ngoài dễ dàng đọc

giám sátKhi xem lại, bạn đã chọn nền tảng nào?

Cỏ nhỏKhông thể kiểm tra lại, kiểm tra lại để tăng giá.