Envie as informações de preço para o telegrama.

Autora:Ervas daninhas, Data: 2018-11-09 15:55:30
Tags:EstudoPushMessage

Estratégias de ensino: A mensagem é automaticamente empurrada para o WeChat quando o preço da moeda está acima ou abaixo do valor definido. O intervalo mínimo de empurrão pode ser definido.

Quando o preço da moeda é maior ou menor do que o valor definido, uma mensagem é automaticamente enviada para o WeChat ou telegrama.


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

Relacionados

Mais.

O que é um limite para o Superman?O que é que o robô está a fazer quando está a funcionar e não consegue contactar os sujeitos?

QuantificaçãoRecomenda-se a inclusão de títulos em inglês para facilitar a leitura de amigos estrangeiros.

MonitorizaçãoA plataforma foi um pouco agressiva quando foi analisada.

Ervas daninhasNão posso fazer o teste de volta, o teste de volta é para aumentar o preço.