Entity Stores
Entity Stores
Somewhat incongruously for a functional programming language, WL incorporates a powerful object-oriented concept known as the Entity Store
◼
An Entity Store appears at first to be only a partial implementation of the OO idea:
◼
Entities have properties
◼
No methods
◼
However, Entity Store “properties” can be functions, i.e. “methods”
Equities Entity Store
Equities Entity Store
◼
Includes over 1,000 equity entities
◼
Stocks and stock indices
◼
Fundamental, technical and historical data
◼
Ideal for cross-sectional analysis
◼
Applications:
◼
Portfolio construction
◼
Statistical Arbitrage
Installation
Installation
Get[StringJoin[dirEntityStore,"EquitiesEntityStore.mx"]];
Typically you would register the store on all kernels, to enable parallelization:
In[]:=
task=Quiet@Table[ParallelSubmit[{i},{EntityUnregister[EquitiesEntityStore],$KernelID}],{i,Length@Kernels[]}];WaitAll[task];task=Table[ParallelSubmit[{i},{EntityRegister[EquitiesEntityStore],$KernelID}],{i,Length@Kernels[]}];WaitAll[task]
{{{"Equities"},1},{{"Equities"},2},{{"Equities"},3},{{"Equities"},4}}
Equity Store Properties
Equity Store Properties
In[]:=
EntityList["Equities"]//Length
Out[]=
1005
Equity Indices
Equity Indices
In[]:=
EntityList[EntityClass["Equities","Stock Indices"]]
Out[]=
Stocks
Stocks
Select a sample of individual equity entities:
In[]:=
selectedStocks=,,,,,,,,,;
Select Index Components
Select Index Components
Often we want to define a universe of stocks for analysis that correspond to common index memberships, for example:
In[]:=
SelectIndexComponents[selectedStocks,"DOW30"]
Out[]=
In[]:=
SelectIndexComponents[selectedStocks,"SP500"]
Out[]=
,,,,,,
Select by Start Date
Select by Start Date
When performing time series cross-sectional analysis we typically want to select subsets of stocks that were extant on or before specified dates:
In[]:=
EntityStartDate[#]&/@selectedStocks
Out[]=
,,,,,,,,,
This is easy to accomplish in the WL operating on the Entity Store:
In[]:=
SelectEntitiesStartDateBefore[selectedStocks,{2001,1,1}]
Out[]=
,,,
Equity Properties
Equity Properties
Each entity in the Equities Entity Store contains the following properties:
In[]:=
Out[]=
,,,,,
Company Information
Company Information
We can use the company information to group equities by sector:
In[]:=
Out[]=
SymbolNYSE:WMT,ExchangeNYSE,Start Date,Company,SectorDiscountStores,SICCode5331
Fundamental Information
Fundamental Information
The fundamental information property gives a limited snapshot of current fundamental data for the stock:
In[]:=
Out[]=
MarketCap3.8642×,PERatio28.14,EarningsPerShare5.0096,EBITDA35286000000
11
10
However, a much more complete dataset of fundamental information is available, as properties of the Company entity:
In[]:=
Out[]//Short=
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,71,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Index Memberships
Index Memberships
In[]:=
Out[]=
DOW30True,SP500True,Russell 1000True
Price-Volume Information
Price-Volume Information
In[]:=
Out[]=
Historical Data
Historical Data
Historical data associated with each entity includes daily/monthly price and returns series from Jan 2, 1990 (or the start date of the series, if later).
We can access historical data immediately for analysis, without requiring any data downloading or database retrieval:
Of course, it is also easy to perform a combined analysis for equity entities in the WL, for instance:
We can construct trading charts using the historical price series:
Performance Data
Performance Data
The information we have considered so far can be retrieved using the FinancialData function, albeit that it is presented in a much more convenient and rapidly accessible form in the Equities Entity Store.
However, the Performance property of equity entities contains a substantial amount of pre-computed information that is not directly available from Wolfram:
Most of the data items are self explanatory, but some require others elucidation:
◼
Autocorrelation refers to the autocorrelation in 1-month, 3-month,... etc, returns. The autocorrelation from inception is the autocorrelation in daily returns, from the start of the data series.
◼
The IR is the information ratio, defined here as the ratio of the CAGR to the annualized volatility, estimated for the last 1-month, 3-month,... etc period.
◼
The Alpha and Beta are the CAPM regression estimates obtained by regressing the (excess) daily returns in the stock against those of the index, for the corresponding 1-month, 3-month,.. etc period.
◼
μ and σ are the annualized, instantaneous drift and volatility parameters for a Geometric Brownian Motion process estimated using daily closing prices over the last 1-month, 3-month, .. etc period.
Cross-Sectional Analysis
Cross-Sectional Analysis
Fundamental Information Dataset
Fundamental Information Dataset
Cross-Sectional Performance Dataset
Cross-Sectional Performance Dataset
We might want to carry out a comparative analysis, looking at performance over, say, the last nine months:
Correlation Plots (with outlier detection)
Correlation Plots (with outlier detection)
In this example we are looking at correlation plots for pairs of equities, using WL’s Anomaly Detection functionality to remove outliers from the data:
Historical Performance Data
Historical Performance Data
While the snapshot performance information contained in the Performance property of each equity entity is interesting, much more useful is the historical performance data contained in the Historical Data property:
Why is this useful?
In cross-sectional strategy design we typically look at performance metics for a universe of stocks at the end of each month, using these to decide which stocks to go long and which to short for the next month.
The Historical Performance Data contained in the Equities Entity Store provides exactly the information we would need to construct such long/short equity portfolios.
We will discuss this application in Part 2 of the presentation.
In cross-sectional strategy design we typically look at performance metics for a universe of stocks at the end of each month, using these to decide which stocks to go long and which to short for the next month.
The Historical Performance Data contained in the Equities Entity Store provides exactly the information we would need to construct such long/short equity portfolios.
We will discuss this application in Part 2 of the presentation.