Purpose: Framework for building automated trading strategies in three steps:
- Build your own strategy.
- Verify it with the backtest module.
- Connect it to a real broker API to make some money.
Every broker API can be implemented. Works for stocks, forex, cryptocurrencies, etc.
Supported brokers:
- IG.com
- FTX.com (partly)
go get github.com/sklinkert/at
Example backtesting run:
INSTRUMENT="CB.ETHUSD" STRATEGY="rsiadx" CANDLE_DURATION=15m YEAR_FROM=2014 YEAR_TO=2022 PRICE_SOURCE="PATTERN_TRADING" go run -ldflags="-w -s -X main.GitRev=123" ./cmd/backtesting/main.go
Uses ETHUSD candles from Coinbase via api.pattern-trading.com
Implements concrete broker API.
The nerve center of the program. It connects the broker with strategies.
Implements various trading indicator like Simple Moving Avergae (SMA).
Implements various trading strategies.
General flow:
- Trader sends OHLC candles to the strategy
- The strategy feeds indicators and decides what to do.
- Trader executes new orders or closes open positions if requested by strategy.
EOs can help to adjust a strategy according to the market volatility in order to reduce risk. E.g. you can change the RSI levels to only buy long if the values goes under 10 instead of 20 because the market is flapping a lot.
The backtest
module can apply historical price simulations to your strategy.
It can also print a chart with a beautiful equity curve:
Feel free to send PRs. I'm always happy to discuss and improve the code.
In case you want to show some love:
- BTC: 3BNnZUfw9qnLVnza9FvWF6n7tEXfWYVVy2
- ETH: 0xd30638F4fD54aeDB458d30504DD1cF2ce7563D36
- XMR: 45At7ezTicAejiLWTAfb28NNXnciH1M67VRrxLRHgfFyimHuPNP7MqbiUgYwwdTzXjbGFwCMsoMoH1Cvv7jPqKKANuaMpjo