Skip to content

Latest commit

 

History

History
86 lines (59 loc) · 3.16 KB

basics.rst

File metadata and controls

86 lines (59 loc) · 3.16 KB

Basics

This page introduces all the important concepts used within deepdow.

Data

Financial timeseries can be seen a 3D tensor with the following dimensions

  • time
  • asset
  • indicator/channel

To give a specific example, one can investigate daily (time dimension) open price returns, close price returns and volumes (channel dimension) of multiple NASDAQ stocks (asset dimension). Graphically, one can imagine

image

Let us denote the shape of our tensor (n_channels, n_timesteps, n_assets) = (3, 10, 6). By fixing a time step (representing now), we can split our tensor into 3 disjoint subtensors:

  • x - (n_channels, lookback, n_assets) = (3, 5, 6)
  • g - (n_channels, gap, n_assets) = (3, 1, 6)
  • y - (n_channels, horizon, n_assets) = (3, 4, 6)

image

Firstly, x represents all the knowledge about the past and present. The second tensor g represents information contained in the immediate future that we cannot use to make investment decisions. Finally, y is the future evolution of the market.

One can now move along the time dimension and apply the same decomposition at every time step. This method of generating a dataset is called the rolling window. To illustrate this idea, let us take a slightly bigger starting tensor (n_timesteps = 12) while keeping lookback = 5, gap = 1 and horizon = 4. Let's roll it!

We now possess a collection of 3 feature tensors (x1, x2, x3) and 3 label tensors (y1, y2, y3). And that is all we need!

Predictions AKA weights

In the deepdow framework, we study networks that input x and return a single weight allocation w of shape (n_assets,) such that iwi = 1. In other words, given our past knowledge x we construct a portfolio w that we buy right away and hold for horizon time steps. Let F some neural network with parameters θ, the below image represents the high level prediction pipeline:

image

Loss

The last piece of the puzzle is definition of the loss function. In the most general terms, the per sample loss L is any function that inputs w and y and outputs a real number. However, in most cases we first compute the portfolio returns r over each time step in the horizon and then apply some summarization function S like mean, standard deviation, etc.

image

Assumptions

Before finishing this chapter, let us summarize the important assumptions deepdow is making

  • The time dimension is contiguous with a single frequency (i.e. daily)
  • The predicted weights w are turned into an actual investment that is held over horizon time steps