예제 #1
0
 def tickPrice(self, tickerId, field, price, canAutoExecute):
     msg = EWrapperMsgGenerator.tickPrice(tickerId, field, price, 
                                          canAutoExecute)
     dt = datetime.now().isoformat()
     try:
         key, index = self.tickerId_to_symbolKey[tickerId]
         bid_histogram = self.bid_histograms[key]
         ask_histogram = self.ask_histograms[key]
         last_histogram = self.last_histograms[key]
         symExp = '_'.join(key)
         if field == 1:
             bid_histogram.datafile = '%s/BID_%s.dat' % (symExp, dt)
             bid_histogram.update_price(price, index)
             print bid_histogram.plot_histogram(fname='%s/BID_%s.jpg'\
                                               % (symExp, dt), timestamp=dt)
         elif field == 2:
             ask_histogram.datafile = '%s/ASK_%s.dat' % (symExp, dt)
             ask_histogram.update_price(price, index)
             print ask_histogram.plot_histogram(fname='%s/ASK_%s.jpg'\
                                               % (symExp, dt), timestamp=dt)
         elif field == 4:
             last_histogram.datafile = '%s/LAST_%s.dat' % (symExp, dt)
             last_histogram.update_price(price, index)
             print last_histogram.plot_histogram(fname='%s/LAST_%s.jpg'\
                                               % (symExp, dt), timestamp=dt)
     except KeyError:
         pass
     self.datahandler(tickerId, msg)
예제 #2
0
 def tickPrice(self, tickerId, field, price, canAutoExecute):
     msg = EWrapperMsgGenerator.tickPrice(tickerId, field, price, 
                                          canAutoExecute)
     dt = datetime.now().isoformat()
     try:
         symExp, right, index = self.tickerId_to_symbolKey[tickerId]
         butterfly_prices = self.butterfly_prices[symExp]
         symExp = '_'.join(symExp)
         if field in [1, 2]:
             butterfly_prices.ocallfile = '%s/buttercalls_%s.dat' % (symExp, dt)
             butterfly_prices.oputfile = '%s/butterputs_%s.dat' % (symExp, dt)
             butterfly_prices.ufile = '%s/underlying_%s.dat' % (symExp, dt)
             butterfly_prices.update_price(price, right, index, field)
             print butterfly_prices.plot_prices(fname='%s/%s.jpg'\
                                               % (symExp, dt), timestamp=dt)
     except KeyError:
         pass
     self.datahandler(tickerId, msg)
예제 #3
0
파일: client.py 프로젝트: gazzman/ib
 def tickPrice(self, tickerId, field, price, canAutoExecute):
     msg = EWrapperMsgGenerator.tickPrice(tickerId, field, price, 
                                          canAutoExecute)
     self.datahandler(tickerId, msg)