The goal is to measure how long it takes to implement solutions to a standard problem in your programming language of choice and to see the various approaches different programmers take when implementing the solution. The goal isn't to finish the problem as quickly as possible but to rather to get some realistic measurements on programming speed and approaches.
- Programming performance/TimN Haskell
- Programming performance/TimN Python
- Programming performance/Magnus Haskell
- Programming performance/kc5tja Forth
- Programming performance/Apter K (added by kc5tja)
- Programming performance/hay.steve Python
Implement a program that computes the solution to the following problem in your language of choice. Measure how long it took you to make your initial implementation. Post the code and the amount of time it took. Please submit only your time and code for your first implementation in a given language. If you have implemented a solution previously in another language please mention that. You may submit further refinements of your solution or new solutions on the same page as your initial submission but the primary goals is to measure your initial solution and the amount of time required. If you wish, you may look at other solutions but it is preferable that you do not.
Submit your entry by creating a wiki page with your code, your time, the language used and a note about how comfortable you are with this language. If you relied on any help, such as reading other solutions, please state what sort of help you made use of. Please make just one page per participant per language. You may include any comments, refinements or alternate programs on this same page.
Simulate the following strategy on the GSPC data set:
- Whenever the closing cost is down 3% or more from the previous closing cost, buy shares with 10% of current cash.
- Whenever the closing cost is up 6% or more from the original purchase price, sell back the full amount of stock purchased at that price.
- Sell off any remaining assets after the last day.
Run the strategy on the provided data starting with $10,000.00 in cash and no holdings.
- All purchases are made at the closing cost.
- Fractional shares may be purchased.
- Fractional pennies may be used.
- Do not simulate any trading costs, interest dividends or taxes.
- Percent change is 100 percent times the change (new price minus old price) divided by the old price.
The http://www.thenewsh.com/gspc.txt file contains the test data. Any lines not starting with a hash sign ("#") contain valid data. Data is in space seperated columns. Each line represents one day's data with most recent date first. The first column contains the date and the last column contains the closing price. The number of columns is always the same.
Display the amount of cash held after executing the strategy. A mode that displays each buy and sell by date is useful, but optional.