Run on your own server

There may be cases where you'd need to run strategies on your own server rather than on Tradelets (Tradologics' servers). This guide will show you how.
Some plans on Tradologics allow you to run strategies on your own server. This can prove to be useful in cases when you need your strategy to communicate with external resources in your stack, use custom data sources, or if you are required to do so for compliance reasons.
Tradologics makes it as simple as possible to port your strategies and run them on your own server.
The basic premise of using your own server involves coding your strategy as you normally would. When writing the code, you will need to make sure that you are able to accept Tradehook data via POST and pass it into your strategy. Utilizing your own server is truly as simple as that.

Getting started

Here are the steps required to run strategies on your own server:
  1. 1.
    Write your strategy as you normally would.
  2. 2.
    Create a file with a function to parse the Tradehook payload's wrapper JSON (e.g.
  3. 3.
    This file should import your strategy's main file (e.g.
  4. 4.
    Make sure your Tradehook handler function accepts JSON body POST via http(s).
Please note that, at the moment, you can only run strategies running on your own server in either Paper or Broker modes. Backtesting on your own server is currently not possible, as it takes too long due to network latency.

Tradehook payload wrapper

The Tradehooks payloads data will be sent to your server in the following format:
"tradehook": "Tradehook name",
"data": "Actual Tradehook payload"
Example: Bar Tradehook
"tradehook": "bar",
"data": {
"assets": [
"bars": {
"YYYY-MM-01": {
"AAPL": {
"o": "113.79",
"h": "117.26",
"l": "113.62",
"c": "115.56",
"v": 136210200,
"t": 782692,
"w": "116.11665173913042"
"YYYY-MM-02": {
"...": "..."

Writing the handler

In order for your strategy to run on your server, you will need to write a handler function. This handler function will need to parse the Tradehook data and pass it on to your strategy.
We recommend that you use a hard-to-guess URL endpoint for your strategy. In the below example, we're using /9d3c6c4cbffc4026a2da24fc068b5107

Example code

In this example, we assume that (your strategy file) is located in the same directory as your file (your Tradehook's handler file), and that has a main function called strategy.
For this reason, you'll notice that we're importing it using from . import strategy and that we're calling it via strategy.strategy(...) .
from tradologics import server
# ↓ this should be a file with your strategy code
from . import strategy
server.start(strategy, endpoint="/9d3c6c4cbffc4026a2da24fc068b5107",
host="", port=5000, debug=False)
Next, run this in your file:
$ python ./
* Serving Flask app
* Running on (Press CTRL+C to quit)
In this example, we assume that strategy.js (your strategy file) and server.js is located in the same directory.
const Server = require('@tradologics/tradologics/server');
const { strategy } = require('./strategy');
Next, run this in your file:
$ node server.js
In this example, we assume that (your strategy file) is located in the same directory as your file (your Tradehook's handler file), and that has the main function called strategy .
import com.tradologics.server.*;
public class Server {
public static void main(String[] args) throws Exception {
Strategy handler = new Strategy();
ServerBuilder builder = new ServerBuilder(handler);"").port(5000).endpoint("/9d3c6c4cbffc4026a2da24fc068b5107").build().start();
import com.tradologics.server.*;
public class Strategy implements IStrategyHandler {
public void strategy(String tradehook, String payload) {
System.out.println("Strategy handler logic...");
// Add this section to your build.gradle file
jar {
manifest {
attributes 'Main-Class': 'Server'
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
// If you want to include resources into your compiled .jar file
into 'resources', {
from 'resources'
duplicatesStrategy = DuplicatesStrategy.INCLUDE
Finally, run this in your file:
$ ./gradlew jar
$ java -jar build/libs/*.jar
* [Thread-0] INFO org.eclipse.jetty.util.log - Logging initialized @123ms
* [Thread-0] INFO spark.webserver.JettySparkServer - == Spark has ignited ...
* [Thread-0] INFO spark.webserver.JettySparkServer - >> Listening on
* [Thread-0] INFO org.eclipse.jetty.server.Server - jetty-9.3.z-SNAPSHOT
* [Thread-0] INFO org.eclipse.jetty.server.ServerConnector - Started [email protected]{HTTP/1.1,[http/1.1]}{}
* [Thread-0] INFO org.eclipse.jetty.server.Server - Started @234ms
In this example, we assume that strategy.go (your strategy file) and server.go is located in the proj directory, main.go in the project root.
package server
import (
func Run() {
server.Start(Strategy, "/9d3c6c4cbffc4026a2da24fc068b5107", "", 5000)
package server
import (
func Strategy(event string, data []byte) {
fmt.Println("EVENT -->", event, "DATA -->", string(data))
package main
import (
"proj/server" // ← your server.go file
func main() {
fmt.Println("Server running...")
module proj
go 1.17
require (
github/tradologics/go-sdk v0.2.0
Lastly, run this in your file:
$ go run main.go
* Server running...

Point to your server

Your handler URL is:
The last step will be to point Tradologics to your server's URL, which can be done from the web console when creating your strategy.
That's it!
Once your strategy is started, all Tradehook data will be sent to your server's URL via POST request. Your strategy can communicate with the Tradologics API as it normally would.