Skip to content

Latest commit

 

History

History
77 lines (54 loc) · 1.13 KB

README.md

File metadata and controls

77 lines (54 loc) · 1.13 KB

Tradologics Golang SDK

This is the initial version of Tradologics' Golang SDK.

The library supports a wrapper for the net/http that will automatically:

  • prepend the full endpoint url to your calls
  • attach your token to the request headers
  • add datetime to your order when in backtesting mode

Install


Install dependencies first

Install the library

go get github/tradologics/go-sdk

Using the library:


package main

import (
	"bytes"
	"encoding/json"
	"github.com/tradologics/go-sdk/net/http"
	"io"
	"log"
)

func main() {
	http.SetToken("YOUR TOKEN")

	data, err := json.Marshal("YOUR DATA STRUCT")

	if err != nil {
		log.Fatalln(err)
	}

	res, err := http.Post("/orders", "application/json", bytes.NewBuffer(data))
	if err != nil {
		log.Fatalln(err)
	}
	...
}

Running your own server:


package main

import (
	"github.com/tradologics/go-sdk/server"
	"net/http"
)

func strategyHandler(tradehook string, payload []byte) {
	...
}

func main() {
	server.Start(strategyHandler, "/my-strategy", "0.0.0.0", 5000)
}