No description
|
|
||
|---|---|---|
| .github/workflows | ||
| examples | ||
| src | ||
| tests | ||
| .gitignore | ||
| .pre-commit-config.yaml | ||
| Cargo.lock | ||
| Cargo.toml | ||
| LICENSE | ||
| README.md | ||
Vexity 🦎
Vexity is a tiny Domain Specific Language aimed at hacking on abstractions of financial markets.
🚧🦺👷Early Development, things will be breaking frequently 👷🦺🚧
License
This library is licensed under the Apache License 2.0.
Example
Create a simple moving average indicator:
Indicator
.config({
# Define a custom configuration for the
# indicator, this is for static data.
name: "Simple Moving Average",
sma_window_size: 50,
sma_color: "orange"
})
.init(|state| {
# Define the initialization logic for the
# indicator, this is for dynamic data.
state bars = []
})
.on_bar(|bar, cfg, state| {
# Define the logic for computing the indicator
# value of each bar or tick of trading activity.
# Update the state of the data array
state.bars.push(bar)
# Define the data window
let data_window = state
.bars
.last(cfg.sma_window_size)
.map(|bar| bar.close)
# Compute the sma value of the data window
let sma_value = sma(data_window)
# Return the indicator value
{ time: bar.time, value: sma_value, color: cfg.sma_color }
})