(1) What are you doing?
(2) How can I help?
(3) What do I gain?
Virgin media disconnected my brand new fiber line for non-payment of my bill after 1 day of connectivity. My bill wasn't paid because Virgin put a "credit limit" on the account. This limit prevented them from taking the connection fee out of my bank account, despite the bank account itself having plenty of money. Now my access is going to be down for a day.
I pay for the downtime as well, since in their view this is my fault. You know, for being a foreigner.
Classification done at 2009-05-04T00:00:11.602436
The best symbol is HBC.
Scheduling trades for today.
Opening positions at 2009-05-04T09:29:30.100081
I am going to trade today.
action=buy~quantity=772~symbol=HBC~ordtype=Limit~price=36.65~expire=day~accountid=xxx
Waiting for order to fill...
772.0 shares filled at 36.65
action=sell~quantity=772.0~symbol=HBC~ordtype=Limit~price=37.38~expire=day~accountid=xxx
Closing positions at 2009-05-04T15:57:00.100089
We won today! All closed out.
I'm a fair way along writing the trade engine for arbit (what I call my statistical arbitrage program that's something like 2.5 years in the making (the name of which still makes me think of these)). I've started to realize that I'm writing a finite state machine, one which looks alarmingly like the one in TIBCO BusinessEvents (BE).
So, out of curiosity, I built up the state model using BE. I'm now thinking BE makes lot of sense for trade life cycle. I've pitched the idea before, but I think trying to write a trade engine from scratch has made it really obvious how valuable this is.

