Integrating external systems with AutoTrade via local sockets is the fastest way to automate your trading workflows. With our lightweight Server Socket Communication Agent (SSCA), you can send commands and data to AutoTrade without extra dependencies.
Below you’ll find everything you need to get started, including setup instructions and minimal-dependency code snippets in ZSH, JavaScript, Python, Java, and C#. Whether you’re executing robots on-demand or building complex trading pipelines, this guide will help you integrate seamlessly and confidently.
What is a local socket?
A local socket (also called a Unix domain socket on Unix or a named pipe on Windows) is an inter-process communication endpoint that enables fast, file-system-based data exchange between applications on the same host. By leveraging our SSCA, you can send JSON-formatted trading commands directly to the AutoTrade desktop application over a local socket. This avoids network overhead and keeps your integration lightweight.
Prerequisites
- AutoTrade desktop application installed and running on your machine.
- Your trading robot saved in AutoTrade with a unique name (e.g.,
my_robot_name
). - Basic familiarity with command-line or programming in your preferred language.
Start with AutoTrade Socket
- Launch AutoTrade: Ensure you’re logged in and your robot is available.
- Identify the socket endpoint: By default, SSCA listens on localhost port
65432
. - Send a command: Use one of the code examples below to send a
run_robot
action.
Code Examples
Below are minimal-dependency examples. Simply replace "my_robot_name"
with your robot’s name.
ZSH
printf '{"action":"run_robot","kwargs":{"name":"my_robot_name"}}' | nc 127.0.0.1 65432
JavaScript (Node.js)
Uses the built-in net module—no extra packages required
const net = require('net')
const payload = JSON.stringify({
action: 'run_robot',
kwargs: { name: 'my_robot_name' }
})
const client = net.createConnection({ host: '127.0.0.1', port: 65432 }, () => {
client.write(payload)
client.end()
})
client.on('error', (err) => console.error('Socket error:', err))
Python
Python’s standard library socket module handles TCP without third-party dependencies.
import socket, json
payload = json.dumps({
'action': 'run_robot',
'kwargs': {'name': 'my_robot_name'}
})
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect(('127.0.0.1', 65432))
s.sendall(payload.encode('utf-8'))
Java
Relies solely on java.net.Socket from the standard JDK—no external libraries needed
import java.io.OutputStream;
import java.net.Socket;
import java.nio.charset.StandardCharsets;
public class AutoTradeClient {
public static void main(String[] args) {
String payload = "{\"action\":\"run_robot\",\"kwargs\":{\"name\":\"my_robot_name\"}}";
try (Socket socket = new Socket("127.0.0.1", 65432);
OutputStream out = socket.getOutputStream()) {
out.write(payload.getBytes(StandardCharsets.UTF_8));
out.flush();
} catch (Exception e) {
System.err.println("Error: " + e.getMessage());
}
}
}
C#
Built on System.Net.Sockets.Socket in .NET—no NuGet packages required
using System;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
class Program {
static async Task Main() {
var payload = "{\"action\":\"run_robot\",\"kwargs\":{\"name\":\"my_robot_name\"}}";
var data = Encoding.UTF8.GetBytes(payload);
var ipEndPoint = new IPEndPoint(IPAddress.Loopback, 65432);
using Socket socket = new Socket(ipEndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
await socket.ConnectAsync(ipEndPoint);
await socket.SendAsync(data, SocketFlags.None);
socket.Shutdown(SocketShutdown.Both);
}
}
AutoTrade Socket API
For now, SSCA supports two actions:
Action | Explaination | Payload |
---|---|---|
run_robot | Execute a stored trading robot by name. | {"action":"run_robot","kwargs":{"name":"my_robot_name"}} |
kill | Shutdown AutoTrade and all running robots. | {"action":"kill","kwargs":{}} |
Next Steps
Ready to automate your entire trading workflow? Download AutoTrade today and start executing your trading robots with zero friction.
🔗 Download AutoTrade Now
📚 Explore Documentation & Tutorials
💬 Ask Questions & Get Support