Skip to main content

API Trading

TL;DR

🔥Python Demo Script

⚠️ 注意,這僅適用於使用TradingView & API模板創建的策略。該模板應實現on_tradingview_signal函數,該函數使用我們的[Python庫](https://docs.crypto-arsenal.io/docs/developer/get-started/python/hello-world)根據接收到的信號下訂單。請參考下面的示例。

POST API 端點

發送 JSON 訊息至 https://api.crypto-arsenal.io/trading-signal/webhook

Python 腳本範例

import requests

# 您可以直接從平台上的 Webhook 訊息方塊中複製 URL 和 PAYLOAD(參見下方)
URL = 'https://crypto-arsenal.io/trading-signal/webhook'
PAYLOAD ={"log":"Buy","action":"buy","percent":"100","connectorName":"YOUR_CONNECTOR","connectorToken":"YOUR_TOKEN"}

# ⚠️ 開始進行模擬/實盤交易以即時查看交易
response = requests.post(URL, json=PAYLOAD)
print(response.text) # ok

下單 JSON 規格:

🔥 JSON messages can be generated automatically and copied via the UI - the process is similar to connecting to TradingView (follow up to Step 4)

🔥 JSON 訊息可以透過使用者介面自動生成並複製 - 此過程類似於連接到 TradingView (按照第 4 步進行)的步驟

步驟 1:確保模式設置為 QUANT(量化模式)

步驟 2:前往策略並創建一個 TradingView 策略

步驟 3:選擇 USDT 期貨和您的貨幣

步驟 4:將 Webhook URL 和訊息複製到 TradingView 的警示框中



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