plotly and cufflinks

Execute the following code to plot Microsoft's stock prices together with the simple and log returns.

  1. Import the libraries and handle the settings:
import cufflinks as cffrom plotly.offline import iplot, init_notebook_mode# set up configuration (run it once)#cf.set_config_file(world_readable=True, theme='pearl', #                   offline=True)init_notebook_mode()
  1. Create the plot:
df.iplot(subplots=True, shape=(3,1), shared_xaxes=True,          title='MSFT time series')

We can observe the time series in the following plot:

The main advantage of using plotly with cufflinks is the interactivity of the preceding chart, which is unfortunately ...

Get Python for Finance Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.