Like most things in the story the natural sciences can tell about the world, it’s all so beautiful, so gracefully simple, yet so rewardingly complex, so neatly connected – not to mention true – that I can’t even begin to imagine why anyone would ever want to believe some New Age ‘alternative’ nonsense instead. I would go so far as to say that even if we are all under the control of a benevolent God, and the whole of reality turns out to be down to some flaky spiritual ‘energy’ that only alternative therapists can truly harness, that’s still neither so interesting nor so graceful as the most basic stuff I was taught at school about how plants work.

...imagine a puddle waking up one morning and thinking, ‘This is an interesting world I find myself in’an interesting hole I find myself in’fits me rather neatly, doesn’t it? In fact it fits me staggeringly well, must have been made to have me in it!’ This is such a powerful idea that as the sun rises in the sky and the air heats up and as, gradually, the puddle gets smaller and smaller, it’s still frantically hanging on to the notion that everything’s going to be alright, because this world was meant to have him in it, was built to have him in it; so the moment he disappears catches him rather by surprise. I think this may be something we need to be on the watch out for.
(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 tried to buy hangers at Argos today. You poke through a phone book sized catalog, pick numbers of items you want and then a clerk gets them for you. The conversation went something like this:
Ben: I don't see any hangers in your catalog, but you sell them right?
Clerk: Yes. Let's see... page 143. But, they usually sell out as soon as we get them in. I'll check if we have any. No. Let me see if any of the surrounding stores have any... No.
Ben: When will you get more in?
Clerk: I don't know.
Ben: Is there anywhere else I can get hangers around here?
Clerk: I don't know.
Ben: Thanks anyway.
Demand > Supply -> Order more hangers. Right? What's next, toilet paper shortages?
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?
Seems strangely familiar.
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