Webhook crypto trader. Intended to be used along with TradingView and any crypto exchange.
It receives a webhook and places a Limit Order on the cryptocurrency exchange you configure. Only tested with Binance so far.
You can post it a BUY
or SELL
to the webhook like this. Example:
{
"exchange_id": "XXXXXXXXXX",
"symbol": "BTC/USDT",
"order_type": "LIMIT",
"side": "BUY",
"price": "11220",
"quantity": 0.002
}
If you don't set quantity
, you might want to set amount_pc
which is a calculated percentage from your wallet for the base or quote currency. Example:
{
"exchange_id": "XXXXXXXXXX",
"symbol": "BTC/USDT",
"order_type": "LIMIT",
"side": "BUY",
"price": "11220",
"amount_pc": 80
}
In this example, the BUY
operation will take 80% of my USDT
Spot wallet to buy BTC
at the specified price above.
The below example uses your entire USDT
wallet to buy BTC
at the market price. These are the minimum required fields for it to work.
{
"exchange_id": "wht-binance",
"symbol": "BTC/USDT",
"order_type": "MARKET",
"side": "BUY"
}
Please note the following:
- You can have any number of exchanges set up in
wht_config.py
, but theid
field is the one you'll be calling from the webhook asexchange_id
. - The input values from the JSON get normalized, so if you mix uppercase with lowercase or mix a type string value with a type float, don't worry. This rule doesn't apply to the
exchange_id
field. - If you don't set the
price
field, it will just retrieve the most recent close price for thesymbol
specified. - If you don't set the
stop_price
field, it will take the value from the previously setprice
field. - Valid
order_type
values are:market
,limit
andstop_limit
. Any otherorder_type
will just get ignored. - Setting
quantity
andamount_pc
at the same time will makequantity
overrideamount_pc
. - If you don't set either
quantity
oramount_pc
,amount_pc
will take the default value of 100% from your Spot wallet.
- Navigate to the cloned repository directory.
- Create a virtual environment (e.g.
$ python -m venv venv
). - Activate the virtual environment (e.g.
$ source venv/bin/activate
). - Install package requirements (e.g.
(venv) $ pip install -r requirements.txt
). - Duplicate file
wht_config-sample.py
intowht_config.py
editing it with your custom values. - #TODO: Write Flask instructions here.
Developed using Flask
and ccxt
.