Saturday, 22 June 2019

StockAnalyzer: Scanning the Stock Files for Data

Now, I will start to interpret the data in the input files (YYYYDDMM.csv) and generate SQL commands based on that information.

I will start by analyzing the headers of all the data files.

I collect all unique headers to a stringlist and print the contents to the console.

There is plenty of data but I will only use some of it. The data that is common for all three different kinds of versions are:
  • Name,
  • Price (P),
  • Earning per share (E),
  • P/E - This is redundant and can be calculated from P and E. I'll use this to verify  P, E and P/E values
  • Annual Dividend (D)
  • Stock Yield (D/P) - This is redundant and can be used to verify P, D and D/P
  • Capital per Share (C)
  • Price/Capital (P/C) - This is redundant and can be used to verify P, C and P/C
  • RSI - Indicator of volatility
  • TA - Technical Analysis. This information was available for the first years.
  • Date for Dividend - Only available for later stocks
  • Date for report - Only available for later stocks

I will start by scanning one file and extract the values.
The first line is the header. If that header string hasn't been detected before, the program will add that header to a list of headers.

The other lines contains the stock data and I'll parse them to parseRecordToDatabase that extracts the relevant data and creates a SQL query that adds the record to the database.
 I will use a switch case to identify the different headers.
 I will split the each line of the file into the different data points and do some initial integrity checks of the data.
After the checks, I will create a SQL query string to enter the data to the database. I'll parse that string to my database handler.

Next steps:
  • Add counters for the number of records that I was able to decode and add to the database
  • Add two case clauses for the other two types of input data
  • Add checks for the input data for errors
  • Analyze a file only if the corresponding date doesn't exist in the database.
  • Refactor and clean up code

No comments:

Post a Comment