Kernel: Python 3
In this example, we will build a Telegram bot that sends a signal once any Bollinger Band has been crossed. We will periodically query for the latest OHLCV data of the selected cryptocurrencies and append this data to our data pool. Additionally to receiving signals, any Telegram user can join the group and ask the bot to provide him with the current information. If the price change is higher than some number of standard deviations from the mean, while crossing the band, the bot sends a funny GIF.
In [1]:
In [2]:
In [3]:
In [4]:
Out[4]:
2021-03-23 17:07:34.598000+00:00 - 2021-03-23 18:07:00+00:00: : 1it [00:00, 1.91it/s]
2021-03-23 17:07:36.639000+00:00 - 2021-03-23 18:07:00+00:00: : 1it [00:00, 2.26it/s]
2021-03-23 17:07:38.885000+00:00 - 2021-03-23 18:07:00+00:00: : 1it [00:00, 1.80it/s]
DatetimeIndex(['2021-03-23 17:08:00+00:00', '2021-03-23 17:09:00+00:00',
'2021-03-23 17:10:00+00:00', '2021-03-23 17:11:00+00:00',
'2021-03-23 17:12:00+00:00', '2021-03-23 17:13:00+00:00',
'2021-03-23 17:14:00+00:00', '2021-03-23 17:15:00+00:00',
'2021-03-23 17:16:00+00:00', '2021-03-23 17:17:00+00:00',
'2021-03-23 17:18:00+00:00', '2021-03-23 17:19:00+00:00',
'2021-03-23 17:20:00+00:00', '2021-03-23 17:21:00+00:00',
'2021-03-23 17:22:00+00:00', '2021-03-23 17:23:00+00:00',
'2021-03-23 17:24:00+00:00', '2021-03-23 17:25:00+00:00',
'2021-03-23 17:26:00+00:00', '2021-03-23 17:27:00+00:00',
'2021-03-23 17:28:00+00:00', '2021-03-23 17:29:00+00:00',
'2021-03-23 17:30:00+00:00', '2021-03-23 17:31:00+00:00',
'2021-03-23 17:32:00+00:00', '2021-03-23 17:33:00+00:00',
'2021-03-23 17:34:00+00:00', '2021-03-23 17:35:00+00:00',
'2021-03-23 17:36:00+00:00', '2021-03-23 17:37:00+00:00',
'2021-03-23 17:38:00+00:00', '2021-03-23 17:39:00+00:00',
'2021-03-23 17:40:00+00:00', '2021-03-23 17:41:00+00:00',
'2021-03-23 17:42:00+00:00', '2021-03-23 17:43:00+00:00',
'2021-03-23 17:44:00+00:00', '2021-03-23 17:45:00+00:00',
'2021-03-23 17:46:00+00:00', '2021-03-23 17:47:00+00:00',
'2021-03-23 17:48:00+00:00', '2021-03-23 17:49:00+00:00',
'2021-03-23 17:50:00+00:00', '2021-03-23 17:51:00+00:00',
'2021-03-23 17:52:00+00:00', '2021-03-23 17:53:00+00:00',
'2021-03-23 17:54:00+00:00', '2021-03-23 17:55:00+00:00',
'2021-03-23 17:56:00+00:00', '2021-03-23 17:57:00+00:00',
'2021-03-23 17:58:00+00:00', '2021-03-23 17:59:00+00:00',
'2021-03-23 18:00:00+00:00', '2021-03-23 18:01:00+00:00',
'2021-03-23 18:02:00+00:00', '2021-03-23 18:03:00+00:00',
'2021-03-23 18:04:00+00:00', '2021-03-23 18:05:00+00:00',
'2021-03-23 18:06:00+00:00', '2021-03-23 18:07:00+00:00'],
dtype='datetime64[ns, UTC]', name='Open time', freq='T')
In [5]:
In [6]:
In [7]:
Out[7]:
2021-03-23 19:07:41,319 - vectorbt.utils.messaging - INFO - Initializing bot
2021-03-23 19:07:41,325 - vectorbt.utils.messaging - INFO - Loaded chat ids [447924619]
2021-03-23 19:07:41,444 - vectorbt.utils.messaging - INFO - Running bot vectorbt_bot
2021-03-23 19:07:41,461 - apscheduler.scheduler - INFO - Scheduler started
2021-03-23 19:07:41,629 - vectorbt.utils.messaging - INFO - 447924619 - Bot: "I'm back online!"
In [8]:
In [9]:
Out[9]:
2021-03-23 19:07:41,670 - vectorbt.utils.schedule - INFO - Starting schedule manager with jobs [Every 60 seconds do update() (last run: [never], next run: 2021-03-23 19:08:41)]
2021-03-23 19:08:47,689 - vectorbt.data.updater - INFO - Updated data has 61 rows from 2021-03-23 17:08:00+00:00 to 2021-03-23 18:08:00+00:00
2021-03-23 19:08:47,822 - numexpr.utils - INFO - NumExpr defaulting to 4 threads.
2021-03-23 19:09:15,117 - vectorbt.utils.messaging - INFO - 447924619 - User: "/info BTC/USDT"
2021-03-23 19:09:15,281 - vectorbt.utils.messaging - INFO - 447924619 - Bot: "23 Mar 2021 18:08:47 +0000:
BTC/USDT (0.08%, 55638.07, -1.06)"
2021-03-23 19:09:54,766 - vectorbt.data.updater - INFO - Updated data has 62 rows from 2021-03-23 17:08:00+00:00 to 2021-03-23 18:09:00+00:00
2021-03-23 19:10:08,781 - vectorbt.utils.schedule - INFO - Stopping schedule manager
In [10]:
Out[10]:
2021-03-23 19:10:08,791 - vectorbt.utils.messaging - INFO - Stopping bot
2021-03-23 19:10:08,793 - apscheduler.scheduler - INFO - Scheduler has been shut down
In [ ]: