Hi all,
We're excited to preview a new feature that hopefully makes your code more readable. It's still experimental, so it is sure to have bugs, and is sure to change. Please use it with care until we finalize the feature. But do try it out and let us know what you think and whether there are any improvements we should make.
Before, if you wanted to buy Apple stock, you had to refer to the stock in the code as SID(24) which is not the most intuitive way. The new feature allows you to just use symbol('AAPL') instead to the same effect.
This is so obvious that you might wonder why we haven't done this from the start. The reason is that these symbols change over time. For example G used to refer to Gilette but now refers to Genpact. So if you write symbol('G') how can we know which one you want? The SIDs are always unique so that made them an easier way for us to start.
If you do use symbol('G') we will raise an error and tell you that this is ambiguous and tell you the different options, e.g.:
Multiple symbols with the name 'G' found. Use the as_of_date' argument to to specify when the date symbol-lookup should be valid. Possible options:
[Security(3082, symbol=u'G', security_name=u'GILLETTE CO', exchange=u'NEW YORK STOCK EXCHANGE', start_date=datetime.datetime(1993, 1, 4, 0, 0, tzinfo=), end_date=datetime.datetime(2005, 9, 30, 0, 0, tzinfo=), first_traded=None),
Security(34442, symbol=u'G', security_name=u'GENPACT LTD', exchange=u'NEW YORK STOCK EXCHANGE', start_date=datetime.datetime(2007, 8, 2, 0, 0, tzinfo=), end_date=datetime.datetime(2014, 3, 10, 0, 0, tzinfo=), first_traded=None)]
You can then let symbol() know which one you want by supplying any date at which the symbol lookup should be valid:
symbol('G', as_of_date='2014-3-5')
Note that we could have used any date in the range of 2007-8-2 until 2014-3-10. Symbols are also not case-sensitive so symbol('aapl') resolves to the same symbol.
This way of specifying the stock may not be perfect yet. The obvious solution would be to just use the most recent symbol->security match but this could change over time and we want your algorithms to behave the same way a year from now and not start using new symbols. A better alternative would be to have an additional command you execute once in initialize along the lines of:
set_symbol_lookup_date('2014-3-5')
And all symbol() calls will resolve securities that match on this particular day.
Anyway, we look forward to your feedback!
Thomas