fbpx

Table of Contents

Guide to EQL

EQL is a language for manipulation and analysis of series data. The language can be roughly divided into constructs for manipulating series, constructs for constructing and aggregating sets of series, constructs for evaluating the performance of aggregated sets in the tracking of trends, and linguistic utilities.

EQL treats financial market entities as primary citizens, with data describing their different aspects and predicates relating them to one another.

Primitives

  .open
  .high
  .low
  .close
  .volume

  .vwpc
  .vwap
  .vwclose

  .fund.<>
  .est.<>
  .guid.<>


  SPY.close
  MSFT.open
  ORCL.volume

.fund, .est, and .guid are special classes of primitives (fundamentals, estimates, and guidance) which have a further subclassification.

Primitives all come with a “native” bar size, but can be resampled to other frequencies.

Indicators

Moving averages

sma(length): A simple moving average (SMA) is an arithmetic moving average calculated by adding recent closing prices and then dividing that by the number of time periods in the calculation average.

hma(length): The Hull moving average was developed as a solution to the lagging of price data introduced in simple, weighted, and exponential moving averages. The Hull moving average is extremely fast and smooth, and is computed by using the difference between two weighted moving averages over lengths (n/2, n) as the input to a weighted moving average of length sqrt(n).

wavg(length): A Weighted Moving Average puts more weight on recent data and less on past data. This is done by multiplying each bar’s price by a weighting factor. Because of its unique calculation, WMA will follow prices more closely than a corresponding Simple Moving Average.

xavg(length): The EMA gives a higher weighting to recent prices, while the SMA assigns equal weighting to all values. The weighting given to the most recent price is greater for a shorter-period EMA than for a longer-period EMA.

adma(fast length, slow length, inner length): The Kaufman adaptive moving average aims to filter out noise by lagging behind the current market price when volatility is high. The Kaufamn adaptive moving average depends on an efficiency ratio, and EMAs with fast and slow lengths. ER fluctuates between 1 and 0 in response to changes in price change efficiency. ER would be 1 if prices moved up 10 consecutive periods or down 10 consecutive periods. ER would be zero if price is unchanged over the 10 periods.

xavg3x(fast length, slow length, inner length): Triple exponential moving average.

Oscillators

rsi(length): The relative strength index (RSI) is a momentum indicator that measures the magnitude of recent price changes to evaluate overbought or oversold conditions in the price of a stock or other asset. The length parameter refers to the number of periods back – 14 days is a standard value.

tsi(fast length, slow length, inner length): The true strength indicator is a technical momentum oscillator which may indicate strength of the trend in a price. TSI values are computed by smoothing the EMA of the price change and absolute price change over a long length (often 25 periods) by the EMA over a short length (often 13 periods), and dividing the double-smoothed price change by the double-smoothed absolute price change. The inner length refers to the length of the EMA applied to the TSI value, which is used to produce a signal line.

macd (fast length, slow length): The MACD indicator thus depends on three time parameters, namely the time constants of the three EMAs. The notation “MACD(a,b,c)” usually denotes the indicator where the MACD series is the difference of EMAs with characteristic times a and b, and the average series is an EMA of the MACD series with characteristic time c. These parameters are usually measured in days. The most commonly used values are 12, 26, and 9 days, that is, MACD(12,26,9).

t3(length): It incorporates a smoothing technique which allows it to plot curves more gradual than ordinary moving averages and with a smaller lag. Its smoothness is derived from the fact that it is a weighted sum of a single EMA , double EMA , triple EMA and so on. When a trend is formed, the price action will stay above or below the trend during most of its progression and will hardly be touched by any swings. Thus, a confirmed penetration of the T3 MA and the lack of a following reversal often indicates the end of a trend.

tilson(length, volume factor): Where vFactor is a volume factor between 0 and 1 which determines how the moving averages responds. A value of 0 returns an EMA. A value of 1 returns DEMA. Tim Tillson advised or preferred a value of 0.7.

atan(length): Arctangent returns a value between 0.5pi and -0.5pi

fisher(): Transforms prices into a normalized Gaussian distribution for the given lookback period

gauss(length, poles):

pass():

momo(length): An indicator computing momentum over the given length.

General expressions and operators

A * B : multiplication  (.close * .volume)
A / B : division
A + B : addition
A - B : subtraction
A**(2) : exponentiation
abs() : absolute value
neg() : inversion


>
<
≥
≤
=

and : intersection
or : union
not : compliment

Views

Views attempt to transform price data based on comparison to historical values.

cume(): cumulate values from beginning of day (intraday only)

qcume(factor): a “staggered” cume calculation that has the smoothing benefits of cume() but applies a decrease weight going back eachba r.

hdelta( length, "(a OR z OR s OR v")): difference in mean OR z-score OR standard deviation OR variance between the current bar and some bar at the same time, some number of days back.

dx(length): A ternary function that compares the current value with a value some number of bars back.

ternary(|range|): converts into a positive/ negative/ neutral signal.

if f(t) < -a    ternary(f(t)) = -1
if f(t) > a    ternary(f(t)) = 1
otherwise     ternary(f(t)) = 0. 

Shifting

Shifting a time series back one period prevents look ahead bias, where data from the current period is used to make conclusions about the current period.

x → lag(length)

Aggregation

Combining the ensemble of series to generate one data point can provide a more meaningful interpretation of the data.

avg() : averages vertically across elements of a list, one layer at a time.

