I have a table in mysql db that has, among other fields, the following:
stock ticker, buy/sell code, transaction_date, insiderCik, filterFlag, create_date
I want to do the following:
For all transaction for the past 6 months (where DATE_SUB(CURDATE(),INTERVAL 180 DAY) <= create_date
1. find out the stock ticker that has 3 different insiderCIk buy (buy/sell code = B and filterFlag != Y) within a 5 day span (by transaction_date) and order the tickers by the latest transaction's file_date desc. The latest transaction's create_date is the buy date
2. for each ticker above, find out the date which there is no more insider buy for the 5 days before that date, this is the sell date
3. find the closing price for the stock for the buy date and the sell date and calucate the return (sell price/buy price - 1). Only keep those with positive returns.
4. generate the final output for the top 5 or 10 distinctive stocks with some html tags around, I will give you the detail tags once you accept the project:
ticker buyDate closePriceBuyDate sellDate ClosePriceSellDate return
I can give you programs on how to connect to the db and query sqls. I also have utility programs which takes stock ticker and a date and returns the close price for that date.
8/10/07 Clearification:
1. I need a standalone java progrom, you cannot do everything in sql (see below for why)
2. the pricing comes from a third party website (I have java utility method to call and get the price, to you it is a black box function taking in date and symbol and return closing price)
3. I've attached my table schema and 3 months of sample data (90k rows) in the attached zip file
## Deliverables
1) Complete and fully-functional working program(s) in executable form as well as complete source code of all work done.
2) Deliverables must be in ready-to-run condition, as follows (depending on the nature of the deliverables):
a) For web sites or other server-side deliverables intended to only ever exist in one place in the Buyer's environment--Deliverables must be installed by the Seller in ready-to-run condition in the Buyer's environment.
b) For all others including desktop software or software the buyer intends to distribute: A software installation package that will install the software in ready-to-run condition on the platform(s) specified in this bid request.
3) All deliverables will be considered "work made for hire" under U.S. Copyright law. Buyer will receive exclusive and complete copyrights to all work purchased. (No GPL, GNU, 3rd party components, etc. unless all copyright ramifications are explained AND AGREED TO by the buyer on the site per the coder's Seller Legal Agreement).
## Platform
Fedora 2
Java 1.4.2_05
Mysql 3.23