বিটকয়েনের দাম নির্ধারণ করুন এবং এটি WeChat-এ পুশ করুন (টিউটোরিয়াল)

Study PushMessage
সৃষ্টির তারিখ: 2018-11-09 15:55:30 অবশেষে সংশোধন করুন: 2019-07-03 16:18:51
অনুলিপি: 946 ক্লিকের সংখ্যা: 7200
3
ফোকাস
1444
অনুসারী

শিক্ষার কৌশলঃ যখন মুদ্রার মূল্য সেট করা মানের চেয়ে বেশি বা কম হয়, তখন স্বয়ংক্রিয়ভাবে একটি বার্তা WeChat এ পাঠানো হয়। সর্বনিম্ন পাঠানোর ব্যবধান সেট করা যেতে পারে।

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