API Trading
TL;DRβ
π₯Python Demo Scriptβ
β οΈ Note that this only works if the strategy is created with TradingView & API
template that implements on_tradingview_signal
which uses our Python library to place orders based on the received signal (see below)
POST API endpointβ
Post JSON message to https://api.crypto-arsenal.io/trading-signal/webhook
Example Python Scriptβ
import requests
# you can copy URL and PAYLOAD straight from the webhook messages box on the platform (see below)
URL = 'https://crypto-arsenal.io/trading-signal/webhook'
PAYLOAD ={"log":"Buy","action":"buy","percent":"100","connectorName":"YOUR_CONNECTOR","connectorToken":"YOUR_TOKEN"}
# β οΈ start a simulation/live trade to see trades in real time
response = requests.post(URL, json=PAYLOAD)
print(response.text) # ok
Place Order JSON Spec:β
π₯ JSON messages can be generated automatically and copied via the UI - the process is similar to connecting to TradingView (follow up to Step 4)
Step 1: Lets' make sure the mode is QUANTβ
Step 2: Navigate to Strategy and Create a TradingView Strategyβ
Step 3: Pick USDT Future and your currencyβ
Step 4: Copy Webhook URL & Message to TradingView Alert Boxβ
Name | Type | Mandatory | Description |
---|---|---|---|
connectorName | STRING | YES | |
connectorToken | STRING | YES | |
action | STRING | YES | For USDβ-M Futures, used with openLong, closeLong, openShort, or closeShort. For SPOT, used with buy or sell. For both, cancel action will cancel by client order ID (clientOrderId will be a required field) For both, cancellAll will cancel all orders. |
fixed | STRING | NO | Amount to place an order with. β οΈ fixed will take precedence over percent if both are present . |
percent | STRING | NO | Percentage of the available base asset to place an order with. E.g. "90" will be 90% of the base asset. β οΈ fixed will take precedence if both are present. |
limit | STRING | NO | LIMIT price of the order. β οΈ If it is not sent, will place an order by MARKET price by default |
profit | STRING | NO | Price for the take profit order β οΈ Only for USDβ-M Futures actions |
loss | STRING | NO | Price for the stop loss order β οΈ Only for USDβ-M Futures actions |
log | STRING | NO | Message to print in the log |
clientOrderId | STRING | NO | Client Order Id to place or cancel orders.β οΈ cancel will cancel by this clientOrderId . |
delaySeconds | NUMBER | NO | Delay this order by seconds |
delaySecondsFilter | STRING | NO | Only delay this order by seconds if the log contain this filter word |