quantopian / alphalens

Performance analysis of predictive (alpha) stock factors
http://quantopian.github.io/alphalens
Apache License 2.0
3.26k stars 1.13k forks source link

Alphalens on uneven time intervals #305

Closed niti closed 6 years ago

niti commented 6 years ago

Is it possible to calculate get_clean_factor_and_forward_returns where the input factor parameter contains timestamps with uneven time intervals, for ex. if we pass in factor data that was run with nonstandard aggregations where we aggregate based on volume etc instead of time?

luca-s commented 6 years ago

Yes, the input factor can have uneven time intervals, but the timedelta between each factor timestamp and its correspondent price must be constant. e.g.

factor with uneven timestamps

-----------------------------------
    date    |    asset   |
-----------------------------------
            |   A        |  -1.1
2014-01-01  ----------------------
            |   B        |   1.7
-----------------------------------
            |   A        |  -0.1
2014-01-02  -----------------------
            |   C        |   2.7
-----------------------------------
            |   B        |  -0.1
2014-01-13  ----------------------
            |   C        |   2.7
-----------------------------------
            |   A        |  -3.1
2014-03-17  -----------------------
            |   C        |   2.3
-----------------------------------

prices contains information for each factor timestamp plus factor timestamp after 1 day (period = 1)

-----------------------------------
            | A    |  B   |  C    |
-----------------------------------
   Date     |      |      |       |
-----------------------------------
2014-01-01  |605.12| 24.58|  11.72|
-----------------------------------
2014-01-02  |604.35| 22.23|  12.21|
-----------------------------------
2014-01-03  |607.94| 21.68|  14.36|
-----------------------------------
2014-01-13  |605.12| 24.58|  11.72|
-----------------------------------
2014-01-14  |604.35| 22.23|  12.21|
-----------------------------------
2014-03-17  |607.94| 21.68|  14.36|
-----------------------------------
2014-03-18  |605.12| 24.58|  11.72|
-----------------------------------
luca-s commented 6 years ago

@niti please let me know if you encounter any problem. closing this for now