Quartz is a WIP high-performance, statically-typed language designed specifically for quantitative trading. Built for speed, it features a concise and easy-to-learn syntax while providing the power and flexibility needed for algorithmic trading strategies.
Quartz is designed for quantitative traders who need a fast, reliable language for building and testing strategies. It integrates both compiled and interpreted modes, allowing you to choose the right trade-off between performance and rapid prototyping.
- ⏩ Static Typing: Ensures high-speed execution and prevents runtime overhead.
- 📊 Optimized Data Handling: Handles large market data efficiently for real-time trading.
- ⚡ Low Latency: Essential for high-frequency trading strategies.
- 🔄 Compiled and Interpreted Modes: Compile for maximum performance & deployment or interpret for fast prototyping & backtesting.
- ✨Concise Syntax: Built to be easy to learn and write, especially for algorithmic trading.
- C++ compiler
- Cmake
To get started with Quartz, clone the repository:
git clone https://github.com/londonmax12/quartz.gitA strategy in Quartz is defined with the strategy keyword. It includes initialization, backtesting, and logic to handle market data.
strategy MovingAverageCrossover {
// Initialize strategy
init() -> void {
// Initialization code
}
// Process incoming data, generate trade signals
on_data() -> void {
// Trading logic
}
}
Define input variables that can be accessed within the on_data() method using the define_input_variables() function.
- E.g.
define_input_variables(price);
Add multiple data sources with the add_data_source() function.
add_data_source("AAPL", "1d"); // Daily data for AAPL
add_data_source("GOOG"); // Default interval for GOOG
Signals trigger trade actions (BUY, SELL, HOLD). You can only emit signals during the on_data() method.
emit_signal(BUY); // To buy the asset
emit_signal(SELL); // To sell the asset
emit_signal(HOLD); // To hold the asset
- Constants: Use
constfor parameters that remain unchanged - Mutable Variables: Use
varfor variables that change during execution
strategy MovingAverageCrossover {
// Constants
const data_source: string = "AAPL";
const interval: string = "1d";
const short_window = 10;
const long_window = 50;
// Initialize strategy
init() -> void {
add_data_source(data_source, interval);
define_input_variables(price, short_ma, long_ma);
}
// Process incoming data
on_data() -> void {
if (short_ma > long_ma) {
emit_signal(BUY); // Buy when short MA crosses above long MA
} else if (short_ma < long_ma) {
emit_signal(SELL); // Sell when short MA crosses below long MA
} else {
emit_signal(HOLD); // Hold if there is no crossover
}
}
}
- Define Your Strategy: Use the
strategykeyword to declare a new strategy. - Add Data Sources: Use the
add_data_source()function to bring in market data. - Define Variables: Use
define_input_variables()to specify the variables that can be used within the strategy. - Implement Logic: Define trading logic in
on_data()and generate trade signals withemit_signal().
You'll find various code examples in the examples folder
We welcome and appreciate contributions to Quartz! Whether it's issue reports, suggesting new features, submitting bug fixes, or even typo fixes.
- Fork this repo to your own Github account
- Create a branch for your new changes
- Implement your fixes or features
- Submit a pull request with a description of your changes
- Distrubted under the MIT license, for more details read the LICENSE file
- All logos, trademarks, images, and other creative works are exclusive property of the Quartz project. You are permitted to use the Quartz logo, as long as you provide proper attribution to the Quartz project
- The logo may be used in your own projects, websites, or materials, provided that the Quartz Project is credited.
- The attribution must be clear and visible, ideally in a prominent location near the logo or in a credits section.
For example, you can include an attribution statement like:
Logo used with permission from the Quartz Project.