median() : as above, but median.

any daily() : longitudinal dis-aggregation and selection [filter] – data is filtered at the daily level before being rebalanced at the monthly horizon.

Dynamic Lists

Dynamic lists are a core construct of the language which allow for the composition of ordered sets of entities based on their aspects. Comparison of returns for filtered quintiles within a sorted list is a typical use case in fundamental analysis.

where : a keyword signalling the formation of a dynamic list.

<universe> where <universe> : the general syntax for list formation.

<universe> : the set which will be searched, and can take on one of a number of values.

<statement> : a potentially composite expression about the attribute(s) of entities in the list, which will be evaluated for every element in the UNIVERSE.

UNIVERSE : UNIVERSE refers to the entire set of elements represented within Equeum, but subsets of UNIVERSE are well formed entries into <universe>.

<universe> can take on the following values:

BASIC_MATERIALS
CONSUMER_CYCLICALS
CONSUMER_NON_CYCLICALS
ECONOMIC
ENERGY
FINANCIALS
HEALTHCARE
INDUSTRIALS
TECHNOLOGY
TELECOMMUNICATIONS_SERVICES
UTILITIES

sortby : order a selection based on an attribute. The default sort order is descending.

Appendix: a short list of fundamental attributes, referenced as SYMBOL.fund.qad.<number>

Language utilities

Lists (Static and Dynamic)

EQLF supports building simple lists with square bracket syntax.

[TS1, TS2, TS3]

Dynamic lists are a more nuanced concept unique to EQLF. Items in a dynamic list are resorted or rebalanced (the list is regenerated from the universe) based on the [(last day of the period) OR (the period average)].

with rebalance_period=1month
list as [UNIVERSE] where [inequality] 

Because of the changing nature of things in time, dynamic lists will often produce arrays of different sizes at each rebalance period. It is desirable to restrict the list on the lower bound to avoid a dynamic sample size.

Lists are indexed as follows:

list[1] : first element of the list
list[1:10] : elements 1 to 10
list[1:20:200] : elements 1 to 200 by 20
list → [1:200] 

Operators

Row references
@2 : series at row two
@[2:5] : series at rows two to five
@2{1} : list at row two, first item in the list
@2{1:5} : list at row two, first to fifth items in the list [inclusive]. 

EQLF supports an iterative workflow, allowing users to pass the data produced by a statement forward through the processing pipeline.

Simple assignment
as : x as 
 can contain a timeseries, security list, or list of timeseries.

with : a keyword indicating assignment of execution context.

with start_date=2017.01.01 , end_date=2019.04.19 , rebalance_period=1month, bar_size=BS_1MIN,

bar_size:
BS_1MIN
BS_1DAY

rebalance_period:
[1]day
[1]week
[1]month
Actions
→ : action operator, indicates the next step in the processing pipeline.

@"" : invocation of external content. 
Scoring

EQLF runs an internal correlation engine which automatically tests all testable results against a default target. By default, the target is set to the 30-bar RSI of SPY.close, but this can be overriden via a manual assignment to the reserved keyword “target”. In practice:

target as

to view the time series of daily scores produced by your algorithm, run:

x → daily_score(target, "mpm")

tbi(actions=[rsi(11:10:80), rsi(111:10:180)], topn=[3,5,10], days_back=[5,8,17], tally=avg())

Appendix: Sample Attributes

1001    netsales
1051    costofgoodssold
1100    grossincome
1249    operatingexptotal
1250    operatingincome
1651    incomenetbottomline
2003    cash
2051    receivablesnet
2097    rawmaterials
2098    workinprocess
2099    finishedgoods
2255    investmentstotal
2999    assetstotal
3040    accountspayable
3101    currliabilitiestotal
3245    debtlongtermexccapleases
3255    debttotal
3495    retainedearnings
5001    marketpriceyrend
5101    dividendspershare
5201    eps
5230    epsafterextraitems
5278    epranav
5476    bookvaluepershare
5486    bookvaluepersharetangible
5490    bookvalueadjustedtogaap
5501    cashflowpershare
6915    cashflowoperationsgaap
6920    cashflowoperatingactivitiesgaap
6930    cashflowfinancingactivitiesgaap
6940    cashflowinvestingactivitiesgaap
7210    marketcapusd
7250    incomenetusd
8001    marketcap
8106    currratio
8221    debttotaltotalcapitalanddebtshorttermratio
8231    debttotalcommonequityratio
8256    dividendpayouttotaldollar
8291    ebitinterestexpratio
8306    profitmargingross
8316    profitmarginoperating
8326    returnonassets
8366    marginnet
8376    returnoninvestedcapital
9100    peratiohigh
9101    peratiolow
9104    peratioclose
9106    peratioavghighlow
9200    earningsyieldhigh
9201    earningsyieldlow
9204    earningsyieldclose
9206    earningsyieldavghighlow
9300    pricebookvalueratiohigh
9301    pricebookvalueratiolow
9304    pricebookvalueratioclose
9306    pricebookvalueratioavghighlow
9400    dividendyieldhigh
9401    dividendyieldlow
9404    dividendyieldclose
9406    dividentyieldavghighlow
9504    dividendpayoutpershare
9604    pricecashflowratio
9904    pricesales
18170   salesunconsolidated
18173   epsunconsolidated
18191   ebit
18193   epsasreported
18197   costscap
18198   ebitda
18199   netdebt