This nodejs project allows you to execute trades from Tradingview alerts on most crypto exchanges.
- Dependencies updated: ccxt v4.4, express v4.21, jest v29.7, Node.js 20
- New feature:
cancel_ordersorder type to cancel all or specific types of orders - Security improvements: Removed eval() usage, proper async/await handling
- CI/CD: Automated tests and Docker image publishing to GitHub Container Registry
docker pull ghcr.io/tomav/docker-tradingview-trader:latest- copy
config.json.sampletoconfig.jsonand fill in the required informationnameis the alias for the exchange (you can have multiple aliases/accounts on 1 exchange)exchangeis the exchangeidused inccxtlibrarykey&secretrefer to the API keys you have to generate on each exchange
- mount this config file in your docker container, ideally using
docker-compose.yml
Tradingview Webhook URL must be set to https://{your-hostname.tld}/trade
Read the following sections to understand how to fill the Message field.
{
"account": "deribit_main",
"instrument": "BTC-PERPETUAL",
"orders": [
{ "t": "market_buy", "a": 10 },
{ "t": "limit_buy", "a": 10, "p": 35000 },
{ "t": "stop_market_sell", "a": 20, "p": 30000 }
]
}
This example will open a market position, place a limit buy order, and set a stop order.
Note: JSON must be valid in order to be executed. You can check format using JSONLint.
torder typeaamount to buy or sellpprice at which to place orderuupper price for a scaled orderllower price for a scaled ordernnumber of orders for a scaled orderotorder type filter for cancel_orders (optional:limit,stop,market)
| t | a | p | u | l | n | ot |
|---|---|---|---|---|---|---|
| limit_buy | x | x | ||||
| limit_sell | x | x | ||||
| scaled_buy | x | x | x | x | ||
| scaled_sell | x | x | x | x | ||
| market_buy | x | |||||
| market_sell | x | |||||
| stop_market_buy | x | x | ||||
| stop_market_sell | x | x | ||||
| close_position | ||||||
| cancel_orders | x |
The cancel_orders order type allows you to cancel all open orders, optionally filtered by order type.
Use case: Useful for updating stop losses or take profit levels by canceling existing orders before placing new ones.
{
"account": "deribit_main",
"instrument": "BTC-PERPETUAL",
"orders": [
{ "t": "cancel_orders" }
]
}{
"account": "deribit_main",
"instrument": "BTC-PERPETUAL",
"orders": [
{ "t": "cancel_orders", "ot": "stop" }
]
}Cancel existing stop orders and place a new one at an updated price:
{
"account": "deribit_main",
"instrument": "BTC-PERPETUAL",
"orders": [
{ "t": "cancel_orders", "ot": "stop" },
{ "t": "stop_market_sell", "a": 20, "p": 32000 }
]
}Supported values for ot parameter:
limit- cancels only limit ordersstop- cancels only stop ordersmarket- cancels only market orders- omit
otto cancel all open orders for the instrument
curl -X POST -H "Content-Type: application/json" -d '{ "account": "first_account", "instrument": "BTC-PERPETUAL", "orders": [{ "t": "debug", "a": 10, "p": 10 }] }' http://localhost:3000/trade
POST /tradeto place trades from tradingviewGET /exchangesto list supported exhanges, useful to find accxt idGET /exchanges/:exchangeto list available instruments (symbols) for a specific exchange
It depends on the exchange. Example:
- deribit: it's fiat on
BTC-PERPETUAL - bitfinex: it's asset on
BTC/USD
Refere to exchange or ccxt documentation.
