当前位置: 首页>>代码示例>>Python>>正文


Python Contract.m_multiplier方法代码示例

本文整理汇总了Python中ib.ext.Contract.Contract.m_multiplier方法的典型用法代码示例。如果您正苦于以下问题:Python Contract.m_multiplier方法的具体用法?Python Contract.m_multiplier怎么用?Python Contract.m_multiplier使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ib.ext.Contract.Contract的用法示例。


在下文中一共展示了Contract.m_multiplier方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: set_contract_ib

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_multiplier [as 别名]
 def set_contract_ib(self, symbol, sec_type, exchange, currency, multiplier, expiry):
     contract = Contract()
     contract.m_symbol = symbol
     contract.m_secType = sec_type
     contract.m_exchange = exchange
     contract.m_currency = currency
     contract.m_multiplier = multiplier
     contract.m_expiry = expiry
     self.contract = contract
开发者ID:joosthoeks,项目名称:jhBacktest2,代码行数:11,代码来源:data.py

示例2: newContract

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_multiplier [as 别名]
def newContract(symbol, secType, optType="", strike=0, expiry=""):
    contract = Contract()
    contract.m_symbol = symbol
    contract.m_secType = secType
    contract.m_exchange = "SMART"
    contract.m_primaryExchange = "SMART"
    contract.m_currency = "USD"
    contract.m_expiry = expiry  # dateString
    contract.m_strike = float(strike)
    contract.m_multiplier = 100
    contract.m_right = optType
    return contract
开发者ID:jtbuttram,项目名称:Mammoth,代码行数:14,代码来源:marketObjects.py

示例3: mkContract

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_multiplier [as 别名]
def mkContract(symbol, secType='STK', exchange='SMART',currency='USD',exp='',strike=0.0,right='',multiplier=100):
    ''' create contract object '''
    c = Contract()
    c.m_symbol = symbol
    c.m_secType= secType
    c.m_exchange = exchange
    c.m_currency = currency
    c.m_expiry = exp
    c.m_strike = strike
    c.m_right = right
    c.m_multiplier=multiplier
    return c
开发者ID:hezhenke,项目名称:myIbPy,代码行数:14,代码来源:interactivebrokers.py

示例4: makeContract

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_multiplier [as 别名]
def makeContract(contractTuple):
    newContract = Contract()
    newContract.m_symbol = contractTuple[0]
    newContract.m_secType = contractTuple[1]
    newContract.m_exchange = contractTuple[2]
    newContract.m_currency = contractTuple[3]
    newContract.m_expiry = contractTuple[4]
    newContract.m_strike = contractTuple[5]
    newContract.m_right = contractTuple[6]
    if len(contractTuple) > 7:
        if contractTuple[1] == "OPT":
            newContract.m_multiplier = contractTuple[7]
    return newContract
开发者ID:dailypips,项目名称:pyalgotrade,代码行数:15,代码来源:barfeed.py

示例5: place_order

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_multiplier [as 别名]
    def place_order(self, instrument, expiry, quantity, acc=None):
        """
        Send API request to place an order on the exchange.
        :param instrument: core.instrument.Instrument object
        :param expiry: contract label
        :param quantity: order size as a signed integer (quantity > 0 means 'BUY'
                         and quantity < 0 means 'SELL')
        :param acc: IB account to place order from, if None - the default account will be used
        """
        contract = Contract()
        contract.m_symbol = instrument.ib_code
        contract.m_secType = 'FUT'
        # place_order expects the contract label here, not the actual expiration date
        contract.m_expiry = expiry
        contract.m_exchange = instrument.exchange
        contract.m_currency = instrument.denomination
        if hasattr(instrument, 'ib_trading_class'):
            contract.m_tradingClass = instrument.ib_trading_class
        if hasattr(instrument, 'ib_multiplier'):
            contract.m_multiplier = instrument.ib_multiplier

        order = Order()
        order.m_orderType = 'MKT'
        order.m_algoStrategy = 'Adaptive'
        order.m_algoParams = [TagValue('adaptivePriority', 'Patient')]
        order.m_totalQuantity = int(abs(quantity))
        order.m_action = quantity > 0 and 'BUY' or 'SELL'
        if acc is not None:
            order.m_account = acc.name
            self.last_account = acc
        logger.warning(
            ' '.join(['Order:', str(self.order_id), contract.m_symbol, contract.m_expiry, \
                      order.m_action, str(order.m_totalQuantity)]))
        self.connection.placeOrder(self.order_id, contract, order)
        self.orders_cache[self.order_id] = {'contract': contract,
                                            'order': order}
        # order_id may not update just after the order is submitted so we save the previous one and
        # keep requesting until it's updated or we hit the time/iterations limit
        prev_id = self.order_id
        i = 0
        while prev_id >= self.order_id:
            sleep(self.api_delay)
            i += 1
            logger.debug('Requesting next order_id..')
            self.connection.reqIds(1)
            self.next_id_event.wait(timeout=(self.api_delay * 30))
            self.next_id_event.clear()
            if i > 60:
                logger.warning("Couldn't obtain next valid order id. Next orders may not be"
                               "submitted correctly!")
                return
