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


Python Contract.m_localSymbol方法代码示例

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


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

示例1: sendOrder

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_localSymbol [as 别名]
 def sendOrder(self, orderReq):
     """发单"""
     # 增加报单号1,最后再次进行查询
     # 这里双重设计的目的是为了防止某些情况下,连续发单时,nextOrderId的回调推送速度慢导致没有更新
     self.orderId += 1
     
     # 创建合约对象
     contract = Contract()
     contract.m_localSymbol = 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)
     
     # 返回委托编号
     vtOrderID = '.'.join([self.gatewayName, str(self.orderId)])
     return vtOrderID
开发者ID:86chenjie,项目名称:vnpy,代码行数:36,代码来源:ibGateway.py

示例2: inner

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_localSymbol [as 别名]
    def inner():

        #con.reqAccountUpdates(1, '')
        qqqq = Contract()
        qqqq.m_symbol = 'QQQ'
        qqqq.m_secType = 'STK'
        qqqq.m_exchange = 'SMART'

        contract = Contract() #
        contract.m_symbol = 'AUD'
        contract.m_currency = 'USD'
        contract.m_secType = 'CASH'
        contract.m_exchange = 'IDEALPRO'

        fut = Contract() #
        fut.m_localSymbol = 'CLM6'
        #fut.m_symbol = 'CL'
        fut.m_currency = 'USD'
        fut.m_secType = 'FUT'
        fut.m_exchange = 'NYMEX'
        #fut.m_expiry = '201606'
        #fut.m_multiplier = '1000'

        #con.reqMktData(1, qqqq, '', False)
        #con.reqMktData(1, contract, '', False)
        con.reqMktData(1, fut, '', False)
开发者ID:border,项目名称:quantway,代码行数:28,代码来源:mktData.py

示例3: create_option_ticker

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_localSymbol [as 别名]
 def create_option_ticker(self, ticker, currency='USD', exchange='SMART'):
     c = Contract()
     c.m_secType = 'OPT'
     c.m_localSymbol = ticker
     c.m_currency = currency
     c.m_exchange = exchange
     return c
开发者ID:gongqingyi,项目名称:untws,代码行数:9,代码来源:connection.py

示例4: makeContract

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_localSymbol [as 别名]
 def makeContract(self, symbol):
     contract = Contract()
     contract.m_symbol = symbol
     contract.m_secType = 'STK'
     contract.m_exchange = 'SMART'
     contract.m_primaryExch = 'SMART'
     contract.m_currency = 'USD'
     contract.m_localSymbol = symbol
     return contract
开发者ID:cjastram,项目名称:silverbot,代码行数:11,代码来源:trader.py

示例5: create_contract

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_localSymbol [as 别名]
def create_contract(symbol, sec_type, exch, prim_exch, curr):
    """Create a Contract object defining what will
    be purchased, at which exchange and in which currency.

    symbol - The ticker symbol for the contract
    sec_type - The security type for the contract ('STK' is 'stock')
    exch - The exchange to carry out the contract on
    prim_exch - The primary exchange to carry out the contract on
    curr - The currency in which to purchase the contract"""
    contract = Contract()
    contract.m_symbol = symbol
    contract.m_secType = sec_type
    contract.m_exchange = exch
    contract.m_primaryExch = prim_exch
    contract.m_currency = curr
    contract.m_localSymbol = symbol
    return contract
开发者ID:LiutaurasP,项目名称:Python-workground,代码行数:19,代码来源:IBData.py

示例6: test_008a

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_localSymbol [as 别名]
def test_008a(connection, options):
    c = Contract()
    c.m_exchange = 'IDEALPRO'
    c.m_symbol = 'MO'
    c.m_localSymbol = 'MO1C'
    c.m_secType = 'BAG'
    c.m_expiry = '200806'
    leg1 = ComboLeg()
    leg1.m_conId = 123
    leg1.m_ratio = 1
    leg1.m_exchange = 'ONE'
    leg1.m_action = 'SELL'
    leg2 = ComboLeg()
    leg2.m_conId = 125
    leg2.m_ratio = 100
    leg2.m_exchange = 'NYSE'
    leg2.m_action = 'BUY'
    c.m_comboLegs = [leg1, leg2]
    connection.reqMktData(1, c, generic_tick_keys, False)
