<commit_before>'''ContractDetails data structure.'''

__copyright__ = "Copyright (c) 2008 <NAME>"
__version__   = "$Id$"

from tws import Contract as _contract_factory


class ContractDetails(object):
    '''Data structure with attributes used to describe contract details,
       including bond information.
    '''

    def __init__(self, summary=_contract_factory(), market_name="", trading_class="",
                 min_tick=0.0, order_types="", valid_exchanges="", under_con_id=0):
        self.m_summary = summary
        self.m_marketName = market_name
        self.m_tradingClass = trading_class
        self.m_minTick = min_tick
        self.m_orderTypes = order_types
        self.m_validExchanges = valid_exchanges
        self.m_underConId = under_con_id

        # Non-parameterized
        self.m_cusip = ""
        self.m_ratings = ""
        self.m_descAppend = ""
        self.m_bondType = ""
        self.m_couponType = ""
        self.m_callable = False
        self.m_putable = False
        self.m_coupon = 0
        self.m_convertible = False
        self.m_maturity = ""
        self.m_issueDate = ""
        self.m_nextOptionDate = ""
        self.m_nextOptionType = ""
        self.m_nextOptionPartial = False
        self.m_notes = ""


    def __eq__(self, other):  # Not in Java source. IB bug?
        if not isinstance(other, self.__class__): return False
        return True if (
            (self.m_summary == other.m_summary) and
            (self.m_marketName == other.m_marketName) and
            (self.m_tradingClass == other.m_tradingClass) and
            (self.m_minTick == other.m_minTick) and
            (self.m_orderTypes == other.m_orderTypes) and
            (self.m_validExchanges == other.m_validExchanges) and
            (self.m_underConId == other.m_underConId) and
            (self.m_cusip == other.m_cusip) and
            (self.m_ratings == other.m_ratings) and
            (self.m_descAppend == other.m_descAppend) and
            (self.m_bondType == other.m_bondType) and
            (self.m_couponType == other.m_couponType) and
            (self.m_callable == other.m_callable) and
            (self.m_putable == other.m_putable) and
            (self.m_coupon == other.m_coupon) and
            (self.m_convertible == other.m_convertible) and
            (self.m_maturity == other.m_maturity) and
            (self.m_issueDate == other.m_issueDate) and
            (self.m_nextOptionDate == other.m_nextOptionDate) and
            (self.m_nextOptionType == other.m_nextOptionType) and
            (self.m_nextOptionPartial == other.m_nextOptionPartial) and
            (self.m_notes == other.m_notes)
        ) else False
<commit_msg>Using tws.Contract constructor as a default parameter caused tws.ContractDetails to reuse the same contract object, stepping on other objects' Contract summaries in the process.<commit_after>'''ContractDetails data structure.'''

__copyright__ = "Copyright (c) 2008 <NAME>"
__version__   = "$Id$"

from tws import Contract as _contract_factory


class ContractDetails(object):
    '''Data structure with attributes used to describe contract details,
       including bond information.
    '''

    def __init__(self, summary=None, market_name="", trading_class="",
                 min_tick=0.0, order_types="", valid_exchanges="", under_con_id=0):
        self.m_summary = _contract_factory() if summary is None else summary 
        self.m_marketName = market_name
        self.m_tradingClass = trading_class
        self.m_minTick = min_tick
        self.m_orderTypes = order_types
        self.m_validExchanges = valid_exchanges
        self.m_underConId = under_con_id

        # Non-parameterized
        self.m_cusip = ""
        self.m_ratings = ""
        self.m_descAppend = ""
        self.m_bondType = ""
        self.m_couponType = ""
        self.m_callable = False
        self.m_putable = False
        self.m_coupon = 0
        self.m_convertible = False
        self.m_maturity = ""
        self.m_issueDate = ""
        self.m_nextOptionDate = ""
        self.m_nextOptionType = ""
        self.m_nextOptionPartial = False
        self.m_notes = ""


    def __eq__(self, other):  # Not in Java source. IB bug?
        if not isinstance(other, self.__class__): return False
        return True if (
            (self.m_summary == other.m_summary) and
            (self.m_marketName == other.m_marketName) and
            (self.m_tradingClass == other.m_tradingClass) and
            (self.m_minTick == other.m_minTick) and
            (self.m_orderTypes == other.m_orderTypes) and
            (self.m_validExchanges == other.m_validExchanges) and
            (self.m_underConId == other.m_underConId) and
            (self.m_cusip == other.m_cusip) and
            (self.m_ratings == other.m_ratings) and
            (self.m_descAppend == other.m_descAppend) and
            (self.m_bondType == other.m_bondType) and
            (self.m_couponType == other.m_couponType) and
            (self.m_callable == other.m_callable) and
            (self.m_putable == other.m_putable) and
            (self.m_coupon == other.m_coupon) and
            (self.m_convertible == other.m_convertible) and
            (self.m_maturity == other.m_maturity) and
            (self.m_issueDate == other.m_issueDate) and
            (self.m_nextOptionDate == other.m_nextOptionDate) and
            (self.m_nextOptionType == other.m_nextOptionType) and
            (self.m_nextOptionPartial == other.m_nextOptionPartial) and
            (self.m_notes == other.m_notes)
        ) else False

{'fraction_non_alphanumeric': 0.09867478510028653, 'fraction_numerical': 0.0028653295128939827, 'mean_word_length': 2.3563701923076925, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3793342', 'n_tokens_mistral': 1746, 'n_tokens_neox': 1722, 'n_words': 347}