Python for Finance: Analyze Big Financial Data

(Elle) #1
Figure 6-13. Resampled Apple stock tick data

To conclude this section, we apply a custom-defined Python function to our new data set.


The function we choose is arbitrary and does not make any economic sense here; it just


mirrors the stock performance at a certain stock price level (compare Figure 6-14 to


Figure 6-13):


In  [ 95 ]: def reversal(x):
return 2 * 95 - x
In [ 96 ]: AAPL_resam[‘bid’].fillna(method=‘ffill’).apply(reversal).plot()

Finally, let’s clean up disk space by erasing all data sets saved to disk:


In  [ 97 ]: !rm ./data/*
# Windows: del /data/*

Figure 6-14. Resampled Apple stock tick data with function applied to it
Free download pdf