Now I just have to figure out how to do this in Python. I'm thinking for each trading day I create a new object and then progress it through with a bunch of flags. Yay for non scalable approaches!
I'm also starting to wonder if my one language to rule them all approach is a good idea. I use Python for most everything, with occasional calls into C for a couple libraries I need that don't exist in Python. Python interoperates natively with C, so this isn't a big deal. That said, it'd be nice to be able to call something mathy (Matlab, R, S+, even Mathematica), and there are about a billion things in Java that'd be nice to have.
I don't want to use Jython because I'm not convinced it has a future. The integration to the Ameritrade API is already as much code as my entire arbitrage program. Likewise, the cluster code is easily 3x the size of the arbitrage code. Then there's the market data scraper which is probably 5x the arbitrage code. Integration is hard... That said, I really like the idea of keeping it all in Python so this problem doesn't get worse.
I've read the book. I love it. If there is some hint of how to find you in it, I've missed it. As GK Ashe probably isn't available, let's go get dinner some other ridiculous place!
The Road Home by Rose Tremain is to Strawberry Fields by Marina Lewycka
as
House of Meetings by Martin Amis is to Russian Debutante's Handbook by Gary Shteyngart
In related flawed reasoning, there are trillions in outstanding lottery tickets. Every time a person buys a lottery ticket, the state is potentially obligated to pay millions of dollars. It's only a matter of time before everyone wins the lottery at once and the state is required to pay out millions to each of millions of lottery players.
End the lottery! It may seem like a boon to public resources now, but soon the bubble will burst and this house of cards will come tumbling down!
Um, no. Anyone heard of CBOE?
import xml.dom.minidom
def xmltodict(xmlstring):
doc = xml.dom.minidom.parseString(xmlstring)
return elementtodict(doc.documentElement)
def elementtodict(parent):
child = parent.firstChild
if (child.nodeType == xml.dom.minidom.Node.TEXT_NODE):
return child.nodeValue
d={}
while child is not None:
if (child.nodeType == xml.dom.minidom.Node.ELEMENT_NODE):
try:
d[child.tagName]
except KeyError:
d[child.tagName]=[]
d[child.tagName].append(elementtodict(child))
child = child.nextSibling
return d
Updated: Fixed a bug that didn't like null nodes and another about whitespace, though I stole some code from an O'Reilly book for that.
import xml.dom.minidom
def xmltodict(xmlstring):
doc = xml.dom.minidom.parseString(xmlstring)
remove_whilespace_nodes(doc.documentElement)
return elementtodict(doc.documentElement)
def elementtodict(parent):
child = parent.firstChild
if (not child):
return None
elif (child.nodeType == xml.dom.minidom.Node.TEXT_NODE):
return child.nodeValue
d={}
while child is not None:
if (child.nodeType == xml.dom.minidom.Node.ELEMENT_NODE):
try:
d[child.tagName]
except KeyError:
d[child.tagName]=[]
d[child.tagName].append(elementtodict(child))
child = child.nextSibling
return d
def remove_whilespace_nodes(node, unlink=True):
remove_list = []
for child in node.childNodes:
if child.nodeType == xml.dom.Node.TEXT_NODE and not child.data.strip():
remove_list.append(child)
elif child.hasChildNodes():
remove_whilespace_nodes(child, unlink)
for node in remove_list:
node.parentNode.removeChild(node)
if unlink:
node.unlink()
Update 2: Someone already did this in the 2nd edition of the Python Cookbook. There's another one here too: http://code.activestate.com/recipes/116539/. So much for there only being one way to do something in Python...
from xml.dom.minidom import parse, Node
def xmltodict(filename):
doc = parse(filename)
return elementtodict(doc.documentElement)
def elementtodict(parent):
child = parent.firstChild
if not child:
return None
while child.nodeType == Node.TEXT_NODE and not child.data.strip():
child = child.nextSibling
if child.nodeType == Node.TEXT_NODE:
return child.nodeValue
d={}
while child is not None:
if (child.nodeType == Node.ELEMENT_NODE):
try:
d[child.tagName]
except KeyError:
d[child.tagName]=[]
d[child.tagName].append(elementtodict(child))
if len(d[child.tagName]) == 1:
d[child.tagName] = d[child.tagName][0]
child = child.nextSibling
return d
def elementtodict(parent):
child = parent.firstChild
if (not child):
return None
elif (child.nodeType == xml.dom.minidom.Node.TEXT_NODE):
val = child.nodeValue
try:
if '.' in val:
val = float(val)
else:
val = int(val)
except ValueError:
pass
return val
d={}
while child is not None:
if (child.nodeType == xml.dom.minidom.Node.ELEMENT_NODE):
try:
d[child.tagName]
except KeyError:
d[child.tagName]=[]
d[child.tagName].append(elementtodict(child))
child = child.nextSibling
for key, val in d.items():
if type(val) is list and len(val) == 1:
d[key] = val[0]
return d It turns out there are more reasonable options between professional brokers and scraping yahoo, google, and Ameritrade pages:
http://www.interactivebrokers.com/ibg/main.php
http://www.tdameritrade.com/tradingtools/partnertools/api_dev.html
If you want to make GUIs (Graphical User Interfaces), I think .NET is the best choice. Of course it restricts you to PCs. Java is a close second, and will work on a Mac.
For .NET, you'd want a copy of Visual Studio. The free express edition is available here: http://www.microsoft.com/Express/
For Java, go with Eclipse: http://www.eclipse.org/
If you want to make lots of little graphs and such, then I think you would be best off with Matlab, though Mathematica and R are close seconds. R is free, the other two are not. http://www.r-project.org/
Finally, if you just want to crunch numbers, manipulate things and generally understand how to program, I think Python is the answer. Python is going to be the easiest of all these to get started with. So you could try it and then switch to something else if you run into a wall. http://wiki.python.org/moin/BeginnersGuide/NonProgrammers
-----begin diatribe --------
You will see lots of this sort of thing in the programming community...
I'd avoid C, C++, JavaScript, Visual Basic, Excel, Objective C, Lisp, Scheme, Haskell, Ruby, any type of assembly, machine code, PHP, Perl, Pascal, and the people who will try to push them on you for a whole bunch of other ones for various reasons.
All that said, if you want to jump into Linux land for some reason, you are going to be forced to learn C. In fact, if you have a Mac you are already trapped in UNIX land, which is pretty similar to Linux land. If that's the case, maybe start with Python then and move over to C once you notice the limitations. This book is the best way to learn C.
Stay away from anything written by Bruce Eckel. His books will be confusing until well after you've learned to program.
I was going to document my crappy little studio in encruciating detail. However, my camera died after the first picture. It now takes very blue pictures:
Adjusting the contrast (in Photoshop) makes it look kind of neat (Why yes, I am bored. Thanks for asking.):
This blog seems to be all about navel gazing. I really don't like that phrase... or the sound of that sentence. Here's the post from the night I got the camera. If I remember correctly, I was staying at Austin's. Changes.
My poor camera was a Canon Elph SD110. 3.2 megapixels! It was a big step up from the junk Fuji I had before. I think that was 1.something. It didn't have a zoom, so you could turn it on very quickly and snap photos. I liked that.
From the file names, I know I took 1108 pictures with the Elph. Assuming it cost something like $200, that's about $0.18 per picture, or $6.50 for 36.
I also feel compelled to point out that I'm a little odd in the way I use digital cameras. I don't tend to take photos indiscriminently. The Elph has an intentionally tiny memory card, which forced me to use my precious 10 photos carefully. I like that, somehow.
When I try to load the camera application on my BlackBerry Curve I get an out of memory error. So, these are probably the last photos for a while.
I have a bunch on clothes that I'd like to stuff in the huge open space in my bathroom. If I can get them out of my main living space, I'll have more room for books (on actual shelves) and my abode will look less like a college student's, and I will grow to love my dark hole of a home. I will also be able to buy wing chairs.
Problem is, I've been buying clothing that likes to be hung up. So, I really need to racks, each about 30" long. What's the best way to accomplish this?
One thought would be to buy some pipe, T, and L joints, kind of like I had in Seattle holding the floor up. Question is, how would I attach these to brick, tile, drywall, and a partly tiled over door without doing too much damage? Could I use one of those telescoping structural supports they use to hold up ceilings? What are those even called? Ideas?
Alternatively I could build a wall and then use traditional clothes hanging type bars. It would probably look better, but it'd be a lot of work and probably piss my landlord off (and he has something like £1500 of mine, so I'd rather do this in some easily reversible way). Anyway, wall like so:
My drawings are excellent!
What would it take to get two unsupported posts pointing perpendicular out of the wall, each with 100lbs of clothes? Maybe that's the way to go?
Or just a ceiling support in the drywall? That might be more reasonable. I would still need to attach pipe to brick in some fairly reliable manner.
Arg! Is this place temporary? Should I spend £100 on this, then more on furniture? Will I be here for 6 months, 1 year? That seems long. 6 months is a good upper limit. Then I move... somewhere. So, maybe I shouldn't bother... anyone have any easy suggestions?
In America, first you cook the vegetables, then you throw out the water, then you eat the vegetables.
In France, first you cook the vegetables, then you throw out the vegetables, then you eat the water.
I was told there would be flying cars. Now they say I can’t have a car at all. This is not the future, but the numbers keep going up anyway.