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


Python Contract.Contract类代码示例

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


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

示例1: start

 def start(self):
     """Start the connection and read the realtime bars for the specified 
     tickers.
     """
     # connection and handler
     self.connection = ibConnection(
                                    host=self.host, 
                                    port=self.port, 
                                    clientId=self.client_id)
     
     # registration
     self.connection.register( self.ticker_updated, message.RealtimeBar )
     
     # connect
     self.connection.connect()
     
     for inx,stock in enumerate(self.stocks):
         print "Requesting:\t%d = %s" % (inx,stock)
         # create the contract
         contract = Contract()
         contract.m_symbol = stock
         contract.m_secType = 'STK'
         contract.m_exchange = self.exchange
         contract.m_currency = 'USD'
         self.connection.reqRealTimeBars(inx, contract, 5, 'TRADES', False)
开发者ID:jbrukh,项目名称:visualizer,代码行数:25,代码来源:ib_price_reader.py

示例2: makeContract

 def makeContract(self, symbol):
     c = Contract()
     c.m_symbol = symbol
     c.m_secType = "STK"
     c.m_currency = "USD"
     c.m_exchange = "SMART"
     return c
开发者ID:jessetane,项目名称:2502,代码行数:7,代码来源:tws.py

示例3: makeStkContract

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]
    return newContract
开发者ID:oolsson,项目名称:oo_eclipse,代码行数:7,代码来源:ee.py

示例4: makeStkContract

def makeStkContract(symbol, cur = 'USD'):
    contract = Contract()
    contract.m_symbol = symbol
    contract.m_secType = 'STK'
    contract.m_exchange = 'SMART'
    contract.m_currency = cur
    return contract
开发者ID:muennix,项目名称:IbHandler,代码行数:7,代码来源:IbHandler.py

示例5: addfutur

def addfutur(ticker, exchg, expiry):
    c = Contract()
    c.m_symbol = ticker
    c.m_secType = 'FUT'
    c.m_exchange = exchg
    c.m_expiry = expiry
    addcontract(c, "Fut(" + exchg + ", " + expiry + ")")
开发者ID:dm04806,项目名称:systemn,代码行数:7,代码来源:test.py

示例6: inner

 def inner():
     con.reqAccountUpdates(1, '')
     qqqq = Contract()
     qqqq.m_symbol = 'QQQQ'
     qqqq.m_secType = 'STK'
     qqqq.m_exchange = 'SMART'
     con.reqMktData(1, qqqq, '', False)
开发者ID:TimonPeng,项目名称:pi314,代码行数:7,代码来源:filters.py

示例7: reqMktData

 def reqMktData(self):
     contract = Contract() #
     contract.m_symbol = 'AUD'
     contract.m_currency = 'USD'
     contract.m_secType = 'CASH'
     contract.m_exchange = 'IDEALPRO'
     self.connection.reqMktData(1, contract, '', False)
开发者ID:TimonPeng,项目名称:pi314,代码行数:7,代码来源:reference_python.py

示例8: create_option_ticker

 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,代码行数:7,代码来源:connection.py

示例9: subscribe_to_market_data

    def subscribe_to_market_data(self,
                                 symbol,
                                 sec_type='STK',
                                 exchange='SMART',
                                 currency='USD'):
        if symbol in self.symbol_to_ticker_id:
            # Already subscribed to market data
            return

        contract = Contract()
        contract.m_symbol = symbol
        contract.m_secType = symbol_to_sec_type[symbol]
        contract.m_exchange = symbol_to_exchange[symbol]
        contract.m_currency = currency
        ticker_id = self.next_ticker_id

        self.symbol_to_ticker_id[symbol] = ticker_id
        self.ticker_id_to_symbol[ticker_id] = symbol

        # INDEX tickers cannot be requested with market data. The data can,
        # however, be requested with realtimeBars. This change will make
        # sure we can request data from INDEX tickers like SPX, VIX, etc.
        if contract.m_secType == 'IND':
            self.reqRealTimeBars(ticker_id, contract, 60, 'TRADES', True)
        else:
            tick_list = "233"  # RTVolume, return tick_type == 48
            self.reqMktData(ticker_id, contract, tick_list, False)
            sleep(11)
开发者ID:florentchandelier,项目名称:zipline,代码行数:28,代码来源:ib_broker.py

示例10: addstock

def addstock(ticker, exchg, cur = None):
    c = Contract()
    c.m_symbol = ticker
    c.m_secType = 'STK'
    c.m_exchange = exchg
    if cur != None:
        c.m_currency = cur
    addcontract(c, "Stock(" + exchg + ")")
开发者ID:dm04806,项目名称:systemn,代码行数:8,代码来源:test.py

示例11: build_qqq_msg

def build_qqq_msg(symbol_id):
    print i
    qqq = Contract()  
    qqq.m_symbol = i  
    qqq.m_secType = ibsecType 
    qqq.m_exchange = ibexchange
    qqq.m_currency = cashcurr
    return qqq
开发者ID:reprior123,项目名称:TraderSoftwareRP,代码行数:8,代码来源:IBdatadownloaderincremental.py

示例12: createContract

def createContract(symbol, secType='STK', exchange='SMART', currency='USD'):
    """ contract factory function """
    contract = Contract()
    contract.m_symbol = symbol
    contract.m_secType = secType
    contract.m_exchange = exchange
    contract.m_currency = currency
    return contract	
开发者ID:reprior123,项目名称:TraderSoftwareRP,代码行数:8,代码来源:new+apidataget+longone.py

示例13: createContract

def createContract(symbol, secType="STK", exchange="SMART", currency="USD"):
    """ contract factory function """
    contract = Contract()
    contract.m_symbol = symbol
    contract.m_secType = secType
    contract.m_exchange = exchange
    contract.m_currency = currency

    return contract
开发者ID:frrp,项目名称:trading-with-python,代码行数:9,代码来源:interactivebrokers.py

示例14: createContract

def createContract(symbol,secType='STK',exchange='SMART',currency='USD'):
    ''' create contract object '''
    c = Contract()
    c.m_symbol = symbol
    c.m_secType= secType
    c.m_exchange = exchange
    c.m_currency = currency
    
    return c
开发者ID:Artemis1997,项目名称:trading-with-python,代码行数:9,代码来源:extra.py

示例15: request_data

 def request_data(self):
     for ticker_id, instrument in self.instruments.items():
         contract = Contract()
         contract.m_symbol = instrument['symbol']
         contract.m_currency = instrument['currency']
         contract.m_secType = instrument['secType']
         contract.m_exchange = instrument['exchange']
         self.contracts[instrument['symbol']] = contract
         self.connection.reqMktData(ticker_id, contract, '', False)
开发者ID:AlexandreBeaulne,项目名称:botty_mcbotface,代码行数:9,代码来源:bot.py


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