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


Python Contract.m_right方法代码示例

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


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

示例1: sendOrder

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_right [as 别名]
 def sendOrder(self, orderReq):
     """发单"""
     # 增加报单号1,最后再次进行查询
     # 这里双重设计的目的是为了防止某些情况下,连续发单时,nextOrderId的回调推送速度慢导致没有更新
     self.orderId += 1
     
     # 创建合约对象
     contract = Contract()
     contract.m_symbol = str(orderReq.symbol)
     contract.m_exchange = exchangeMap.get(orderReq.exchange, '')
     contract.m_secType = productClassMap.get(orderReq.productClass, '')
     contract.m_currency = currencyMap.get(orderReq.currency, '')
     
     contract.m_expiry = orderReq.expiry
     contract.m_strike = orderReq.strikePrice
     contract.m_right = optionTypeMap.get(orderReq.optionType, '')
     
     # 创建委托对象
     order = Order()
     order.m_orderId = self.orderId
     order.m_clientId = self.clientId
     
     order.m_action = directionMap.get(orderReq.direction, '')
     order.m_lmtPrice = orderReq.price
     order.m_totalQuantity = orderReq.volume
     order.m_orderType = priceTypeMap.get(orderReq.priceType, '')
     
     # 发送委托
     self.connection.placeOrder(self.orderId, contract, order)
     
     # 查询下一个有效编号
     self.connection.reqIds(1)
开发者ID:Allen1203,项目名称:vnpy,代码行数:34,代码来源:ibGateway.py

示例2: subscribe

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_right [as 别名]
    def subscribe(self, subscribeReq):
        """订阅行情"""
        # 订阅行情
        self.tickerId += 1
        
        contract = Contract()
        contract.m_symbol = str(subscribeReq.symbol)
        contract.m_exchange = exchangeMap.get(subscribeReq.exchange, '')
        contract.m_secType = productClassMap.get(subscribeReq.productClass, '')
        contract.m_currency = currencyMap.get(subscribeReq.currency, '')
        contract.m_expiry = subscribeReq.expiry
        contract.m_strike = subscribeReq.strikePrice
        contract.m_right = optionTypeMap.get(subscribeReq.optionType, '')
        
        # 考虑设计为针对期货用代码_到期日的方式来代替单纯的代码
        if contract.m_secType == 'FUT' and not subscribeReq.expiry:
            # 期货 如果没有设置过期时间, 默认设置为下个月
            dt_obj = datetime.now()
            days = calendar.monthrange(dt_obj.year, dt_obj.month)[1]
            nextMonth = dt_obj + timedelta(days=(days - dt_obj.day + 1))
            contract.m_expiry = nextMonth.strftime('%Y%m')

        self.connection.reqMktData(self.tickerId, contract, '', False)
        
        # 获取合约详细信息
        self.connection.reqContractDetails(self.tickerId, contract)
        
        # 创建Tick对象并保存到字典中
        tick = VtTickData()
        tick.symbol = subscribeReq.symbol
        tick.exchange = subscribeReq.exchange
        tick.vtSymbol = '.'.join([tick.symbol, tick.exchange])
        tick.gatewayName = self.gatewayName
        tick.__setattr__('m_secType', productClassMap.get(subscribeReq.productClass, ''))
        self.tickDict[self.tickerId] = tick
开发者ID:Ainstain,项目名称:vnpy,代码行数:37,代码来源:ibGateway.py

示例3: create_contract

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_right [as 别名]
def create_contract(contract_tuple):
    new_contract = Contract()
    new_contract.m_symbol = str(contract_tuple['ib_symbol'])
    new_contract.m_secType = str(contract_tuple['ib_type'])
    new_contract.m_exchange = str(contract_tuple['ib_exchange'])
    new_contract.m_currency = str(contract_tuple['ib_currency'])
    new_contract.m_strike = float(contract_tuple['ib_strike'])
    new_contract.m_tradingClass = str(contract_tuple['ib_trading_class'])
    if contract_tuple['ib_expiry']:
        new_contract.m_expiry = str(contract_tuple['ib_expiry'])     
    else:
        new_contract.m_expiy = ''
    if contract_tuple['ib_right']:
        new_contract.m_right = str(contract_tuple['ib_right'])
    else:
        new_contract.m_right = ''
    return new_contract
开发者ID:volchemist,项目名称:monitoring,代码行数:19,代码来源:monitor.py

示例4: addoption

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_right [as 别名]
def addoption(ticker, exchg, expiry, strike, right):
    c = Contract()
    c.m_symbol = ticker
    c.m_secType = 'OPT'
    c.m_exchange = exchg
    c.m_expiry = expiry
    c.m_strike = float(strike)
    c.m_right = right
    addcontract(c, "Opt(" + exchg + ", " + expiry + ", " + str(strike) + ", " + right +")")
