print ffn.get('aapl:Open,aapl:High,aapl:Low,aapl:Close', start='2010-01-01', end='2014-01-01').head()

data = ffn.get('dbc', provider=ffn.data.csv, path='test_data.csv', existing=data)
print data.head()

returns = data.to_log_returns().dropna()
print returns.head()

"""
Explanation: By default, the data is downloaded from Yahoo! Finance and the Adjusted Close is used as the security's price. Other data sources are also available and you may select other fields as well. Fields are specified by using the following format: {ticker}:{field}. So, if we want to get the Open, High, Low, Close for aapl, we would do the following:
End of explanation
"""


ax = returns.hist(figsize=(12, 5))

"""
Explanation: Let's look at the different distributions to see how they look.
End of explanation
"""


returns.corr().as_format('.2f')

"""
Explanation: We can also use the numerous functions packed into numpy, pandas and the like to further analyze the returns. For example, we can use the corr function to get the pairwise correlations between assets.
End of explanation
"""


returns.plot_corr_heatmap()

ax = data.rebase().plot(figsize=(12,5))

perf = data.calc_stats()

"""
Explanation: Here we used the convenience method as_format to have a prettier output. We could also plot a heatmap to better visualize the results.
End of explanation
"""


perf.plot()

"""
Explanation: Now that we have our GroupStats object, we can analyze the performance in greater detail. For example, the plot method yields a graph similar to the one above.
End of explanation
"""


print perf.display()

"""
Explanation: We can also display a wide array of statistics that are all contained in the PerformanceStats object. This will probably look crappy in the docs, but do try it out in a Notebook. We are also actively trying to improve the way we display this wide array of stats.
End of explanation
"""


# we can also use perf[2] in this case
perf['spy'].display_monthly_returns()

perf[2].plot_histogram()

"""
Explanation: Lots to look at here. We can also access the underlying PerformanceStats for each series, either by index or name.
End of explanation
"""


perf['spy'].stats

returns.calc_mean_var_weights().as_format('.2%')

"""
Explanation: Most of the stats are also available as pandas objects - see the stats, return_table, lookback_returns attributes.
End of explanation
"""


returns.calc_ftca(threshold=0.8)

"""
Explanation: Some other interesting functions are the clustering routines, such as a Python implementation of David Varadi's Fast Threshold Clustering Algorithm (FTCA)
End of explanation
"""


