Skip to content
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.

Remove incorrect code from contract details decoder #664

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

djkelleher
Copy link

Problem - The current contract details decoder contains a bit of code that should only be used in the bond contract details decoder.

Effect - The function first correctly assigns the timeZoneId, but then later in the function body overwrites it with the timezone TWS is set to use.

Solution - Delete the extra code.

For reference, here is the logic from the official API from Interactive Brokers:

def readLastTradeDate(self, fields, contract: ContractDetails, isBond: bool):
        lastTradeDateOrContractMonth = decode(str, fields)
        if lastTradeDateOrContractMonth is not None:
            if '-' in lastTradeDateOrContractMonth: 
                splitted = lastTradeDateOrContractMonth.split('-')
            else:
                splitted = lastTradeDateOrContractMonth.split()
                
            if len(splitted) > 0:
                if isBond:
                    contract.maturity = splitted[0]
                else:
                    contract.contract.lastTradeDateOrContractMonth = splitted[0]

            if len(splitted) > 1:
                contract.lastTradeTime = splitted[1]

            if isBond and len(splitted) > 2:
                contract.timeZoneId = splitted[2]

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant