Push the price information to telegram
Teaching Strategies: When the token price is above or below the set value, a message is automatically pushed to WeChat. You can set a minimum push interval. When the price of the currency is higher or lower than the…
Teaching Strategies: When the token price is above or below the set value, a message is automatically pushed to WeChat. You can set a minimum push interval.
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.
Parameters
| Name | Default | What it controls |
|---|---|---|
| Currency | BTC_USDT | trading pair |
| UpPrice | 5500 | when price is higher than |
| LowPrice | 5000 | when price is lower than |
| Interval | 10 | interval |
Source JavaScript
/*
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
}
}Published by 小草 on the FMZ strategy square · last modified 2019-07-03. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.
Build this with AgenKit
A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Push-the-price-information-to-telegram.md- npx agenkit install engineering-kit in your project
- Paste the command into your agent and approve each phase
- Get tests, backtest, risk controls and a paper-trading switch
Understand it first
Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.