B
     9-eò  ã               @   s¤   d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ e	dƒ\Z
ZZZG dd	„ d	eƒZG d
d„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZdS )zÊ
Copyright (C) 2019 Interactive Brokers LLC. All rights reserved. This code is subject to the terms
 and conditions of the IB API Non-Commercial License or the IB API Commercial License, as applicable.
é    )ÚObject)ÚUNSET_DECIMAL)ÚintMaxString)ÚfloatMaxString)ÚdecimalMaxStringé   c               @   s   e Zd Zdd„ Zdd„ ZdS )ÚComboLegc             C   s4   d| _ d| _d| _d| _d| _d| _d| _d| _d S )Nr   Ú éÿÿÿÿ)ÚconIdÚratioÚactionÚexchangeÚ	openCloseÚshortSaleSlotÚdesignatedLocationÚ
exemptCode)Úself© r   ú°G:\My Drive\STUDY\EPAT\09 TBP - Trading & Back-testing Platforms\TBP04 - Backtesting & Live Trading\IB IBridgePy API\02 Python 3.7 IBridgePy_Win_Anaconda37_64\ibapi\contract.pyÚ__init__   s    zComboLeg.__init__c             C   sJ   d  t| jƒt| jƒt| jƒt| jƒt| jƒt| jƒt| j	ƒt| j
ƒf¡S )Nú,)Újoinr   r   r   Ústrr   r   r   r   r   r   )r   r   r   r   Ú__str__%   s    zComboLeg.__str__N)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r   r      s   r   c               @   s   e Zd Zdd„ Zdd„ ZdS )ÚDeltaNeutralContractc             C   s   d| _ d| _d| _d S )Nr   g        )r   ÚdeltaÚprice)r   r   r   r   r   2   s    zDeltaNeutralContract.__init__c             C   s"   d  t| jƒt| jƒt| jƒf¡S )Nr   )r   r   r   r   r   r    )r   r   r   r   r   7   s    zDeltaNeutralContract.__str__N)r   r   r   r   r   r   r   r   r   r   1   s   r   c               @   s   e Zd Zdd„ Zdd„ ZdS )ÚContractc             C   s|   d| _ d| _d| _d| _d| _d| _d| _d| _d| _d| _	d| _
d| _d| _d| _d| _d| _d| _d| _d | _d | _d S )Nr   r	   g        F)r   ÚsymbolÚsecTypeÚlastTradeDateOrContractMonthÚstrikeÚrightÚ
multiplierr   ÚprimaryExchangeÚcurrencyÚlocalSymbolÚtradingClassÚincludeExpiredÚ	secIdTypeÚsecIdÚdescriptionÚissuerIdÚcomboLegsDescripÚ	comboLegsÚdeltaNeutralContract)r   r   r   r   r   ?   s(    zContract.__init__c             C   sâ   d  t| jƒt| jƒt| jƒt| jƒt| jƒt| jƒt| j	ƒt| j
ƒt| jƒt| jƒt| jƒt| jƒt| jƒt| jƒt| jƒt| jƒt| jƒf¡}|d| j 7 }| jrÆx| jD ]}|dt|ƒ 7 }q®W | jrÞ|dt| jƒ 7 }|S )Nr   zcombo:ú;)r   r   r   r"   r#   r$   r   r%   r&   r'   r   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   )r   ÚsZlegr   r   r   r   X   s2    zContract.__str__N)r   r   r   r   r   r   r   r   r   r!   >   s   r!   c               @   s   e Zd Zdd„ Zdd„ ZdS )ÚContractDetailsc             C   s  t ƒ | _d| _d| _d| _d| _d| _d| _d| _d| _	d| _
d| _d| _d| _d| _d| _d| _d| _d| _d| _d| _d| _d | _d| _d| _d| _t| _t| _t| _d| _d| _d| _ d| _!d| _"d| _#d| _$d| _%d| _&d| _'d| _(d| _)d| _*d| _+d| _,d S )Nr	   g        r   F)-r!   ÚcontractÚ
marketNameÚminTickÚ
orderTypesÚvalidExchangesÚpriceMagnifierÚ
underConIdÚlongNameÚcontractMonthÚindustryÚcategoryÚsubcategoryÚ
timeZoneIdÚtradingHoursÚliquidHoursÚevRuleÚevMultiplierÚaggGroupÚunderSymbolÚunderSecTypeÚmarketRuleIdsÚ	secIdListÚrealExpirationDateÚlastTradeTimeÚ	stockTyper   ÚminSizeÚsizeIncrementÚsuggestedSizeIncrementÚcusipÚratingsÚ
descAppendÚbondTypeÚ
couponTypeÚcallableÚputableÚcouponÚconvertibleÚmaturityÚ	issueDateÚnextOptionDateÚnextOptionTypeÚnextOptionPartialÚnotes)r   r   r   r   r   x   sV    zContractDetails.__init__c          -   C   s^  d  t| jƒt| jƒt| jƒt| jƒt| jƒt| j	ƒt| j
ƒt| jƒt| jƒt| jƒt| jƒt| jƒt| jƒt| jƒt| jƒt| jƒt| jƒt| jƒt| jƒt| jƒt| jƒt| jƒt| jƒt| jƒt| jƒt| jƒt| jƒt| jƒt| j ƒt| j!ƒt| j"ƒt| j#ƒt| j$ƒt| j%ƒt| j&ƒt| j'ƒt| j(ƒt| j)ƒt| j*ƒt+| j,ƒt+| j-ƒt+| j.ƒf*¡}|S )Nr   )/r   r   r7   r8   r   r9   r:   r;   r   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rI   rJ   rK   rH   rL   rM   rO   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   r   rP   rQ   rR   )r   r5   r   r   r   r   ¦   sX    zContractDetails.__str__N)r   r   r   r   r   r   r   r   r   r6   w   s   .r6   c               @   s   e Zd Zdd„ ZdS )ÚContractDescriptionc             C   s   t ƒ | _d | _d S )N)r!   r7   ÚderivativeSecTypes)r   r   r   r   r   ×   s    zContractDescription.__init__N)r   r   r   r   r   r   r   r   rb   Ö   s   rb   N)Ú__doc__Úibapi.object_implemr   Úibapi.commonr   Úibapi.utilsr   r   r   ÚrangeZSAME_POSZOPEN_POSZ	CLOSE_POSZUNKNOWN_POSr   r   r!   r6   rb   r   r   r   r   Ú<module>   s   
9_