Python for Finance: Analyze Big Financial Data

(Elle) #1

The strategy pays off well; the investor is able to lock in a much higher return over the


relevant period than a plain long investment would provide. Figure 3-8 compares the


cumulative, continuous returns of the index with the cumulative, continuous returns of our


strategy:


In  [ 45 ]: sp500[[‘Market’,    ‘Strategy’]].cumsum().apply(np.exp).plot(grid=True,
figsize=( 8 , 5 ))

Figure 3-8. The S&P 500 index vs. investor’s wealth

Figure 3-8 shows that especially during market downturns (2003 and 2008/2009) the


shorting of the market yields quite high returns. Although the strategy does not capture the


whole upside during bullish periods, the strategy as a whole outperforms the market quite


significantly.


However, we have to keep in mind that we completely neglect operational issues (like


trade execution) and relevant market microstructure elements (e.g., transaction costs). For


example, we are working with daily closing values. A question would be when to execute


an exit from the market (from being long to being neutral/in cash): on the same day at the


closing value or the next day at the opening value. Such considerations for sure have an


impact on the performance, but the overall result would probably persist. Also, transaction


costs generally diminish returns, but the trading rule does not generate too many signals.


FINANCIAL TIME SERIES

Whenever it comes to the analysis of financial time series, consider using pandas. Almost any time series-related

problem can be tackled with this powerful library.
Free download pdf