Control the bot remotely
A planar strategy can be controlled with telegram.
Requirements
Create a new telegram bot:
- Initiate a chat with
BotFather
- send the
/start
command - follow the prompts
Get a chat_id
:
- Initiate a chat with
userinfobot
- send the name of the bot you created, e.g.
@mynewbot
- use the
Id
in the response as yourchat_id
Once you have the token and the id, save them either:
- in the strategy config file as keys
tgtoken
andtgchat_id
- after loading the strategy object in the strategy attributes (same keys (
Symbol
) as config) - as env vars
TELEGRAM_BOT_TOKEN
andTELEGRAM_BOT_CHAT_ID
.
The telegram client
Start listening for commands:
using Planar
Planar.Remote.tgstart!(s) # where s is your strategy object
Now you can start a chat with your telegram bot. The supported commands are:
start
: start the strategystop
: stop the strategystatus
: show summarydaily
: rolling 1d historyweekly
: rolling 7d historymonthly
: rolling 30d historybalance
: show current balanceassets
: trades history by assetconfig
: show toml configlogs
: upload most recent logsset
: set a strategy attributeget
: get a strategy attribute
To manually stop the telegram bot:
Planar.Remote.tgstop!(s) # where s is your strategy object
To prevent the bot from talking with strangers you can set a specific username that the bot is allowed to talk to by setting the tgusername
(Symbol
) key to your desired telegram username.