cbilson/ib-re-actor — pull request #6 by cbilson (2013-01-04 13:01:14+00:00)
Title: Fix register-contract/lookup-contract

These functions won't consider `{:symbol "AAPL" :exchange "ISLAND"}` and `{:symbol "AAPL" :exchange "ISLAND" :currency "USD"}` as the same security. If I request ticks for both, ib-re-actor will have two entries in `@id->contract` and make two requests. I am not sure if Interactive Brokers will send the same ticks for both ticker ids (maybe it will ignore one of them?), but even if it did, this is kind of dumb.

Not sure if it would be better to go back to having the client track their own ticker-ids (that was how this used to work, and it was kind of a pain,) or forge onward and implement full-blown tracking of contract details.

The following is just kind of brain-stormy. If no one cares, I will probably try to do this sometime in the future.

I think "full-blown" tracking of contract details would involve:
* When we see a contract, like inside of `request-market-data`, we already call `register-contract` to see if we already have a ticker-id to use for this. Inside of `register-contract`, I think it should look for a match with a comparison function instead of using the contract as a key to lookup the ticker id. I think the comparison function could be pretty simple: if both have some subset of symbol, local-symbol, currency, exchange, contract-id, ..., then use those to compare and it's the same security if you have a match.
* When we see a new contract, kick off a request to get contract details for it. When we get a response, update our copy of the contract details.
* Since contract details have some time-specific data in them (trading/liquid hours, margin reqs., etc,) we need to refresh them from time to time. Maybe we could use the trading hours as some kind of a signal to refresh?

Writing this out has made me realize it's probably too much stuff for a library that is supposed to be a _wrapper_. On the other hand I hate to have to implement this every time I build an application that uses ib-re-actor.

I have been considering starting a new project to build a host for trading algorithms. I have a couple of poorly designed applications I could replace if I did this, and it would be easier to maintain than several applications. The host could manage security reference data (as mentioned above) and keep that stuff out of the wrapper library. It would also include facilities to schedule things like activating trading programs at certain times and other market schedule driven processing.

Is anyone interested in pursuing a separate project (and revert to request-id based calls inside ib-re-actor) or should we fix the security reference data inside ib-re-actor?