Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Futures Contract String #31

Description

@3rock618

There are a few issues with the formula contractString for futures. on line 1480 you have localSymbol = contract.m_localSymbol.

There are two problems here:

  1. some exchanges use a different syntax for m_localSymbol for example DAX which trades on DTB details['m_localSymbol'] = 'FDAX JUN 19'. Or the Dow Jones (YM trading on ECBOT) has details['m_localSymbol'] = 'YM JUN 19'. On line 1503 you have the code exp = localSymbol[2:3] + self.localSymbolExpiry[localSymbol][:4]. Thus the first term (localSymbol[2:3]) in the DAX would be "A" and in "YM" would be " " (for which you have a backup).

  2. for symbols that have more than 2-character symbols, for example, RTY, localSymbol = "RTYM9" again the term localSymbol[2:3] is inappropriate here.

As this is so important for futures, this is what I would recommend:

From what I can tell details['m_contractMonth'] seems to be very reliable, slicing [-2:] would give you the best chance to get the correct letter code for expiry. If that's empty, then I would look to localSymbol, first checking for spaces. If there is no space use localSymbol[-2:-1]. If there are spaces, I would try to parse it 'localSymbol.split()[1]' and then use that to lookup against 3-letter month codes.

Unfortunately, if you want to standardize to using the expiry letter codes (which IS the correct choice), using m_expiry will sometimes lead you astray because the expiry date does not always happen in the month of coded expiration, for example, July gasoline m_expiry is 6/28. Many of the single month contracts have this problem. So mixing expiration day and expiration month can be confusing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions