Skip to content

Commit

Permalink
Updated example NBs with new API and improved price DataFrame explana…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
luca-s committed Nov 15, 2017
1 parent 27f7adf commit f21bbb5
Show file tree
Hide file tree
Showing 4 changed files with 1,178 additions and 868 deletions.
6 changes: 4 additions & 2 deletions alphalens/examples/event_study.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,11 @@
"editable": true
},
"source": [
"The pricing data passed to alphalens should reflect the next available price after a factor value was observed at a given timestamp. The price must not be included in the calculation of the factor for that time. Always double check to ensure you are not introducing lookahead bias to your study.\n",
"The pricing data passed to alphalens should contain the entry price for the assets so it must reflect the next available price after an event was observed at a given timestamp. Those prices must not be used in the calculation of the events for that time. Always double check to ensure you are not introducing lookahead bias to your study.\n",
"\n",
"In our example, before trading starts on 2014-12-2, we observe yesterday, 2014-12-1's factor value. The price we should pass to alphalens is the next available price after that factor observation: the open price on 2014-12-2."
"The pricing data must also contain the exit price for the assets, for period 1 the price at the next timestamp will be used, for period 2 the price after 2 timestats will be used and so on.\n",
"\n",
"While Alphalens is time frequency agnostic, in our example we build 'pricing' DataFrame so that for each event timestamp it contains the assets open price for the next day afer the event is detected, this price will be used as the assets entry price. Also, we are not adding additional prices so the assets exit price will be the following days open prices (how many days depends on 'periods' argument)."
]
},
{
Expand Down
8 changes: 6 additions & 2 deletions alphalens/examples/predictive_vs_non-predictive_factor.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,13 @@
"editable": true
},
"source": [
"The pricing data passed to alphalens should reflect the next available price after a factor value was observed at a given timestamp. The price must not be included in the calculation of the factor for that time. Always double check to ensure you are not introducing lookahead bias to your study.\n",
"The pricing data passed to alphalens should contain the entry price for the assets so it must reflect the next available price after a factor value was observed at a given timestamp. Those prices must not be used in the calculation of the factor values for that time. Always double check to ensure you are not introducing lookahead bias to your study.\n",
"\n",
"In our example, before trading starts on 2014-12-2, we observe yesterday, 2014-12-1's factor value. The price we should pass to alphalens is the next available price after that factor observation: the open price on 2014-12-2."
"The pricing data must also contain the exit price for the assets, for period 1 the price at the next timestamp will be used, for period 2 the price after 2 timestats will be used and so on.\n",
"\n",
"There are no restrinctions/assumptions on the time frequencies a factor should be computed at and neither on the specific time a factor should be traded (trading at the open vs trading at the close vs intraday trading), it is only required that factor and price DataFrames are properly aligned given the rules above.\n",
"\n",
"In our example, before the trading starts every day, we observe yesterday factor values. The price we pass to alphalens is the next available price after that factor observation: the daily open price that will be used as assets entry price. Also, we are not adding additional prices so the assets exit price will be the following days open prices (how many days depends on 'periods' argument). The retuns computed by Alphalens will therefore based on assets open prices."
]
},
{
Expand Down
Loading

0 comments on commit f21bbb5

Please sign in to comment.