Skip to main content

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​



NameTypeMandatoryDescription
connectorNameSTRINGYES
connectorTokenSTRINGYES
actionSTRINGYESFor 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.
fixedSTRINGNOAmount to place an order with.

⚠️ fixed will take precedence over percent if both are present.
percentSTRINGNOPercentage 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.
limitSTRINGNOLIMIT price of the order.

⚠️ If it is not sent, will place an order by MARKET price by default
profitSTRINGNOPrice for the take profit order

⚠️ Only for USDβ“ˆ-M Futures actions
lossSTRINGNOPrice for the stop loss order

⚠️ Only for USDβ“ˆ-M Futures actions
logSTRINGNOMessage to print in the log
clientOrderIdSTRINGNOClient Order Id to place or cancel orders.

⚠️ cancel will cancel by this clientOrderId.
delaySecondsNUMBERNODelay this order by seconds
delaySecondsFilterSTRINGNOOnly delay this order by seconds if the log contain this filter word