<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-7447615856962529940</id><updated>2011-04-21T18:11:34.120-07:00</updated><title type='text'>j/k</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://eachright.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7447615856962529940/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://eachright.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>J</name><uri>http://www.blogger.com/profile/06851614180315372274</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>16</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7447615856962529940.post-8048061631055196653</id><published>2009-01-30T05:16:00.000-08:00</published><updated>2009-01-30T05:36:09.801-08:00</updated><title type='text'>A New Computer</title><content type='html'>It's probably been 10 years since I've bought a new computer. I feel like it's a good habit to develop on older, less advanced hardware- it makes you write tighter code (256MB of memory anyone). But the house computer died, and it was time to build a new media center. Since this is a once a decade purchase- I got the signoff from the boss lady to do it "my way".&lt;br /&gt;&lt;br /&gt;So I went with a true media center.&lt;br /&gt;I got a 902 Euni Case off ebay, with the board, CPU and Fan off eBay for 700$.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://3.bp.blogspot.com/_e-yYJH56fac/SYL-02TjLrI/AAAAAAAAAFE/MehVGVkjWmQ/s1600-h/902_1.jpg"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 214px;" src="http://3.bp.blogspot.com/_e-yYJH56fac/SYL-02TjLrI/AAAAAAAAAFE/MehVGVkjWmQ/s320/902_1.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5297076295625289394" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://3.bp.blogspot.com/_e-yYJH56fac/SYL-6ScxiXI/AAAAAAAAAFM/eLIzjMYFHLU/s1600-h/902_gallery.jpg"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 184px;" src="http://3.bp.blogspot.com/_e-yYJH56fac/SYL-6ScxiXI/AAAAAAAAAFM/eLIzjMYFHLU/s320/902_gallery.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5297076389079517554" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;This is the setup (to start)&lt;br /&gt;&lt;br /&gt;MSI Platinum 975x Power Up Edition MotherBoard&lt;br /&gt;Intel Dual Core E6600 @ 2.4Ghz&lt;br /&gt;HD Tuner Card&lt;br /&gt;On Board 5.1 Sound&lt;br /&gt;&lt;br /&gt;Now to tune this up I put in dual OCZ 64GB SSD Drives. These drives are rates 155/90 MBs Read/Write. I put them in Raid 0. Then some more memory, OCZ 4GB DDR800 (29$ ?!? I remember when 4GB of memory was 1k!). &lt;br /&gt;Then Off to the OS. I went with Vista... my first experience. I chose the 32bit version for ompatibility (nobody writes 64bit drivers yet, and it is a family computer). After the intense install, and the absurd driver dectective work... Vista was up. After 5 hours of registry hacks, service disabling, process removal, etc... Vista was usable.&lt;br /&gt;&lt;br /&gt;Let me be the first to say, SSD drives are amazing. The applications load instantly, the OS boots from cold in 20 seconds (be sure to enable the boot manager to use both cores... why this isn't enabled by default is beyond me). I threw in a 7900GT graphics card, because honestly it's good enough and I'm not a gamer. HD picture is perfect, video's are clear and crisp. Just a wonderful little machine. Ans those SSD drives? See below&lt;br /&gt;&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/_e-yYJH56fac/SYMAZZpPgsI/AAAAAAAAAFU/iizU5tR-0ho/s1600-h/readrate.PNG"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 256px;" src="http://2.bp.blogspot.com/_e-yYJH56fac/SYMAZZpPgsI/AAAAAAAAAFU/iizU5tR-0ho/s320/readrate.PNG" border="0" alt=""id="BLOGGER_PHOTO_ID_5297078023098434242" /&gt;&lt;/a&gt;&lt;br /&gt;Read Rates&lt;br /&gt;&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/_e-yYJH56fac/SYMAiXOC50I/AAAAAAAAAFc/EvLH6b_q718/s1600-h/filerate.PNG"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 256px;" src="http://1.bp.blogspot.com/_e-yYJH56fac/SYMAiXOC50I/AAAAAAAAAFc/EvLH6b_q718/s320/filerate.PNG" border="0" alt=""id="BLOGGER_PHOTO_ID_5297078177066313538" /&gt;&lt;/a&gt;&lt;br /&gt;File ReaD and Write Rates (SSD write is not up to par just yet, but still absurdly quick).&lt;br /&gt;&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/_e-yYJH56fac/SYMAnuB2_lI/AAAAAAAAAFk/CfCPUJW1lCE/s1600-h/accesstime.PNG"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 256px;" src="http://2.bp.blogspot.com/_e-yYJH56fac/SYMAnuB2_lI/AAAAAAAAAFk/CfCPUJW1lCE/s320/accesstime.PNG" border="0" alt=""id="BLOGGER_PHOTO_ID_5297078269088562770" /&gt;&lt;/a&gt;&lt;br /&gt;Access time..... nuff said&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;A little h2benchw (from the German mag C't) sums it up nicely&lt;br /&gt;**********************************************************************&lt;br /&gt;Interface transfer rate w/ block size 128 sectors at 0.0% of capacity:&lt;br /&gt;Sequential read rate medium (w/out delay): 273626 KByte/s&lt;br /&gt;Sequential transfer rate w/ read-ahead (delay: 0.26 ms): 1201217 KByte/s&lt;br /&gt;Repetitive sequential read ("core test"): 1757337 KByte/s&lt;br /&gt;&lt;br /&gt;Sustained transfer rate (block size: 128 sectors):&lt;br /&gt;Reading:   average 270946.7, min 147388.7, max 279534.2 [KByte/s]&lt;br /&gt;&lt;br /&gt;Random access read:  average 0.22, min 0.17, max 0.38 [ms]&lt;br /&gt;Random access read (&lt;504 MByte):  average 0.23, min 0.03, max 0.55 [ms]&lt;br /&gt;&lt;br /&gt;Application profile `swapping': 64632.6 KByte/s&lt;br /&gt;Application profile `installing': 32218.5 KByte/s&lt;br /&gt;Application profile `Word': 99457.5 KByte/s&lt;br /&gt;Application profile `Photoshop': 91775.7 KByte/s&lt;br /&gt;Application profile `copying': 220664.1 KByte/s&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7447615856962529940-8048061631055196653?l=eachright.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://eachright.blogspot.com/feeds/8048061631055196653/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7447615856962529940&amp;postID=8048061631055196653' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7447615856962529940/posts/default/8048061631055196653'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7447615856962529940/posts/default/8048061631055196653'/><link rel='alternate' type='text/html' href='http://eachright.blogspot.com/2009/01/new-computer.html' title='A New Computer'/><author><name>J</name><uri>http://www.blogger.com/profile/06851614180315372274</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_e-yYJH56fac/SYL-02TjLrI/AAAAAAAAAFE/MehVGVkjWmQ/s72-c/902_1.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7447615856962529940.post-3095018141196455251</id><published>2007-09-07T11:23:00.000-07:00</published><updated>2007-09-07T11:29:03.077-07:00</updated><title type='text'>riddles</title><content type='html'>I was under the impression that riddles were out of style for interviews. I was wrong. Don't get me wrong, I love a good brain teaser- but as a criteria for hiring? &lt;br /&gt;My favorite are the "personal probing riddles"&lt;br /&gt;I actually got this today&lt;br /&gt;&lt;br /&gt;q:"if you were stuck on a desert island what 3 items would you bring with you"&lt;br /&gt;me:"seriously?"&lt;br /&gt;q:"yeah"&lt;br /&gt;me:"ok. a boat, a sat phone. and a tank of gas"&lt;br /&gt;q:"oh"&lt;br /&gt;me:"what would you take?"&lt;br /&gt;q:"well, generally people say their favorite book or something"&lt;br /&gt;me:"that wont get you off the island."&lt;br /&gt;q:"no, it wouldn't.&lt;br /&gt;me:"next question"&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7447615856962529940-3095018141196455251?l=eachright.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://eachright.blogspot.com/feeds/3095018141196455251/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7447615856962529940&amp;postID=3095018141196455251' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7447615856962529940/posts/default/3095018141196455251'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7447615856962529940/posts/default/3095018141196455251'/><link rel='alternate' type='text/html' href='http://eachright.blogspot.com/2007/09/riddles.html' title='riddles'/><author><name>J</name><uri>http://www.blogger.com/profile/06851614180315372274</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7447615856962529940.post-6917376360686818393</id><published>2007-09-04T18:43:00.000-07:00</published><updated>2007-09-04T19:00:49.419-07:00</updated><title type='text'>the times, they are a changing</title><content type='html'>So, the dust has settled... mostly. &lt;br /&gt;The world has calmed... mostly. &lt;br /&gt;And the market has stabalized- er, well at least it's not tanking- er, at least not as bad as a couple of weeks ago. &lt;br /&gt;&lt;br /&gt;And now is the time for change. &lt;br /&gt;&lt;br /&gt;At my firm, it began with mortgages (pronounced "morgue-ages"). Then onto CDO. I get that. Then onto repo. OK. And now, it has began to spread everywhere. My firm was not a trading firm- purely brokerage. Riskless. That was until my division came around. As a whole, I think we did ok, but the scare has changed things. Books are flattening, and you can taste change in the air. &lt;br /&gt;&lt;br /&gt;And so, after 2 years, and my best month of trading ever (seriously- it was ridiculous. 100% win rate one day. 122mm traded. 100%! Come on) I find my self looking for another job, which is a real shame because I loved my job. I loved my boss. And I loved that the solutions to the problems we were solving were always just out of our reach- which kept us reaching. I loved my team, small and fast, the way all things should be. Most of all I loved my freedom- it was a lab first- a trading desk second. And although at the time I sweated the actual trading- looking back it was good for me personally.&lt;br /&gt;&lt;br /&gt;I'm not afraid of change, I was always ready to leave if required. I've had the number for a truck driving school as my desktop for almost 2 months. Change is good. It means a new challenge, new problems, and new people/friends. And so on that note, if you're looking for either&lt;br /&gt;&lt;br /&gt;a. A professional surfer for your southern California team. Or...&lt;br /&gt;b. A new statistical arbitrage group. Or...&lt;br /&gt;c. A kdb+ programmer (I've decided not to work in another language except if absolutely necessary)&lt;br /&gt;&lt;br /&gt;Then drop me a line.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7447615856962529940-6917376360686818393?l=eachright.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://eachright.blogspot.com/feeds/6917376360686818393/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7447615856962529940&amp;postID=6917376360686818393' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7447615856962529940/posts/default/6917376360686818393'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7447615856962529940/posts/default/6917376360686818393'/><link rel='alternate' type='text/html' href='http://eachright.blogspot.com/2007/09/times-they-are-changing.html' title='the times, they are a changing'/><author><name>J</name><uri>http://www.blogger.com/profile/06851614180315372274</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7447615856962529940.post-4055846293888952723</id><published>2007-07-20T08:13:00.000-07:00</published><updated>2007-07-20T08:14:26.542-07:00</updated><title type='text'>Fridays (again)</title><content type='html'>Yup. Worst day ever. Just further reinforcement that coming in on Friday's is bad for me, bad for business.  All over by 10AM.&lt;br /&gt;Damn.&lt;br /&gt;j&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7447615856962529940-4055846293888952723?l=eachright.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://eachright.blogspot.com/feeds/4055846293888952723/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7447615856962529940&amp;postID=4055846293888952723' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7447615856962529940/posts/default/4055846293888952723'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7447615856962529940/posts/default/4055846293888952723'/><link rel='alternate' type='text/html' href='http://eachright.blogspot.com/2007/07/fridays-again.html' title='Fridays (again)'/><author><name>J</name><uri>http://www.blogger.com/profile/06851614180315372274</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7447615856962529940.post-1752546441191901218</id><published>2007-07-19T04:31:00.000-07:00</published><updated>2007-07-19T10:40:32.869-07:00</updated><title type='text'>redundancy</title><content type='html'>I've always said (and I picked it up from somewhere) that for every 9 you want to add to your uptime, multiply your initial cost by 9.&lt;br /&gt;So if you have a 10mm USD data center, and you want to go from 99 to 99.9% uptime, you need a 90mm data center infrastructure. Why? Well lets take a look&lt;br /&gt;&lt;br /&gt;You need back up generators, back up network lines, which means changing the data center architecture to support all that. Redundant gas lines for the generators. Failover for power sources etc (would have been cheaper to build it like that in the first place)-8mm&lt;br /&gt;You need double the hardware, and multiple components in all the hardware you have (dual nic etc)- 7mm&lt;br /&gt;You need a DR data center in another location, with the same setup- 15mm.&lt;br /&gt;You need a new high speed line for the center links, and a new line for the DR site (different clec)- 2mm&lt;br /&gt;You need to upgrade the SAN with real time LUN level replication, and buy one for the DR site - 5mm&lt;br /&gt;You need clustering, on everything (oracle,sybase, windows, unix, linux ...), custom coded apps need to be re-written for active failover- 25mm (includes services)&lt;br /&gt;You need the buy staff to deal with active/active failover, and 24x7 operation- 4mm&lt;br /&gt;You need load balancing and/or fail over network operations for inbound and outbound connections (data feeds etc)- 10mm (at least!)&lt;br /&gt;Since you have 2 different physical locations now (hopefully not the same state) you need new services contracts- 1mm&lt;br /&gt;&lt;br /&gt;So thats only 78mm more, or 8x the original cost. But I'm sure I could spend the extra 12mm on something I've forgotten.&lt;br /&gt;&lt;br /&gt;The best DRS I've ever seen was at the Depart of the Navy. Everything was a virtual machine. Live snapshots of the VM's was taken every hour or so. The snapshots were saved to an EMC SAN- which had real time replication to 5 other locations. All locals replicated to all remotes. Every remote site had a small cluster of "failover machines". The network was designed by Cisco and everything could automagically routed wherever. So, the entire data center in VA gets blown up (or whatever). The alarm fires, the VM's are started at the primary failover site (NC), they come online, routers do their thing (the DoD has the benefit of their own network) and wallah. Magic data center moved. Worst case loss, 1 hour. Failover time for the entire data center- 5-10 minutes (AND no application restart- they are hot snapshot loads). beautiful.&lt;br /&gt;&lt;br /&gt;So, having built a couple of data centers in my day, and coded many an application for active failover, and having deployed clustering on every version of windows since NT4 and Red hat- when a data center is down for say 7 hours, I think people should not only be fired, but any contractors should be sued. I'm not saying who's data center went down, but let's just say it was bad. &lt;br /&gt;Oh, kdb+ failover is trivial. Everything I do is in a pub/sub model. So aside from an extra machine in my data center- I push everything to my desktop. So when the lights went out, I still knew my positions.&lt;br /&gt;J&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7447615856962529940-1752546441191901218?l=eachright.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://eachright.blogspot.com/feeds/1752546441191901218/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7447615856962529940&amp;postID=1752546441191901218' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7447615856962529940/posts/default/1752546441191901218'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7447615856962529940/posts/default/1752546441191901218'/><link rel='alternate' type='text/html' href='http://eachright.blogspot.com/2007/07/redundancy.html' title='redundancy'/><author><name>J</name><uri>http://www.blogger.com/profile/06851614180315372274</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7447615856962529940.post-6223830716594204558</id><published>2007-07-18T05:22:00.000-07:00</published><updated>2007-07-19T10:43:13.112-07:00</updated><title type='text'>BSC- sorry about that</title><content type='html'>Sorry, we lost all the money. Well- 90% of it, but the other 10% is ours. &lt;br /&gt;In other news, we have some free flights to Florida for you- and all you need to do is attend a 2 hour presentation on the wonderful oppertunity for real estate in the greater Miami area.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7447615856962529940-6223830716594204558?l=eachright.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://eachright.blogspot.com/feeds/6223830716594204558/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7447615856962529940&amp;postID=6223830716594204558' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7447615856962529940/posts/default/6223830716594204558'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7447615856962529940/posts/default/6223830716594204558'/><link rel='alternate' type='text/html' href='http://eachright.blogspot.com/2007/07/bsc-sorry-about-that.html' title='BSC- sorry about that'/><author><name>J</name><uri>http://www.blogger.com/profile/06851614180315372274</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7447615856962529940.post-3910488182684650561</id><published>2007-07-11T06:08:00.001-07:00</published><updated>2007-07-11T06:16:19.654-07:00</updated><title type='text'>maths</title><content type='html'>I've tossed this around to a bunch of people, so I thought I'd toss it out here and maybe someone would know an answer:&lt;br /&gt;&lt;br /&gt;Given 3 series, A B and C&lt;br /&gt;Solve for the next value of each series subject to the constraints:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;correlation of A&amp;B&gt;=.9&lt;br /&gt;correlation of B&amp;C&gt;=.9&lt;br /&gt;correlation of A&amp;C&gt;=.85&lt;br /&gt;&lt;br /&gt;deviation of A is &lt;=.051&lt;br /&gt;deviation of B is &lt;=.051&lt;br /&gt;deviation of C is &lt;=.051&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;There are multiple correct answers, I'm looking for as many as possible as quickly as possible.&lt;br /&gt;&lt;br /&gt;Here's some sample data&lt;br /&gt;&lt;br /&gt;A  B  C&lt;br /&gt;2.47 3.453 4.263&lt;br /&gt;2.476 3.405 4.211&lt;br /&gt;2.484 3.429 4.228&lt;br /&gt;2.46 3.377 4.178&lt;br /&gt;2.395 3.309 4.119&lt;br /&gt;2.387 3.298 4.115&lt;br /&gt;2.46 3.394 4.215&lt;br /&gt;2.582 3.494 4.296&lt;br /&gt;2.591 3.508 4.293&lt;br /&gt;2.55 3.456 4.24&lt;br /&gt;2.469 3.363 4.161&lt;br /&gt;2.485 3.411 4.197&lt;br /&gt;2.485 3.404 4.188&lt;br /&gt;2.469 3.36 4.137&lt;br /&gt;2.436 3.343 4.126&lt;br /&gt;2.478 3.377 4.166&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7447615856962529940-3910488182684650561?l=eachright.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://eachright.blogspot.com/feeds/3910488182684650561/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7447615856962529940&amp;postID=3910488182684650561' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7447615856962529940/posts/default/3910488182684650561'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7447615856962529940/posts/default/3910488182684650561'/><link rel='alternate' type='text/html' href='http://eachright.blogspot.com/2007/07/maths.html' title='maths'/><author><name>J</name><uri>http://www.blogger.com/profile/06851614180315372274</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7447615856962529940.post-1518552405095393154</id><published>2007-07-11T04:40:00.000-07:00</published><updated>2007-07-11T04:42:32.092-07:00</updated><title type='text'>Amending to a Matrix</title><content type='html'>Jamie did an excellent job on explaining this and I thought I share it (cleaning out old emails)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;A way of amending multiple points in a square matrix in one go. &lt;br /&gt;&lt;/span&gt;Take the following matrix:&lt;br /&gt;&lt;code&gt;&lt;span&gt;&lt;br /&gt;q)4 4#0&lt;br /&gt;(0 0 0 0;0 0 0 0;0 0 0 0;0 0 0 0)&lt;br /&gt;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;Let's say we want to add 1 to the diagonal (make it the identity matrix). We could get ourselves a list of coordinates (0 0;1 1;2 2;3 3) and do it one at a time, using over to pass the previous result forward each time:&lt;br /&gt;&lt;code&gt;&lt;span&gt;&lt;br /&gt;q).[;;+;1]/[4 4#0;(0 0;1 1;2 2;3 3)]&lt;br /&gt;(1 0 0 0;0 1 0 0;0 0 1 0;0 0 0 1)&lt;br /&gt;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;This would get pretty slow if the list of coordinates is large, since they are essentially scalar operations. So we can do as Arthur has done, flatten the matrix and use a bit of code to map the 2 dimensional coordinate to it's one dimensional equivalent:&lt;br /&gt;&lt;code&gt;&lt;span&gt;&lt;br /&gt;q)(4*4)#0&lt;br /&gt;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0&lt;br /&gt;q)4 sv flip (0 0;1 1;2 2;3 3)&lt;br /&gt;0 5 10 15&lt;br /&gt;q)@[(4*4)#0;4 sv flip (0 0;1 1;2 2;3 3);+;1]&lt;br /&gt;1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1&lt;br /&gt;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;The cut command gives us back the matrix from the flat vector:&lt;br /&gt;&lt;code&gt;&lt;span&gt;&lt;br /&gt;q)4 cut @[(4*4)#0;4 sv flip (0 0;1 1;2 2;3 3);+;1]&lt;br /&gt;(1 0 0 0;0 1 0 0;0 0 1 0;0 0 0 1)&lt;br /&gt;&lt;/code&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7447615856962529940-1518552405095393154?l=eachright.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://eachright.blogspot.com/feeds/1518552405095393154/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7447615856962529940&amp;postID=1518552405095393154' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7447615856962529940/posts/default/1518552405095393154'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7447615856962529940/posts/default/1518552405095393154'/><link rel='alternate' type='text/html' href='http://eachright.blogspot.com/2007/07/amending-to-matrix.html' title='Amending to a Matrix'/><author><name>J</name><uri>http://www.blogger.com/profile/06851614180315372274</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7447615856962529940.post-4761930740983014166</id><published>2007-07-10T12:36:00.000-07:00</published><updated>2007-07-11T04:38:33.444-07:00</updated><title type='text'>Data Mining in kdb+</title><content type='html'>I'm revisting the "billion query code" because many people have sent questions in.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Mining in Practice&lt;/span&gt;&lt;br /&gt;In general, if you can brute force all the solutions to a given search space (or phase space as my physics friends and wife say) - thats what you want to do. If you can't, time for a heuristic.&lt;br /&gt;What do I mean by space? Well lets consider an example:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.csie.ntu.edu.tw/%7Ekmchao/papers/2006_TCS_KMAXSUM.pdf"&gt;&lt;br /&gt;K- Maximum Sum Subarray Problem &lt;/a&gt;&lt;br /&gt;&lt;br /&gt;We have a table (arrayable) T&lt;br /&gt;&lt;span&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;n:10&lt;br /&gt;t:ungroup flip (`$/:.Q.a)!enlist each (26 0N#(26*n)?5)*(26 0N#(26*n)?-1 1)&lt;br /&gt;&lt;br /&gt;Which looks like&lt;br /&gt;q)show flip t&lt;br /&gt;a| 0  0  4  -2 -3 3  0  -4 1  -1&lt;br /&gt;b| 0  3  1  -4 -3 2  4  3  0  -3&lt;br /&gt;c| 4  -3 0  -1 -2 0  -3 -4 1  0&lt;br /&gt;...&lt;br /&gt;z| -1 2  0  3  -2 2  1  -3 0  2&lt;br /&gt;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Now I ask you to find the maximum sum of the column z, using any combination of the other variables. E.g. let's sort by column a&lt;br /&gt;&lt;br /&gt;We can see that if we use the range a&gt;=0&amp;a&lt;=5 then we have&lt;br /&gt;&lt;span&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;q)show flip `a xasc t&lt;br /&gt;a| -4 -3 -2 -1 &lt;span style="font-weight: bold;"&gt;0  0  0  1  3  4&lt;/span&gt;&lt;br /&gt;b| 3  -3 -4 -3 0  3  4  0  2  1&lt;br /&gt;c| -4 -2 -1 0  4  -3 -3 1  0  0&lt;br /&gt;...&lt;br /&gt;z| -3 -2 3  2  &lt;span style="font-weight: bold;"&gt;-1 2  1  0  2  0&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;What if we add the condition b&gt;=3? Then the intersection is...&lt;br /&gt;&lt;span&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;q)show flip `a xasc t&lt;br /&gt;a| -4 -3 -2 -1 &lt;span style="font-weight: bold;"&gt;0  0  0  1  3  4&lt;/span&gt;&lt;br /&gt;b| &lt;span style="font-weight: bold;"&gt;3&lt;/span&gt;  -3 -4 -3 0  &lt;span style="font-weight: bold;"&gt;3  4  0  2  1&lt;/span&gt;&lt;br /&gt;c| -4 -2 -1 0  4  -3 -3 1  0  0&lt;br /&gt;...&lt;br /&gt;z| -3 -2 3  2  -1&lt;span style="font-weight: bold;"&gt; 2  1  0  2  0&lt;/span&gt; //the -1 falls out&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Ok now what's the best we can do? How hard is this problem? If we consider all 3 dimensional solutions (e.g. using 1 a, 1 b and 1 d) the problem has */26 26 26 5 5 5 solutions (about 2 million). But in real life we have lots more values (more than 5) and generally more variables.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Breaking down the problem:&lt;/span&gt;&lt;br /&gt;A good place to start is to reduce the dimensionality by bucketing values. Consider placing value in &lt;span style="font-style:italic;"&gt;m&lt;/span&gt; uniform buckets. The code below does this- and quickly.&lt;br /&gt;Then you can do the search, this is ludicrously fast in q (arthur code of course).&lt;br /&gt;&lt;span&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;br /&gt;n:500000&lt;br /&gt;m:10&lt;br /&gt;t:([]a:n?1.0;b:n?1.0;c:n?1.0;d:n?1.0)&lt;br /&gt;f:`b`c`d&lt;br /&gt;&lt;br /&gt;/running totals in 2 dims&lt;br /&gt;s2:+\+\'(m;0N)#&lt;br /&gt;/ 3d aggrs&lt;br /&gt;f3:{s2'+\(m;0N)#@[(m*m*m)#0.0;m/:(x;(m-1)-y;z);+;t.z]}&lt;br /&gt;&lt;br /&gt;\t u:m .q.xrank't f&lt;br /&gt;\t r3:{u f3[x]\:/:u}'u&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/code&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7447615856962529940-4761930740983014166?l=eachright.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://eachright.blogspot.com/feeds/4761930740983014166/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7447615856962529940&amp;postID=4761930740983014166' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7447615856962529940/posts/default/4761930740983014166'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7447615856962529940/posts/default/4761930740983014166'/><link rel='alternate' type='text/html' href='http://eachright.blogspot.com/2007/07/data-mining-in-kdb.html' title='Data Mining in kdb+'/><author><name>J</name><uri>http://www.blogger.com/profile/06851614180315372274</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7447615856962529940.post-3178839654319035930</id><published>2007-07-06T11:17:00.001-07:00</published><updated>2007-07-06T11:28:52.208-07:00</updated><title type='text'>Stay home Friday's</title><content type='html'>So-&lt;br /&gt;yesterday and the day before the holiday were great days for me. I trade a pattern recognition system (which is just jargon for "matched patterns built from data mining to streaming data"). Most of the time the system trades as normal- never that big of a position- and life is fine. I win, I lose, but overall I'm up with a very small draw down. But the market has been wicked recently- like a skittish, rabid, cocaine addicted rabbit.&lt;br /&gt;&lt;br /&gt;So today I walk in, knowing it's going to be a bad day. Why? Well first of all it seems every time I trade on Friday (my day off) I lose- as if to reinforce the fact that I should have stayed home. But also after 2 big winning days- I was in for a loss.&lt;br /&gt;So the day goes like this&lt;br /&gt;&lt;br /&gt;5 AM- wake up/news&lt;br /&gt;5:30 Out the door&lt;br /&gt;5:45 At the office &lt;br /&gt;6:00 Turn on trading system (start q process), check last night's data, get coffee&lt;br /&gt;wait&lt;br /&gt;8:00 (or about) start trading&lt;br /&gt;8:30 lose $7500 on one trade- ok&lt;br /&gt;8:45 lose another 3k- still ok&lt;br /&gt;9:00 down another 10k mark to market- that sucks&lt;br /&gt;9:30 risk management and other stuff begins triggering (q is awesome)&lt;br /&gt;10:00 system fights back from down 20k to down only 11&lt;br /&gt;11:00 flat (down only 1k)&lt;br /&gt;12:00 market grinds down, no trades. At this point I contemplate going home.&lt;br /&gt;12:00:00.001 get long 10 mm&lt;br /&gt;12:10 get long another 10 mm (why not)&lt;br /&gt;12:30 %*^*&amp;*@!!!&lt;br /&gt;13:30 more %*^*&amp;*@!!!&lt;br /&gt;14:00 give up, risk management rolls out of positions, end the day down 30k.&lt;br /&gt;Fuck.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7447615856962529940-3178839654319035930?l=eachright.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://eachright.blogspot.com/feeds/3178839654319035930/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7447615856962529940&amp;postID=3178839654319035930' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7447615856962529940/posts/default/3178839654319035930'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7447615856962529940/posts/default/3178839654319035930'/><link rel='alternate' type='text/html' href='http://eachright.blogspot.com/2007/07/stay-home-fridays.html' title='Stay home Friday&apos;s'/><author><name>J</name><uri>http://www.blogger.com/profile/06851614180315372274</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7447615856962529940.post-8850738437568638491</id><published>2007-06-13T10:39:00.000-07:00</published><updated>2007-06-13T10:48:46.525-07:00</updated><title type='text'>The devil is in the details</title><content type='html'>&lt;span style="font-weight:bold;"&gt;Easy: &lt;/span&gt;&lt;br /&gt;getting real-time data from a financial exchange&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Harder:&lt;/span&gt; &lt;br /&gt;ensuring that data is correct&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Harder Still:&lt;/span&gt; &lt;br /&gt;interacting with the exchange and sending markets/orders cancels etc.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Harder Than That:&lt;/span&gt; &lt;br /&gt;maintaining a book with offsetting positions&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Really Really Really Hard:&lt;/span&gt; &lt;br /&gt;dealing with partial fills for new positions and/or exits&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Approaching Impossible:&lt;/span&gt; &lt;br /&gt;crossing those positions internally to save a trip and the spread, including partial filling, waiting for confirmation that outstanding markets&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Worthy of Arthur:&lt;/span&gt; &lt;br /&gt;doing all that, without loops, and a subsytem to minimize paying the spread via fancy bid-&gt; agress conversion logic.&lt;br /&gt;&lt;br /&gt;E.g. imagine you are long 5@100, looking for the market to goto 110$ in the next hour. Then you get short 10 @101, expecting the market to goto 99 in the next 30 minutes, in 30 minutes the market is 100- what do you do?&lt;br /&gt;Lets say you cross internally. You take the 5 longs off the book, so you cancel the offers for those 5 longs- but wait- while thats happening the market goes to 107/109.&lt;br /&gt;&lt;br /&gt;Now instead of 2 positions imagine 100, and instead of 1 price per position- imagine N distinct prices- and a market that jumps all over the place.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7447615856962529940-8850738437568638491?l=eachright.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://eachright.blogspot.com/feeds/8850738437568638491/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7447615856962529940&amp;postID=8850738437568638491' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7447615856962529940/posts/default/8850738437568638491'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7447615856962529940/posts/default/8850738437568638491'/><link rel='alternate' type='text/html' href='http://eachright.blogspot.com/2007/06/devil-is-in-details.html' title='The devil is in the details'/><author><name>J</name><uri>http://www.blogger.com/profile/06851614180315372274</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7447615856962529940.post-5579297548681253099</id><published>2007-06-11T12:37:00.001-07:00</published><updated>2007-06-11T12:52:06.069-07:00</updated><title type='text'>Some useful financial functions</title><content type='html'>thought these might be handy to a few people. I can't take credit for most:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://en.wikipedia.org/wiki/Drawdown_(economics)"&gt; Drawdown  &lt;/a&gt;&lt;br /&gt;&lt;code&gt; drawdown:{[x]v:u?max u:(maxs x)-x;(u v;x?x[v]+u v;v)};&lt;br /&gt;&lt;br /&gt;This returns a vector, the drawdown value, the index of the start and end of that period.&lt;br /&gt;&lt;br /&gt; &lt;/code&gt;&lt;br /&gt;&lt;a href="http://en.wikipedia.org/wiki/Exponential_moving_average#Exponential_moving_average"  &gt;EMA &lt;/a&gt;&lt;br /&gt;&lt;code&gt; ema:{[n;x]b:1-a:2%n+1;c:(sum n#x)%n;((n-1)#0n),c,c{[a;b;x;y](a*y)+b*x}[a;b]\n _x}; &lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Smooth Moving Average&lt;br /&gt;&lt;code&gt; smavg:{[n;x]((n-1)#0n),i,{(z+(x-1)*y)%x}[n]\[i:avg n#x;n _ x:0^x]}; &lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Max Consecutive Losses&lt;br /&gt;&lt;code&gt; MaxConsectiveLosers:(max count each "0"vs raze string pl&lt;0) &lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Convert Tics to Float and visa versa&lt;br /&gt;&lt;code&gt;&lt;br /&gt;f2tic:{[x]a:x - floor x;b:a%(1%32);c:floor(a -(floor b)%32)%(1%256);if[c=4;c:"+"];raze raze string(floor x),"-",string floor b, string floor c};&lt;br /&gt;&lt;br /&gt;tic2f:{("I"$n#x)+((8*"I"$x n+1 2)+"0123+567"?x 3+n:x?"-")%256.}&lt;br /&gt;&lt;/code&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7447615856962529940-5579297548681253099?l=eachright.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://eachright.blogspot.com/feeds/5579297548681253099/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7447615856962529940&amp;postID=5579297548681253099' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7447615856962529940/posts/default/5579297548681253099'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7447615856962529940/posts/default/5579297548681253099'/><link rel='alternate' type='text/html' href='http://eachright.blogspot.com/2007/06/some-useful-financial-functions.html' title='Some useful financial functions'/><author><name>J</name><uri>http://www.blogger.com/profile/06851614180315372274</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7447615856962529940.post-4644456751377525384</id><published>2007-05-25T05:24:00.000-07:00</published><updated>2007-06-11T13:19:06.654-07:00</updated><title type='text'>Back testing in Q</title><content type='html'>I get this all the time- how do you backtest a strategy.&lt;br /&gt;Well, here's a simple way. Every trade has 4 components- it's entry time, it's profit objective (ge: good exit)) it's stop limit (se- stop exit) and a time exit (te).&lt;br /&gt;The code below will, given a table with a column "entry" which is boolean and a price will backtest the strategy (this is a version for going long). I like to back test against quotes, but this is for prices (trades).&lt;br /&gt;&lt;br /&gt;&lt;span&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;font size="1"&gt;&lt;br /&gt;btL:{[t;gep;sep;tep]&lt;br /&gt; i_eb:where t`entry; &lt;font color=GREEN&gt; //where are the entry indicies&lt;/font&gt;&lt;br /&gt; i_te:(count t)^((t`time) bin/: ((t@i_eb)`time)+tep*1000); &lt;font color=GREEN&gt;//find the indicies for the time exits&lt;/font&gt;&lt;br /&gt; rng:{x+key floor (y-x)}'[i_eb;i_te]; &lt;font color=GREEN&gt;//define the ranges &lt;/font&gt;&lt;br /&gt; f_u:{[xe;limit;p;x]limit&amp;amp;x+xe&amp;gt;p x};f_l:{[xe;limit;p;x]limit&amp;amp;x+xe&amp;lt;p x}; &lt;font color=GREEN&gt;//functions for upper and lower limits &lt;/font&gt;&lt;br /&gt; e_pr:(t`entryprice)i_eb; &lt;font color=GREEN&gt; //define the entry prices &lt;/font&gt;&lt;br /&gt; i_ge:f_u[(e_pr+gep);i_te;t`bid1]/[i_eb]; &lt;font color=GREEN&gt; //indices for the good exits &lt;/font&gt;&lt;br /&gt; i_se:f_l[(e_pr-sep);i_te;t`bid1]/[i_eb];&lt;font color=GREEN&gt; //indices for the stop exits &lt;/font&gt;&lt;br /&gt; i_xe:min each v:(count t)^flip (i_te;i_ge;i_se); &lt;font color=GREEN&gt;//define the exit action &lt;/font&gt;&lt;br /&gt; x_ty:(`te`ge`se)@/:i_x:first each iasc each v; &lt;font color=GREEN&gt;//define the exit types&lt;/font&gt;&lt;br /&gt; x_pr:(t`bid1) i_xe;&lt;font color=GREEN&gt; //the exit price is the bid at the exit index&lt;/font&gt;&lt;br /&gt; x_pl:x_pr-(e_pr); &lt;font color=GREEN&gt;//the exit pnl is the exit price- entry price &lt;/font&gt;&lt;br /&gt; `entrytime`exittime`entryprice`exittype`exitprice`exitindx`pnl!((t`time)i_eb;(t`time)i_xe;e_pr;x_ty;x_pr;i_xe;x_pl)}&lt;br/&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;An example&lt;br /&gt;&lt;code&gt;&lt;br /&gt;n:1000;&lt;br /&gt;t:`time xasc flip `time`price`entry`entryprice!(n?`time$.z.Z;n?10;n?01b;n?10)&lt;br /&gt;btL[t;2;1;30] //go for 2$,risk 1$, hold for 30 seconds&lt;br /&gt;&lt;/code&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7447615856962529940-4644456751377525384?l=eachright.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://eachright.blogspot.com/feeds/4644456751377525384/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7447615856962529940&amp;postID=4644456751377525384' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7447615856962529940/posts/default/4644456751377525384'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7447615856962529940/posts/default/4644456751377525384'/><link rel='alternate' type='text/html' href='http://eachright.blogspot.com/2007/05/back-testing-in-q.html' title='Back testing in Q'/><author><name>J</name><uri>http://www.blogger.com/profile/06851614180315372274</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7447615856962529940.post-5082931464673802152</id><published>2007-05-25T05:17:00.000-07:00</published><updated>2007-05-25T05:23:58.112-07:00</updated><title type='text'>1 billion queries</title><content type='html'>Prior to a life in finance, I had a brief stint in root cause analysis for diseases for the Department of the Navy (NMIC).&lt;br /&gt;They problem was always the same- a ton of variables and some measure of sickness. For example you might have weight, age, blood pressure etc and on the right hand side you have a weighted value of sickness (visits, stage of disease etc). If I had q and arthur back then, I think we could have cured cancer. The code below does 1 billion queries in a couple of seconds, finding all 3 variable combinations. For example if the variables are `a`b`c, and the weighted death value is D then an example output is&lt;br /&gt;&lt;br /&gt;if a&gt;2,b&lt;3,d&gt;5 then the sum of D is 2345&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;n:500000&lt;br /&gt;m:5&lt;br /&gt;t:([]a:n?1.0;b:n?1.0;c:n?1.0;d:n?1.0;e:n?1.0)&lt;br /&gt;il:`b`c`d`e  //variable list il (independent list)&lt;br /&gt;&lt;br /&gt;k)f3:{s2'+\(m;0N)#@[(m*m*m)#0.0;m/:(x;(m-1)-y;z);+;t.a]}&lt;br /&gt;k)u:m .q.xrank't il&lt;br /&gt;k)r3:{u f3[x]\:/:u}':u&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7447615856962529940-5082931464673802152?l=eachright.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://eachright.blogspot.com/feeds/5082931464673802152/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7447615856962529940&amp;postID=5082931464673802152' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7447615856962529940/posts/default/5082931464673802152'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7447615856962529940/posts/default/5082931464673802152'/><link rel='alternate' type='text/html' href='http://eachright.blogspot.com/2007/05/1-billion-queries.html' title='1 billion queries'/><author><name>J</name><uri>http://www.blogger.com/profile/06851614180315372274</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7447615856962529940.post-1912943017626955356</id><published>2007-05-25T05:13:00.000-07:00</published><updated>2007-05-25T05:16:49.362-07:00</updated><title type='text'>CEP</title><content type='html'>Complex Event Processing- is overly complex.&lt;br /&gt;I don't go to trade shows anymore- or talk to vendors. This reminds me of the first large installations of networks in the 90's (WAN). The idea's were simple- and so was the base technology- but in order to make a buck vendors made the whole process so complicated and full of jargon that no-one knew what the hell was going on.&lt;br /&gt;&lt;br /&gt;Seriously&lt;br /&gt;&lt;br /&gt;Event processing is this&lt;br /&gt;&lt;br /&gt;kdb+tic-&gt; subscriber&lt;br /&gt;alert on subscriber-&gt; push out&lt;br /&gt;chain another subscriber.&lt;br /&gt;&lt;br /&gt;How hard is that?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7447615856962529940-1912943017626955356?l=eachright.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://eachright.blogspot.com/feeds/1912943017626955356/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7447615856962529940&amp;postID=1912943017626955356' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7447615856962529940/posts/default/1912943017626955356'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7447615856962529940/posts/default/1912943017626955356'/><link rel='alternate' type='text/html' href='http://eachright.blogspot.com/2007/05/cep.html' title='CEP'/><author><name>J</name><uri>http://www.blogger.com/profile/06851614180315372274</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7447615856962529940.post-3248962762884627725</id><published>2007-05-25T05:05:00.000-07:00</published><updated>2007-05-25T05:12:56.308-07:00</updated><title type='text'>kdb+ as the infrastructure</title><content type='html'>We use kdb+ as our sole technology infrastructure. Some people find that odd. What? No java? No C#? No Tibco? And then the inevitable.. "How do you..." So I thoughts I'd anwser some common questions.&lt;br /&gt;&lt;br /&gt;How do you?&lt;br /&gt;&lt;br /&gt;Q... Build GUI's&lt;br /&gt;A: In general we don't. We do use flash (adobe flex) to connect to kdb+ via q's built in XML parser- but that's only for show. We use the kdb+Excel link for real-time information. But in  general we have few GUI's.&lt;br /&gt;&lt;br /&gt;Q... Handle Risk Management&lt;br /&gt;A: kdb+tic is all you need for an event driven system. Risk management is just an event based decision process. Requested positions come in, they are checked against a bank of risk management rules, and either they are rejected or passed to the execution engine.&lt;br /&gt;&lt;br /&gt;Q... Execute trades&lt;br /&gt;A: The feedhandler works both ways. It can both capture data from the exchange and send it. This ensures that you are not making decisions you can't trade on.&lt;br /&gt;&lt;br /&gt;Q...Why kdb+&lt;br /&gt;A: Speed and simplicity. Our entire trading system- which is data capture, back testing, real time screening, risk management, execution and position management is about 8 pages and very very fast.&lt;br /&gt;&lt;br /&gt;Send in some questions and Ill post them here&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7447615856962529940-3248962762884627725?l=eachright.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://eachright.blogspot.com/feeds/3248962762884627725/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7447615856962529940&amp;postID=3248962762884627725' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7447615856962529940/posts/default/3248962762884627725'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7447615856962529940/posts/default/3248962762884627725'/><link rel='alternate' type='text/html' href='http://eachright.blogspot.com/2007/05/kdb-as-infrastructure.html' title='kdb+ as the infrastructure'/><author><name>J</name><uri>http://www.blogger.com/profile/06851614180315372274</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry></feed>