开发者ID:TimonPeng,项目名称:pi314,代码行数:21,代码来源:api_coverage.py

示例7: subscribe

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_localSymbol [as 别名]
    def subscribe(self, subscribeReq):
        """订阅行情"""
        # 如果尚未连接行情,则将订阅请求缓存下来后直接返回
        if not self.connected:
            self.subscribeReqDict[subscribeReq.symbol] = subscribeReq
            return
        
        contract = Contract()
        contract.m_localSymbol = 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, '')

        # 获取合约详细信息
        self.tickerId += 1
        self.connection.reqContractDetails(self.tickerId, contract)        
        
        # 创建合约对象并保存到字典中
        ct = VtContractData()
        ct.gatewayName = self.gatewayName
        ct.symbol = str(subscribeReq.symbol)
        ct.exchange = subscribeReq.exchange
        ct.vtSymbol = '.'.join([ct.symbol, ct.exchange])
        ct.productClass = subscribeReq.productClass
        self.contractDict[ct.vtSymbol] = ct
        
        # 订阅行情
        self.tickerId += 1   
        self.connection.reqMktData(self.tickerId, contract, '', False)
        
        # 创建Tick对象并保存到字典中
        tick = VtTickData()
        tick.symbol = subscribeReq.symbol
        tick.exchange = subscribeReq.exchange
        tick.vtSymbol = '.'.join([tick.symbol, tick.exchange])
        tick.gatewayName = self.gatewayName
        self.tickDict[self.tickerId] = tick   
        self.tickProductDict[self.tickerId] = subscribeReq.productClass
开发者ID:86chenjie,项目名称:vnpy,代码行数:43,代码来源:ibGateway.py

示例8: get_market_data

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

示例9: processMsg

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

#.........这里部分代码省略.........
         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()
             errorMsg = self.readStr()
             self.m_parent.error(id, errorCode, errorMsg)
     elif msgId == self.OPEN_ORDER:
         version = self.readInt()
开发者ID:Jicheng-Yan,项目名称:ib-py,代码行数:70,代码来源:EReader.py

示例10: Contract

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_localSymbol [as 别名]
ibgw.register(my_hist_data_handler, message.historicalData)

contract = Contract()
contract.m_symbol = 'QQQ'
contract.m_secType = 'STK'
contract.m_exchange = 'SMART'

cash = Contract() #
cash.m_symbol = 'EUR'
cash.m_currency = 'USD'
cash.m_secType = 'CASH'
cash.m_exchange = 'IDEALPRO'

fut = Contract() #
#fut.m_symbol = 'CL'
fut.m_localSymbol = 'CLM6'
fut.m_currency = 'USD'
fut.m_secType = 'FUT'
fut.m_exchange = 'NYMEX'
#fut.m_expiry = '201606'

print vars(fut)

endtime = strftime('%Y%m%d %H:%M:%S')
ibgw.reqHistoricalData(
    tickerId=1,
    contract=fut,
    endDateTime=endtime,
    durationStr='1 W',
    #barSizeSetting='5 mins',
    barSizeSetting='1 hour',
开发者ID:border,项目名称:quantway,代码行数:33,代码来源:historyData.py

示例11: Contract

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_localSymbol [as 别名]
ibgw.connect()

# Map server replies for "Error" messages to the "error_handler" function
ibgw.register(error_handler, 'Error')

#ibgw.register(my_detail_data_handler, message.contractDetails)
ibgw.register(my_detail_data_handler, message.contractDetails)

contract = Contract()
contract.m_symbol = 'QQQ'
contract.m_secType = 'STK'
contract.m_exchange = 'SMART'

cash = Contract() #
#cash.m_symbol = 'EUR'
cash.m_localSymbol = 'EUR.USD'
cash.m_currency = 'USD'
cash.m_secType = 'CASH'
cash.m_exchange = 'IDEALPRO'

fut = Contract() #
#fut.m_symbol = 'CL'
fut.m_localSymbol = 'CLM6'
fut.m_currency = 'USD'
fut.m_secType = 'FUT'
fut.m_exchange = 'NYMEX'
fut.m_expiry = '201606'

print vars(fut)

ibgw.reqContractDetails(1, cash)
开发者ID:border,项目名称:quantway,代码行数:33,代码来源:contractDetails.py


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