gocryptotrader
gocryptotrader copied to clipboard
backtester: custom strategy plugins
PR Description
This PR allows for a user to build custom strategies that are not part of the main codebase. This PR uses Golang plugins which you can read about here. They do not work on Windows, however, they do work on WSL, Linux and macOS, so I consider them usable on all platforms.
I've documented what's required for these to work here
tl;dr how do?
For a quick testing run, do the following:
- navigate to
/backtester/plugins/strategies/example/
and rungo build -buildmode=plugin
- navigate to
/backtester
and rungo build
- run
./backtester --strategypluginpath="/backtester/plugins/strategies/example/example.so" --configpath=/backtester/config/examples/custom-plugin-strategy.strat"
Type of change
- [x] New feature (non-breaking change which adds functionality)
How has this been tested
- [x] go test ./... -race
- [x] golangci-lint run
- [x] Running the custom strategy
Checklist
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have made corresponding changes to the documentation and regenerated documentation via the documentation tool
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my feature works
- [x] New and existing unit tests pass locally and on Github Actions/AppVeyor with my changes
- [x] Any dependent changes have been merged and published in downstream modules
I had the thought last night that in combination with this PR and the Backtester becoming a long-living application, it would be better to load multiple custom strategies at once. So I've updated it to take in a slice instead 🎉