Stratysis
A pluggable automated trading system backtesting engine.
Install / Use
/learn @jonblankenship/StratysisREADME
Stratysis
A pluggable automated trading system backtesting engine.
Builds
Overview
Stratysis an automated trading system backtesting engine written in C#. It is designed to be pluggable, allowing for the easy addition of new strategies, indicators, data providers, etc...
Stratysis is a pet project of mine and very much a work-in-progress. I'm developing it to satisfy my own creativity and to support my personal trading interests.
Progress
- 2019.04 - Start project; built original engine skeleton; console app
- 2020.09 - Dust off project; add Oanda web client; upgrade to .NET Core 3.1
- 2020.10 - Start (ugly) WPF client to support changing parameters and visualization of results
Getting Started
Stratysis currently supports data from Oanda and Quandl. My current focus is on the Forex market, and Oanda will be the default data provided for the foreseeable future.
Prior to running either the console app or the WPF app, obtain an API key from Oanda. This will require an account.
Running the Console App
-
Open the solution in Visual Studio.
-
Right-click Stratysis.Console > Set as Startup Project.
-
Right-click Stratysis.Console > Manage User Secrets.
-
In the secrets.json file that opens, add the following, using the API key provided by Oanda:
{ "AppSettings": { "QuandlApiKey": "xxxxxxxxxxxx-xxxxxxx", "OandaApiKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" } }(This is also where you add the QuandlApiKey if you're using the QuandlWebClient.)
-
Save the secrets.json file and run the project.
Running the WPF App
-
Open the solution in Visual Studio.
-
Right-click Stratysis.WPF > Set as Startup Project.
-
Right-click Stratysis.WPF > Manage User Secrets.
-
In the secrets.json file that opens, add the following, using the API key provided by Oanda:
{ "AppSettings": { "QuandlApiKey": "xxxxxxxxxxxx-xxxxxxx", "OandaApiKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" } }(This is also where you add the QuandlApiKey if you're using the QuandlWebClient.)
-
Save the secrets.json file and run the project.
Adding a Strategy
Specific trading strategies are located in the Stratysis.Strategies project. The SimpleBreakoutStrategy is a good example to follow (and the only example for now) for creating a new strategy.
-
Create
MyCustomStrategyParametersimplementingIStrategyParametersin Stratysis.Strategies.The strategy parameters class is used to manage the parameters specific to the custom strategy.
-
Create
MyCustomStrategyderiving fromStrategyin Stratysis.Strategies.The strategy class contains the strategy rules. There are four main methods to implement:
Initialize(BacktestParameters parameters, IStrategyParameters strategyParameters)ProcessNewData(Slice slice)EvaluateEntryConditions(string security, Slice slice)EvaluateExistConditions(Position openPosition, string security, Slice slice)
-
Add the following to the dictionary in StrategiesService:
{ typeof(MyCustomStrategy), typeof(MyCustomStrategyParameters) } -
Add
MyCustomStrategyParametersViewModelto Stratysis.Wpf\ViewModels\StrategyParameters. -
Add the following to the dictionary in StrategyParametersViewModelFactory:
{ typeof(MyCustomStrategy), typeof(MyCustomStrategyParametersViewModel) } -
Add
MyCustomStrategyParametersViewto Stratysis.Wpf\Views\StrategyParameters.
For now, the backtest results are only visible by setting a breakpoint on the _strategyRunner.RunAsync(..) call and inspecting the results, but I'll be adding visualization of the results to the app soon.
Stay in Touch
If you find Stratysis helpful or have any comments or questions, I'd love to hear from you. Feel free to send me a message on Twitter at @Jon_Blankenship.
Disclaimer
Stratysis is not intended to be an example of how to build an application or develop a trading system. While there may be things that can be gleaned from the codebase pertaining to either topic, teaching is not the intent here.
Stratysis is not a production-level application, and it should not be used to make investment decisions. Nothing in this repository nor any output of the application constitutes investment advice, and I am not responsible for any profits or losses incurred as a result of using Stratysis.
Related Skills
node-connect
354.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
112.2kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
354.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
354.2kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