开发者ID:renc,项目名称:PyTrendFollow,代码行数:53,代码来源:ibstate.py

示例6: create_contract

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_multiplier [as 别名]
 def create_contract(self, symbol, secType, exchange, currency,
                     right = None, strike = None, expiry = None,
                     multiplier = None, tradingClass = None):
     contract = Contract()
     contract.m_symbol = symbol
     contract.m_secType = secType
     contract.m_exchange = exchange
     contract.m_currency = currency
     contract.m_right = right
     contract.m_strike = strike
     contract.m_expiry = expiry
     contract.m_multiplier = multiplier
     contract.m_tradingClass = tradingClass
     return contract
开发者ID:anthonyng2,项目名称:ib,代码行数:16,代码来源:IBWrapper.py

示例7: makeContract

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_multiplier [as 别名]
def makeContract(symbol, derivative, exchange, expiration = None, 		strike = None, call_put = None, currency = "USD", tradingClass = None, multiplier = None):
	contract = Contract()
	contract.m_symbol = symbol
	contract.m_secType = derivative
	contract.m_exchange = exchange
	contract.m_currency = currency
	if derivative == "OPT":
		contract.m_expiry = expiration
		contract.m_strike = strike
		contract.m_right = call_put
		contract.m_multiplier = multiplier
		contract.m_tradingClass = tradingClass
	if derivative == "FUT":
		contract.m_expiry = expiration
	
	return contract
开发者ID:wcant,项目名称:ib-options,代码行数:18,代码来源:getHistOpt.py

示例8: makecontract

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_multiplier [as 别名]
    def makecontract(self, symbol, sectype, exch, curr,
                     expiry='', strike=0.0, right='', mult=1):
        '''returns a contract from the parameters without check'''

        contract = Contract()
        contract.m_symbol = bytes(symbol)
        contract.m_secType = bytes(sectype)
        contract.m_exchange = bytes(exch)
        if curr:
            contract.m_currency = bytes(curr)
        if sectype in ['FUT', 'OPT', 'FOP']:
            contract.m_expiry = bytes(expiry)
        if sectype in ['OPT', 'FOP']:
            contract.m_strike = strike
            contract.m_right = bytes(right)
        if mult:
            contract.m_multiplier = bytes(mult)
        return contract
开发者ID:DDZZ1995,项目名称:backtrader,代码行数:20,代码来源:ibstore.py

示例9: craft_contract_option

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_multiplier [as 别名]
def craft_contract_option(details, strike, expiry):
	print(strike)
	print(expiry)
	if isinstance(details, dict):
		try:			
			newContract = Contract()
			newContract.m_symbol = details['symbol']
			newContract.m_secType = details['security_type']
			newContract.m_primaryExch = details['primary_exchange']
			newContract.m_exchange = details['exchange']
			newContract.m_currency = details['currency']
			newContract.m_multiplier = details['multiplier']
			newContract.m_right = details['right']
			newContract.m_expiry = expiry
			newContract.m_strike = strike # not sure how comfortable I am with float representation...anyway...
			return newContract
		except:
			raise TypeError
	else:
		raise TypeError
开发者ID:hestinr12,项目名称:simple_algo_trading,代码行数:22,代码来源:contract.py

