totomz / gotrader

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

go-trader

build status

go-trader is a platform to backtest and run live trading strategies, with focus on intra-day trading.

Examples

Check out the examples!

Create a simple strategy

The full souce code for this example is in examples/backtest/main.go Import gotrader in your project

go get -v github.com/totomz/gotrader

Then write a simple strategy

package main
import "github.com/totomz/gotrader/gotrader"

type SimpleStrategy struct {
	broker gotrader.Broker
}

func (s *SimpleStrategy) Initialize(cerbero *gotrader.Cerbero) {
	s.broker = cerbero.Broker
}

func (s *SimpleStrategy) Eval(candles []gotrader.Candle) {
	// c is the latest candle
	c := candles[len(candles)-1]
	println(c.String())
}

Data Visualization

Backtestsing

Candles and indicators are saved in Signals, that can be exported in a JSON format once the simulation is done

dataGrafana := gotrader.SignalsToGrafana()
err = os.WriteFile("./plotly/signals_grafana.json", dataGrafana, 0644)
if err != nil {
    panic(err)
}

This file can be used to plot candles and indicators in Grafana

TODO:

  • Visualizzo la roba su grafana
  • BONUS: mi creo con le label "buy" and "sell"

Credits

Backtrader

go-trader is heavily inspired by Backtrader

Indicators

The indicators are based on github.com/cinar/indicator

Development

shMake is required to build and run the testss

About

License:MIT License


Languages

Language:Go 74.5%Language:JavaScript 20.5%Language:HTML 4.4%Language:Shell 0.5%Language:Dockerfile 0.2%