RogerThat
RogerThat is a standalone python web server designed to receive TradingView alerts (or similar) and forward them to Hummingbot.
TradingView is a widely used market market tracker that allows users to create, share and use custom strategies but is quite limited in how it can be "plugged in" to other services. It does however allow the creation of "Alerts" which can send data to a webhook (public URL).
RogerThat facilitates the collection and forwarding of these TradingView Alerts to Hummingbot via the Remote Command Executor module, which listens to RogerThat via a websocket for received commands and updates.
Whilst it's purpose is to bridge TradingView and Hummingbot, it can work as a gateway / bridge between any service that sends data via Webhooks (to a public URL) and serve / route them to multiple Hummingbot instances.
Menu
Docker
Installation
Download and extract this whole repository.
Linux/Mac
wget https://github.com/TheHolyRoger/RogerThat/archive/refs/heads/master.zip
unzip master.zip
Change directory:
cd RogerThat-master
scripts
directory
Windows
Manually download and extract the repository zip file.
Open up Windows CMD and switch directory to the extracted zip folder.
scripts
directory
Then run the following commands to launch the docker image:
Linux/Mac
./scripts/start_docker.sh
Windows
Use git bash only for git
commands, do not run these scripts from git bash as they will not work.
scripts\start_docker.bat
Running
Linux/Mac
./scripts/start_docker.sh
OR as daemon (in background):
./scripts/start_docker.sh -d
Windows
scripts\start_docker.bat
OR as daemon (in background):
scripts\start_docker.bat -d
Upon successful launch, navigating to http://localhost/
in your browser (or your public domain) will show a 404 not found page.
Stopping
Run the following command to stop RogerThat:
docker-compose stop
Configuration
You can use the config setup script via docker by running the following commands:
Linux/Mac
scripts/setup_config.sh --help
scripts/setup_config.sh
.
Windows
scripts\setup_config.bat --help
scripts\setup_config.bat
.
Public access
Expand ...
Since TradingView requires a publicly accessible URL for webhook alerts, you'll need to use your own domain name, or your public IP address.
You'll also need to open up (and forward) port 80 (or 443 if using HTTPS) in your firewall/router to the machine running RogerThat.
It is recommended to use Cloudflare with HTTPS to hide your IP address.
Change Hostname
Expand ...
Change the hostname to listen on for the public TradingView webhook with the following commands:
(Do not use a full URL here, the hostname is the part of the URL after https:// and before any other slashes)
Linux/Mac
scripts/setup_config.sh --hostname yourhostname.com
scripts/setup_config.sh --hostname 1.2.3.4
Windows
scripts\setup_config.bat --hostname yourhostname.com
scripts\setup_config.bat --hostname 1.2.3.4
If using your own domain name, it is recommended to use a long and not obvious subdomain as the hostname eg: thereisnotraderhere.mydomain.com
.
Cloudflare (Recommended)
Expand ...
It is recommended to use Cloudflare to proxy and mask your IP address for public operation.
You can use services like DNS-o-matic with your home dynamic IP to keep it updated and proxied with Cloudflare.
Dynamic Domain Names (Optional)
Expand ...
Services you can use for dynamic DNS with a non-static public IP address are:
- DNS-O-matic (Recommended, with Cloudflare)
- No-IP
- Afraid
- Duck DNS
- Dynu
Enabling HTTPS (Recommended, required for Cloudflare)
Expand ...
To setup (LetsEncrypt run the following commands.
Linux/Mac
scripts/generate_cert_letsencrypt.sh
Windows
scripts/generate_cert_letsencrypt.bat
Or run the following command to generate a self-signed key pair:
Linux/Mac
scripts/generate_cert_self_signed.sh
Windows
scripts\generate_cert_self_signed.bat
After enabling HTTPS you can now forward port 443, close port 80 and start RogerThat.
Usage
TradingView Webhooks
Set up your TradingView alert URL like this:
http://<public-ip-or-domain-name>/api/tv_webhook/?api_key=<tradingview-apikey>
Where <public-ip-or-domain-name>
is your domain name or public IP address and <tradingview-apikey>
is the generated api key found in web_server.yml
under api_allowed_keys_tv
.
JSON Data for TradingView alerts.
Alerts must be formatted as JSON, the only required parameter is name
.
(this parameter key name is configurable in configs/tradingview.yml
)
The name
key or one of the tradingview_descriptor_fields
must be present in the JSON data to be accepted, but the value can be null or empty. This is transmitted to Hummingbot as event_descriptor
Using an empty value for name
ignores Hummingbot's Remote Command Executor routing names.
Example alert data:
Simple Start command
{
"name": "hummingbot_instance_1",
"command": "start",
}
Simple Stop command
{
"name": "hummingbot_instance_1",
"command": "stop",
}
Alert with all fields using Pine variables
{
"name": "hummingbot_instance_1",
"timestamp": "{{timenow}}",
"exchange": "{{exchange}}",
"symbol": "{{ticker}}",
"interval": "{{interval}}",
"price": "{{close}}",
"volume": "{{volume}}",
"command": "{{strategy.market_position}}",
"inventory": "{{strategy.order.comment}}"
}
Hummingbot Connection
You can connect the Hummingbot Remote Command Executor to the RogerThat websocket with this URL:
ws://localhost:10073/wss
Example Config
Example Config ...
Use something like the following config to connect RogerThat to Hummingbot via the Remote Command Executor.
This config is found inside your main hummingbot folder then conf\conf_global.yml
# Remote commands
remote_commands_enabled: true
remote_commands_api_key: a9ba4b61-6f6d-41cf-85c3-7cfdfcbea0f3
remote_commands_ws_url: ws://localhost:10073/wss
# Specify a routing name for use with multiple Hummingbot instances
remote_commands_routing_name: hummingbot_instance_1
# Recommended to keep this on so no events are missed in the case of a network drop out.
remote_commands_ignore_first_event: true
# Whether to disable console command processing for remote command events.
# Best to disable this if using in custom scripts or strategies
remote_commands_disable_console_commands: false
# You can specify how to translate received commands to Hummingbot commands here
# eg.
# remote_commands_translate_commands:
# long: start
# short: stop
remote_commands_translate_commands:
long: start
short: stop
Filtering events
Expand ...
To filter events received based on the event_descriptor
, change your websockets URL to:
ws://localhost:10073/wss/<event-descriptor>
Where event-descriptor
matches the event_descriptor
or name value of the events you wish to receive.
Command Shortcuts
Expand ...
Command shortcuts can be defined in Hummingbot's conf_global.yml
, for more information see here: https://docs.hummingbot.io/operation/config-files/#create-command-shortcuts
Test Connection
Test Connection ...
You can enable and disable websockets authentication in the config with these commands. (You must disable websockets authentication for the in-browser test to work.)
Linux/Mac
scripts/setup_config.sh --enable-websocket-auth
scripts/setup_config.sh --disable-websocket-auth
Windows
scripts\setup_config.bat --enable-websocket-auth
scripts\setup_config.bat --disable-websocket-auth
Test the websocket feed in your browser with this js code:
var ws = new WebSocket('ws://localhost:10073/wss');
ws.onmessage = function (event) {
console.log(event.data);
};
Or run the python test listener (requires source installation steps but can authenticate):
python tests/test_websocket.py
Or test the REST url here:
http://localhost:10073/api/hbot/?api_key=<hummingbot-apikey>
Where <hummingbot-apikey>
is the generated api key found in web_server.yml
under api_allowed_keys_hbot
.
Source Installation (ADVANCED!!!)
Steps to install from **source** instead of docker ...
Installation
Install Miniconda (or Anaconda)
Clone this repository.
git clone git@github.com:TheHolyRoger/RogerThat.git
Change directory:
cd RogerThat
Set up and activate the environment with the following command.
Linux/Mac
./scripts/update_environment.sh
Windows
scripts\update_environment.bat
Run the following command to generate the default configs:
scripts/setup.py -s
Edit the configs in ./configs
or via the setup.py
command.
Running
From source:
bin/start_rogerthat.py