示例10: get_market_data

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_multiplier [as 别名]
    def get_market_data(self, connection):
        """ IB function to retrieve market data per contract """
        sys.stdout.write("Calling Market Data\n")

        # Loop through all options contracts
        for _, option in OPTIONS.iterrows():
            contract_values = Contract()
            contract_values.m_symbol = option['m_symbol']
            contract_values.m_localSymbol = option['m_localSymbol']
            contract_values.m_exchange = "SMART"
            contract_values.m_currency = "USD"
            contract_values.m_secType = "OPT"
            contract_values.m_multiplier = option['m_expiry']
            contract_values.m_expiry = option['m_expiry']
            contract_values.m_strike = option['m_strike']
            contract_values.m_right = option['m_right']
            contract_values.m_conId = option['m_conId']

            connection.reqMktData(str(option['m_conId']), \
                                                    contract_values, "", True)
            sleep(1)

        sleep(30)
开发者ID:LumbaJack,项目名称:Plan-Visualizer,代码行数:25,代码来源:interactivebroker.py

示例11: processMsg

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_multiplier [as 别名]

#.........这里部分代码省略.........
         parentId = 0
         if version >= 3:
             parentId = self.readInt()
         lastFillPrice = 0
         if version >= 4:
             lastFillPrice = self.readDouble()
         clientId = 0
         if version >= 5:
             clientId = self.readInt()
         whyHeld = None
         if version >= 6:
             whyHeld = self.readStr()
         self.eWrapper().orderStatus(id, status, filled, remaining, avgFillPrice, permId, parentId, lastFillPrice, clientId, whyHeld)
     elif msgId == self.ACCT_VALUE:
         version = self.readInt()
         key = self.readStr()
         val = self.readStr()
         cur = self.readStr()
         accountName = None
         if version >= 2:
             accountName = self.readStr()
         self.eWrapper().updateAccountValue(key, val, cur, accountName)
     elif msgId == self.PORTFOLIO_VALUE:
         version = self.readInt()
         contract = Contract()
         if version >= 6:
             contract.m_conId = self.readInt()
         contract.m_symbol = self.readStr()
         contract.m_secType = self.readStr()
         contract.m_expiry = self.readStr()
         contract.m_strike = self.readDouble()
         contract.m_right = self.readStr()
         if version >= 7:
             contract.m_multiplier = self.readStr()
             contract.m_primaryExch = self.readStr()
         contract.m_currency = self.readStr()
         if version >= 2:
             contract.m_localSymbol = self.readStr()
         position = self.readInt()
         marketPrice = self.readDouble()
         marketValue = self.readDouble()
         averageCost = 0.0
         unrealizedPNL = 0.0
         realizedPNL = 0.0
         if version >= 3:
             averageCost = self.readDouble()
             unrealizedPNL = self.readDouble()
             realizedPNL = self.readDouble()
         accountName = None
         if version >= 4:
             accountName = self.readStr()
         if (version == 6) and (self.m_parent.serverVersion() == 39):
             contract.m_primaryExch = self.readStr()
         self.eWrapper().updatePortfolio(contract, position, marketPrice, marketValue, averageCost, unrealizedPNL, realizedPNL, accountName)
     elif msgId == self.ACCT_UPDATE_TIME:
         version = self.readInt()
         timeStamp = self.readStr()
         self.eWrapper().updateAccountTime(timeStamp)
     elif msgId == self.ERR_MSG:
         version = self.readInt()
         if version < 2:
             msg = self.readStr()
             self.m_parent.error(msg)
         else:
             id = self.readInt()
             errorCode = self.readInt()
开发者ID:Jicheng-Yan,项目名称:ib-py,代码行数:70,代码来源:EReader.py

示例12: Contract

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_multiplier [as 别名]
        order.m_orderType = order_type
        order.m_totalQuantity = qty
        order.m_action = action
        # more functionalities....
        return order


# In[23]:

ng = Contract()
ng.m_symbol = "CN"
ng.m_secType = "FUT"
ng.m_exchange = "SGX"
ng.m_expiry = "20161129"
ng.m_currency = "USD"
ng.m_multiplier = 1
ng.m_tradingClass = "CN"


# In[24]:

TWS = tws(ng) 


# In[25]:

TWS.connect()
#TWS.con.connect()


# In[26]:
开发者ID:InsomniaGoku,项目名称:-silentcrusader,代码行数:33,代码来源:Ib_Proj_1.py


注:本文中的ib.ext.Contract.Contract.m_multiplier方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。