Developing an artificial intelligence program around the true value of a company.
Files - So Far
Functions to control access to postgres database. There are two main methods of doing this in this app.
main() - test for if my db is working. It returns the version of Postgres I'm using.
table_create(self) - creates a table named after whatever stock I decide to query.
write_database(self) - lets me write stuff to my db
read_database(self) - reads stuff back from my db
pandas_read(self) - reads database into a pandas data frame. This is where the magic starts happening. I cannot recommend this enough!
close_database(self) - closes my connection to prevent random connections hanging around and mucking up my computer.
Builds basic stock query functionality. This allows me to access any stock listed on Yahoo Finance and query all of their records, storing results on my own database. Ultimately this will form the basis for the AI engine I am creating.
Functions (so far)
stock_data(self) - initial method for yahoo finance. Takes a stock code and converts it into a format the yahoo-finance wrapper can understand.
hist_data(self, start_date,end_date) - takes arguments of the stock code and the start and end dates I'd like to query. This function will take a while to run as it downloads a ton of data from yahoo.
store_data(self, stock_code, start_date,end_date) - building on hist_data, this function takes the returned data and inserts it into a postgres table named after the queried stock. This will take even longer as each line needs to be parsed and stored separately.
Starts to return the data to me. Although this is the simplest of the modules to build, it is also the most useful one. Over time this will form the basis for the AI engine and is most likely to be the backend to my eventual Django app.
Functions (so far):
pull_date_price_data(self, start_date, end_date) - As stated in the postgres column, this is where you can choose between direct SQL manipulation or getting into the world of Pandas. I chose Pandas. This method simply takes the stock I wish to query, the date range I care about and reads it into a variable. So far I'm up to 3500 records with no issues which is trivial in the data mining space.
plot_graphs.time_price_line(self, start_date,end_date) - displays a line graph of price each day over a date range. I chose to use Plotly for this as it means I don't have to do any JSON manipulation. However if you wish to get into the JSON space, I'd recommend highcharts - http://www.highcharts.com It's a beautiful program as well with tons of options. I've used it successfully with Ruby on Rails, ASP and ASP.NET
plot_graphs.two_comparison_price(self, company2,start_date,end_date) - pretty much the same as the single plot but compares two companies together.