Skip to content

Go

Standard library only for REST; github.com/gorilla/websocket for streaming.

All examples assume the EA is running on the same computer with default ports. Order examples are for demo accounts.

package main
import (
"encoding/json"
"fmt"
"net/http"
)
func main() {
resp, err := http.Get("http://127.0.0.1:81/v1/quote?symbol=EURUSD")
if err != nil { panic(err) }
defer resp.Body.Close()
var q map[string]any
json.NewDecoder(resp.Body).Decode(&q)
fmt.Println(q["SYMBOL"], q["BID"], q["ASK"])
}
resp, _ := http.Post(
"http://127.0.0.1:81/v1/order?symbol=EURUSD&volume=0.01&type=ORDER_TYPE_BUY",
"application/json", nil)
var r map[string]any
json.NewDecoder(resp.Body).Decode(&r)
fmt.Println(r["RETCODE"], r["ORDER"])