开发者ID:dm04806,项目名称:systemn,代码行数:11,代码来源:test.py

示例5: __make_ib_contract

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_right [as 别名]
 def __make_ib_contract(contract_tuple):
     new_contract = Contract()
     new_contract.m_symbol = contract_tuple[0]
     new_contract.m_secType = contract_tuple[1]
     new_contract.m_exchange = contract_tuple[2]
     new_contract.m_currency = contract_tuple[3]
     new_contract.m_expiry = contract_tuple[4]
     new_contract.m_strike = contract_tuple[5]
     new_contract.m_right = contract_tuple[6]
     return new_contract
开发者ID:ssg100,项目名称:ibpython,代码行数:12,代码来源:ibcontract.py

示例6: make_ib_contract

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_right [as 别名]
def make_ib_contract(contract_tuple):
    contract = Contract()
    contract.m_symbol = contract_tuple[0]
    contract.m_secType = contract_tuple[1]
    contract.m_exchange = contract_tuple[2]
    contract.m_currency = contract_tuple[3]
    contract.m_expiry = contract_tuple[4]
    contract.m_strike = contract_tuple[5]
    contract.m_right = contract_tuple[6]
    return contract
开发者ID:JulesTan,项目名称:IB-Trading-Models-And-Backtester,代码行数:12,代码来源:ibUtil.py

示例7: create_contract

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_right [as 别名]
def create_contract(symbol, sec_type='STK', expiry='', strike=0.0, right=''):
    contract = Contract()
    contract.m_symbol = symbol
    contract.m_secType = sec_type
    contract.m_exchange = 'SMART'
    contract.m_primaryExch = 'SMART'
    contract.m_currency = 'USD'
    contract.m_expiry = expiry
    contract.m_strike = strike
    contract.m_right = right
    return contract
开发者ID:gongqingyi,项目名称:stock,代码行数:13,代码来源:common.py

示例8: contract

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_right [as 别名]
def contract(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]
	print 'Contract Parameters: [%s,%s,%s,%s,%s,%s,%s]' % contractTuple
	return newContract
开发者ID:hezhenke,项目名称:myIbPy,代码行数:13,代码来源:getPrevDayStat.py

示例9: makeStkContract

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_right [as 别名]
def makeStkContract(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]
    print 'Contract Values:%s,%s,%s,%s,%s,%s,%s:' % contractTuple
    return newContract
开发者ID:TimonPeng,项目名称:pi314,代码行数:13,代码来源:fancy_marketdata.py

示例10: mkContract

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_right [as 别名]
def mkContract(symbol, secType='STK', exchange='SMART',currency='USD',exp='',strike=0.0,right=''):
	''' 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
	return c
开发者ID:hezhenke,项目名称:myIbPy,代码行数:13,代码来源:catscanner.py

示例11: newContract

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_right [as 别名]
def newContract(symbol, sec_type, exch='SMART', prim_exch='SMART', curr='USD',
                expiry=None, strike=None, opt_type=None):
    contract = Contract()
    contract.m_symbol = symbol
    contract.m_secType = sec_type
    contract.m_expiry = expiry
    contract.m_strike = strike
    contract.m_right = opt_type
    contract.m_exchange = exch
    contract.m_primaryExchange = prim_exch
    contract.m_currency = curr
    return contract
开发者ID:jtbuttram,项目名称:Mammoth,代码行数:14,代码来源:IbHw.py

示例12: makeOptContract

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_right [as 别名]
def makeOptContract(sym, exp, right, strike):
    newOptContract = Contract()
    newOptContract.m_symbol = sym
    newOptContract.m_secType = 'OPT'
    newOptContract.m_right = right
    newOptContract.m_expiry = exp
    newOptContract.m_strike = float(strike)
    newOptContract.m_exchange = 'SMART'
    newOptContract.m_currency = 'USD'
    #newOptContract.m_localSymbol = ''
    #newOptContract.m_primaryExch = ''
    return newOptContract
开发者ID:Jicheng-Yan,项目名称:ib-py,代码行数:14,代码来源:option_order_data.py

示例13: addoption

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_right [as 别名]
	def addoption(self, ticker, exchg, expiry, strike, right):
		c = Contract()
		c.m_symbol = ticker
		c.m_secType = 'OPT'
		c.m_exchange = exchg
		c.m_expiry = expiry
		c.m_strike = float(strike)
		c.m_right = right
		cid = self.registercontract(c)
		if not self.isActiveContract(cid):
			self.activateContract(cid)		
		return(cid)
开发者ID:dm04806,项目名称:systemn,代码行数:14,代码来源:server.py

示例14: newContract

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_right [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

示例15: makeContract

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_right [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


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