Qc is a command line tool that lets you sync and run your QuantConnect backtests.
Qc is distributed as a ruby gem. You can install it with:
gem install qc
Qc requires Ruby version 2.3 or greater.
qc loginfor introducing your QuantConnect credentials
qc initon the directory that contains your QuantConnect algorithm
qcto sync and backtest your algorithm in QuantConnect
Default (no command provided)
When no command is provided, it will push your changes to QuantConnect, compile the project and run a backtest.
qc qc --open # To open the results in QuantConnect while running the backtest
This is equivalent to executing
qc compile and
qc backtest in sequence.
The supported commands are:
||It will ask for the API credentials you can find in your QuantConnect account page. They will be stored in
||Logout from QuantConnect clearing the credentials stored locally.|
||Initialize the directory of the algo project you are working on. It will ask for a QuantConnect project to link your algo with. You need to run this once for every project you want to sync with QuantConnect.|
||Send your local files to QuantConnect. It will only send the files that changed since the last time you run the command|
||Compile your project in QuantConnect|
||Run the backtest of your algorithm in QuantConnect|
||Open the latest results in QuantConnect (only MacOS)|
Opening the results in QuantConnect (only MacOS)
If you pass
--open when running a backtest, it will open the results in QuantConnect while the backtest is running:
qc --open qc backtest --open
This option only works in MacOS. quantconnect.com currently doesn't offer an URL endpoint to open backtest results. In MacOS, it will use an Automator workflow that will open the project and show its latest results by simulating a click on the corresponding option. See this discussion.
Support for importing trades into Tradervue (experimental)
Tradervue is a powerful trading journal system. It can be very helpful for analyzing your backtests. In addition to a ton of analytics and reporting features, it lets you see your trade executions in charts.
Qc lets you import each backtest results into tradervue. In tradervue, it will tag the executions with the backtest name.
To enable tradervue imports you must:
- Use the
--tradervueflag when running your backtest
TRADERVUE_PASSWORDas environment variables
TRADERVUE_LOGIN=<your tradervue login> TRADERVUE_PASSWORD=<your tradervue password> qc --tradervue
After running the backtest, it will open the results in tradervue automatically (only MacOS).
After checking out the repo, run
bin/setup to install dependencies. Then, run
rake test to run the tests. You can also run
bin/console for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run
bundle exec rake install. To release a new version, update the version number in
version.rb, and then run
bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the
.gem file to rubygems.org.
The gem is available as open source under the terms of the MIT License.