Jump-Start Your Quant Finance Workflow

Jump-Start Your Quant Finance WorkflowSome quick tips to speed up some of your daily analysis using PythonLuke PoseyBlockedUnblockFollowFollowingJul 3This will be an intro to using one of my favorite quant finance libraries for speeding up your workflow.

The Jupyter Notebook I built for this article can be found here.

You can also find other analysis tools in this repo:Poseyy/MarketAnalysisPortfolio Theory, Options Theory, & Quant Finance – Poseyy/MarketAnalysisgithub.

comPrice Data & ReturnsFirst thing you’ll want to do is import the library and if working in a notebook you’ll want to add “%matplotlib inline” to get plots to show in your notebook.

Now you can start using the powerful tools provided by ffn.

There are many other libraries out there and I use many different libraries in my other posts.

For this article we focus on the powerful tools within ffn.

Retrieve price data with the following code:You might be interested in plotting these values.

To view these prices on the same scale you need to rebase the prices first.

You might then be curious to view the percent returns.

As you can see from the below image, GOOG returned about 6% over this timeframe, FB returned about 43.

7% during this timeframe, etc.

:AnalysisThere are various metrics for analyzing assets and portfolios that are standards within industry; ffn provides many of these tools; basically any industry standard tool can be found within one of the many open sourced libraries.

You can perform the analysis using individual methods like Sortino and Sharpe ratios individually or you can pull all of that data at once.

You can pull individual stocks out of your grouping of stocks.

You can do all sorts of different plots.

I find histograms to be especially useful for viewing sometimes.

If we want to make a histogram of fb returns we just need to reference that location:We can start performing analysis to build an optimal portfolio with this pre-specified group of assets.

There are many different ways to do this.

We may be interested in finding the efficient frontier.

We may be interested in using different metrics like sortino or sharpe; all of these tools are available to us.

We start by allocating with balanced volatility:Now we might want to do risk-return analysis for each asset to continue to empower our decision making.

This is essentially Sharpe Ratios without the risk free rate included.

You can add the risk free rate in rf (currently about 2.

1%) You can also use Sortino; the options are open to you:risk-return ratios, NOT SharpeThere are some really slick strategies like Pairs Trading that might interest you.

For pairs trading you’ll want to view correlation and cointegration of various assets.

With heatmaps you can do just that.

Here is a correlation heatmap for the assets in our analysis:Correlation heatmap showing FB & MSFT are the most correlated from the groupConclusionThere are many awesome finance libraries out there.

For more on ffn you can go through the documentation here.

Some other libraries to look into include but are not limited to: pyfin, quantpy, pynance, talib, zipline, backtrader, pyfolio, and many others.

It’s awesome that there is such a strong community of developers building and supporting these open sourced projects!.. More details

Leave a Reply