ETF historical data preparation

In the previous chapter, we introduced dividend data from IEX. IEX also provides historical data such as the closing price, opening price, highest price, lowest price, and closing price change. The following screenshot will show the historical price responses from IEX. We will retrieve one month of ACWF ETF data:

We list each returned field and give a short description for each one in the following table:

Field Type Description
date date The trading date
open float The adjusted opening price of the ETF on that date
high float The adjusted highest price of the ETF on that date
low float The adjusted lowest price of the ETF on that date
close float The adjusted closing price of the ETF on that date
volume long The adjusted daily trading volumes traded on that date
change float The closing price change between the trading day and the previous trading day
changePercent float The ratio of the closing price change between the trading day and the previous trading day
label text The given label Month Day of the trading date
changeOverTime float The percentage of the closing price change between the trading day and the first reported trading day
uVolume, uHigh, uLow, uOpen, uClose, float The unadjusted data corresponding to volume, high, low, open, and close on that date. These fields will not be used in the example.

 

In our GitHub repository (https://github.com/PacktPublishing/Mastering-Elasticsearch-7.0/tree/master/Chapter08), we can download three files, cf_etf_hist_price_bulk.json, cf_etf_hist_price_mappings.json, and cf_etf_hist_price_bulk_index.sh. We need to make the Bash file runnable and then we can run it to index those documents. We will use the default settings and static mapping from cf_etf_hist_price_mappings.json to create an index, named cf_etf_hist_price. All three figures of month data of 314 ETFs, starting from 2018-12-26 to 2019-03-25 and compiled for bulk index operations, are put in the cf_etf_hist_price_bulk.json file. We have separated each record manually as a document. We have also associated the corresponding symbol field and value with each ETF. We can use the _count API to count the total records, which is 19,141 in the cf_etf_hist_price index. 

Let's take a look at the search all results from the cf_etf_hist_price index as shown in the following screenshot: 

We can see that 10000 hits are reported. This is the default value of the maximum result window size setting, index.max_result_window, for the search results. If we want more search results, we should search with the scroll parameter as we described in Chapter 6, Search APIs. In the next section, we will introduce the basic syntax of the aggregation query.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.84.71