Quick Start
Get Started with Sending Signal
https://api.crypto-arsenal.io/trading-signal/webhook
- Python
- JSON
- NodeJS
- Java
- Golang
- Rust
- C++
- C
- PHP
import requests
URL = 'https://api.crypto-arsenal.io/trading-signal/webhook'
PAYLOAD = {
"connectorName": "FIND_ME_ON_CA_STRATEGY_CONNECTOR",
"connectorToken": "FIND_ME_ON_CA_STRATEGY_CONNECTOR",
"log": "OPEN LONG on BTC/USDT at $1200",
# ...whatever you would like to send to us :)
}
response = requests.post(URL, json=PAYLOAD)
{
connectorName: "FIND_ME_ON_CA_STRATEGY_CONNECTOR",
connectorToken: "FIND_ME_ON_CA_STRATEGY_CONNECTOR",
log: "OPEN LONG on BTC/USDT at $1200",
// ...whatever you would like to send to us :)
}
npm install axios
const axios = require("axios");
const URL = "https://api.crypto-arsenal.io/trading-signal/webhook";
const PAYLOAD = {
connectorName: "FIND_ME_ON_CA_STRATEGY_CONNECTOR",
connectorToken: "FIND_ME_ON_CA_STRATEGY_CONNECTOR",
log: "OPEN LONG on BTC/USDT at $1200",
// Add any other properties you wish to send
};
axios
.post(URL, PAYLOAD)
.then((response) => {
console.log("Response:", response.data);
})
.catch((error) => {
console.error("Error:", error);
});
<!-- Add this to your pom.xml -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20210307</version>
</dependency>
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.http.HttpRequest.BodyPublishers;
import java.net.http.HttpResponse.BodyHandlers;
import org.json.JSONObject;
public class WebhookClient {
public static void main(String[] args) {
String url = "https://api.crypto-arsenal.io/trading-signal/webhook";
HttpClient client = HttpClient.newHttpClient();
// Create JSON payload
JSONObject payload = new JSONObject();
payload.put("connectorName", "FIND_ME_ON_CA_STRATEGY_CONNECTOR");
payload.put("connectorToken", "FIND_ME_ON_CA_STRATEGY_CONNECTOR");
payload.put("log", "OPEN LONG on BTC/USDT at $1200");
// Add any other properties you wish to send
// Create request
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Content-Type", "application/json")
.POST(BodyPublishers.ofString(payload.toString()))
.build();
// Send request and get response
try {
HttpResponse<String> response = client.send(request, BodyHandlers.ofString());
System.out.println("Response status code: " + response.statusCode());
System.out.println("Response body: " + response.body());
} catch (Exception e) {
e.printStackTrace();
}
}
}
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
func main() {
url := "https://api.crypto-arsenal.io/trading-signal/webhook"
payload := map[string]interface{}{
"connectorName": "FIND_ME_ON_CA_STRATEGY_CONNECTOR",
"connectorToken": "FIND_ME_ON_CA_STRATEGY_CONNECTOR",
"log": "OPEN LONG on BTC/USDT at $1200",
// Add any other properties you wish to send
}
jsonData, err := json.Marshal(payload)
if err != nil {
fmt.Println("Error encoding JSON:", err)
return
}
resp, err := http.Post(url, "application/json", bytes.NewBuffer(jsonData))
if err != nil {
fmt.Println("Error making POST request:", err)
return
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println("Error reading response body:", err)
return
}
fmt.Println("Response:", string(body))
}
[package]
name = "your-strategy"
version = "0.1.0"
[dependencies]
reqwest = "0.11.10"
serde_json = "1.1.10"
tokio = "1.21.1"
use reqwest::Client;
use serde_json::json;
use tokio;
#[tokio::main]
async fn main() {
let url = "https://api.crypto-arsenal.io/trading-signal/webhook";
let client = Client::new();
let payload = json!({
"connectorName": "FIND_ME_ON_CA_STRATEGY_CONNECTOR",
"connectorToken": "FIND_ME_ON_CA_STRATEGY_CONNECTOR",
"log": "OPEN LONG on BTC/USDT at $1200",
// Add any other properties you wish to send
});
match client.post(url)
.json(&payload)
.send()
.await {
Ok(response) => {
if response.status().is_success() {
match response.text().await {
Ok(text) => println!("Response: {}", text),
Err(err) => eprintln!("Failed to read response text: {}", err),
}
} else {
eprintln!("Received non-success status code: {}", response.status());
}
},
Err(err) => eprintln!("Failed to send request: {}", err),
}
}
sudo apt-get install libcurl4-openssl-dev
#include <iostream>
#include <string>
#include <curl/curl.h>
int main() {
CURL *curl;
CURLcode res;
std::string data = R"({"connectorName": "FIND_ME_ON_CA_STRATEGY_CONNECTOR", "connectorToken": "FIND_ME_ON_CA_STRATEGY_CONNECTOR", "log": "OPEN LONG on BTC/USDT at $1200"})";
curl_global_init(CURL_GLOBAL_ALL);
curl = curl_easy_init();
if(curl) {
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Content-Type: application/json");
curl_easy_setopt(curl, CURLOPT_URL, "https://api.crypto-arsenal.io/trading-signal/webhook");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data.c_str());
res = curl_easy_perform(curl);
if(res != CURLE_OK) {
std::cerr << "curl_easy_perform() failed: " << curl_easy_strerror(res) << std::endl;
}
curl_easy_cleanup(curl);
curl_slist_free_all(headers);
}
curl_global_cleanup();
return 0;
}
g++ -o post_request post_request.cpp -lcurl
./post_request
sudo apt-get install libcurl4-openssl-dev
#include <stdio.h>
#include <string.h>
#include <curl/curl.h>
int main(void) {
CURL *curl;
CURLcode res;
// JSON data to send
char *data = "{\"connectorName\": \"FIND_ME_ON_CA_STRATEGY_CONNECTOR\", \"connectorToken\": \"FIND_ME_ON_CA_STRATEGY_CONNECTOR\", \"log\": \"OPEN LONG on BTC/USDT at $1200\"}";
// Initialize a curl session
curl = curl_easy_init();
if(curl) {
// Set the URL that receives the POST data
curl_easy_setopt(curl, CURLOPT_URL, "https://api.crypto-arsenal.io/trading-signal/webhook");
// Set the content type header
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Content-Type: application/json");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
// Set the POST data
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
// Perform the request, res will get the return code
res = curl_easy_perform(curl);
// Check for errors
if(res != CURLE_OK)
fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
// Cleanup
curl_easy_cleanup(curl);
curl_slist_free_all(headers);
}
return 0;
}
gcc -o post_request post_request.c -lcurl
./post_request
<?php
$url = 'https://api.crypto-arsenal.io/trading-signal/webhook';
$payload = array(
"connectorName" => "FIND_ME_ON_CA_STRATEGY_CONNECTOR",
"connectorToken" => "FIND_ME_ON_CA_STRATEGY_CONNECTOR",
"log" => "OPEN LONG on BTC/USDT at $1200",
// Add any other properties you wish to send
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
$response = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
} else {
echo 'Response:' . $response;
}
curl_close($ch);
You can send us custom JSON payload and process them in the Python editor
Common Q&A
Q: What is the webhook URL?
The webhook URL is https://api.crypto-arsenal.io/trading-signal/webhook
. You will need to send your signal via a POST request to this URL with the JSON payload.
Q: What are connectorName
and connectorToken
?
The connectorName
and connectorToken
uniquely identify and link the signal you send to a specific strategy on Crypto-Arsenal. Each pair has a one-to-one correspondence with a strategy. You can locate these details within your strategy's editor on Crypto-Arsenal.
Q: How can I process customized signal? (Advanced)
You can send any custom JSON payload to the webhook URL. The payload will be processed in the Python editor that is where your strategy lives.
Each time a signal is received from the webhook, the on_tradingview_signal
callback is invoked with the signal's JSON data and the most recent candle data. This class and function is stateful, allowing for the maintenance of state across signals.
#...
def on_tradingview_signal(self, signal, candles):
exchange, pair, base, quote = CA.get_exchange_pair()
# will print out exactly the signal you sent to the webhook
CA.log('on_tradingview_signal: ' + str(signal))
if signal.get('action') == 'open_long':
CA.open_long(exchange, pair, signal.get('amount'), CA.OrderType.MARKET)
#...