Making an animation of alpha and beta for given stocks with matplotlib.
| 日本語(Qiita) | haltaro |
You have to add Histrical Data such as GOOG.csv to /data directry. For example, YAHOO! FINANCE helps you.
GOOG.csv)).Histrical Data at top of the page.Time Period: is the period you want, and Frequency: is Daily. Then click Download Data.table.csv to `GOOG.cThe codes depend on functions defined in Machine learning for trading at Udacity. Refer to the class (and take it!). You have to add udacity.py which defines get_data(), fill_missing_values(), and compute_daily_returns() to the current directry.

Hereinafter, we assume SPY as the benchmark. The figure shows daily-returns of SPY and GOOG from Dec. 1, 2006 to Dec. 1, 2016. The regression line can be defined as y = beta x + alpha.
import animab as ab
ab.animate_a_b()
symbols: List of symbols to animatestart_date and end_date: Defines the animation period. Strings with yyyy-mm-dd format.period: Calculation period of alpha and beta.MIT