PG: I am playing around with some historical stock option data, and have decided to use a database to make my life easier. The data is "end-of- day" for all equitable options, so something like 17 columns and approximately 200,000 rows a day. I have several months of data in "csv" format, one file for each trading day.
After some simple experiments, I found it was easier to import this data directly into postgresql than into mysql, because of the expiration date format being un-friendly to mysql. I'm using the COPY command to load the data. I realize I have a lot of reading to do, but I would like to ask a few questions to help guide my reading. 1) The data contains the price of the underlying stock, the strike price of the option, and the option premium. From this I can calculate the "cost basis" and the "maximum potential profit", which are elements I would like to be able to SELECT and ORDER. Should I store the results of these calculation with the data, or is this "business logic" which doesn't belong in the database. Is this what views are for? 2) For each underlying stock there are lots of options, each having unique strike prices and expirations. For example, AAPL (apple computer) have stock options (calls and puts) that expire in June, at various strike prices. Lets say that apple stock is trading at $112. I would like to be able to select the options with strikes just above and below this price, for example $110 and $115. The data contains options with strikes from $60 through $125, every $5. Is this something I need to do programatically, or can I create a complex SQL query to extract this information? I have rudimentary python skills, and I'm getting the hang of psycopg2. After reading the postgresql manual, what should I read next? Thanks in advance, CJL ---------------------------(end of broadcast)--------------------------- TIP 6: explain analyze is your friend