Difference between revisions of "Programming performance/JN K"

From HaskellWiki
Jump to navigation Jump to search
 
m
 
Line 5: Line 5:
 
<blockquote><pre>
 
<blockquote><pre>
 
/ parse quotes
 
/ parse quotes
D:|1_*(" F ";" ")0:`:/tmp/gspc.txt
+
D:|1_*(" F ";" ")0:`:gspc.txt
   
 
/ Cash and Portfolio (price -> quantity)
 
/ Cash and Portfolio (price -> quantity)

Latest revision as of 18:08, 9 March 2007

Submission in K. Start to finish time: 17 minutes.
RaymondH showed me his, so this might not be entirely originial.
I tried not to look at any of the K solutions.

/ parse quotes
D:|1_*("    F  ";" ")0:`:gspc.txt

/ Cash and Portfolio (price -> quantity)
C:10000.00; P:(`u#0#0.)!0#0.

/ Trading strategy
T:{if[~.97<x%y; P[x]+:(b:C%10)%x; C-:b]; C+:x*+/P p:p@&~1.06>x%p:!P; P[p]:0.}

/ run strategy on each pair (current and previous) of prices
(*D)T':D;

/ Sell off remaining
C+:+/.:[P]**|D