qex¶
Express quant signals in one line¶
qex is a language for quantitative trading signals. A signal is one readable expression, applied to a whole panel of stock data at once.
Sector-neutral, risk-adjusted momentum:
Short-term reversal, leaving out the most volatile stocks:
A blend of the two, with names:
Where to find what¶
| Section | For |
|---|---|
| Philosophy | why signals are written this way, and how to go from an idea to an expression |
| Language | qex itself, with no Python: syntax, how expressions are evaluated, missing values, groups, universes, look-ahead, and the operator reference |
| Examples | signals written in qex: momentum, mean reversion, pairs, events, market beta, technical indicators |
| Python | installing qex, parsing and evaluating, books, backtests, diagnostics, the risk model, Dask |
| Data | the data qex reads: format, labels, universes, events, large datasets, adjusted prices, gaps |
| Python Examples | worked programs: the quick start, backtesting, checking a book's beta |
| Excel to qex | a friendly walkthrough for spreadsheet users: one signal built in Excel, then written in qex |
In Python¶
from qex import qex, Backtest
signal = qex("demean(rank(returns(20)))")
result = Backtest(signal, transaction_cost=0.001).run(data) # data: a dict of DataFrames, see Data
print(result.summary())
Installation¶
Optional extras and a development install are in Installation.