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:
Broker | Demo account | Paperwallet trading | Real trading | Backtesting (historical prices) |
---|---|---|---|---|
IG.com | ✅ | ❌ | ✅ | ✅ |
Coinbase | ❌ | ✅ | ❌ | ✅ |
FTX | ❌ | ✅ | ❌ | ❌ |
Disclaimer: The developers are not liable for any losses arising from the buy or sell of securities. All included strategies are examples and in no case ready trading systems.
go get github.com/sklinkert/at
Example backtesting run:
INSTRUMENT="BTC-USD" STRATEGY="rsi" CANDLE_DURATION=24h YEAR_FROM=2021 MONTH_FROM=4 YEAR_TO=2021 MONTH_TO=12 PRICE_SOURCE="COINBASE" 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. paperwallet can be used if a broker does not offer testing/sandbox accounts for trading without real money.
The nerve center of the program. It connects the broker with strategies.
Implements various trading indicator like Simple Moving Average (SMA) or RSI. Indicators should implement this interface.
Implements various trading strategies. Each strategy needs to implement this interface thus the trader is able to connect.
General flow:
- Trader sends candlesticks (what is a candlestick?) and the current price (tick) to the strategy
- Optional: The strategy feeds indicators and retrieves the latest indicator values
- The strategy decides if trader should open a new position and which position should be closed.
- Trader executes new orders or closes open positions via broker APIs.
EOs can help to adjust a strategy according to the market volatility in order to reduce risk. E.g. you might want to buy when RSI indicator is below 25. However, if the market is getting dangerous due to high volatility you might only buy if RSI falls below 10 to ensure you buy only when indicator signals are stronger.
The backtest
module can apply historical price simulations to your strategy.
You can configure tradings fees and spreads to simulate trading like with real money.
It can also print a chart with a beautiful equity curve:
You can use Coinbase and histdata.com prices for backtestings. Check cmd/import-histdata for more.
Feel free to send PRs. I'm always happy to discuss and improve the code.
For hosting I can recommend DigitalOcean:
In case you want to show some love:
- BTC: 3BNnZUfw9qnLVnza9FvWF6n7tEXfWYVVy2
- ETH: 0xd30638F4fD54aeDB458d30504DD1cF2ce7563D36
- XMR: 45At7ezTicAejiLWTAfb28NNXnciH1M67VRrxLRHgfFyimHuPNP7MqbiUgYwwdTzXjbGFwCMsoMoH1Cvv7jPqKKANuaMpjo