Saturday 3 February 2018

StockReader: What Data I Want and the Final Script

I want to acquire the following data for stocks on Swedish markets:
  • Name, DI
  • Price, DI
  • Earning per share, DI
  • P/E, DI
  • Book value per share, DI
  • Price per adjusted equity, DI 
  • Yield, DI
  • Yield per share, DI
  • Profit margin, DI
  • RSI, DI
  • Date of next report, DI
  • Date of next yield, DI
(In Swedish: Namn;Kurs;Vinst per aktie;P E;Kapital per aktie;P JEK;Direktavkastning;Utdelning per aktie;Vinstmarginal;RSI;Nasta rapport;Utdelningsdatum;TA)

I'll start with fetching 

If that allows, I'll fetch the entire stock list:

For each stock in that list, I'll use the hyperlink to get the stocks unique id number:
https://trader.di.se/index.php/quote/kurs/730

This is done using re.findall("/index.php/quote/kurs/[0-9]{1,10}", stockListResponse)

I'll use that number to fetch the key numbers of that stock:
https://trader.di.se/index.php/quote/nyckeltal/730

The code is shown below:
The new script is 24 lines of code, compared with the original C program with 300+ lines of code.
The data is encapsulated in table tags. The regex command generates a list of all matches, and I cherry-pick the data I want.

The next step was to add StockReader to scheduled tasks in windows.

No comments:

Post a Comment