• C#
  • Java
  • VB
  • C++
  • Python
Contact us
Histograms

Histogram data requires API v973.02+ and TWS 964+. Instead of returned data points as a function of time as with the function IBApi::EClient::reqHistoricalData, histograms return data as a function of price level with function IBApi::EClient::reqHistogramData

  • client.reqHistogramData(15001, ContractSamples.USStockWithPrimaryExch(), false, "1 week");
  • /*client.reqHistogramData(4004, ContractSamples.USStock(), false, "3 days");
  • client.reqHistogramData(15001, ContractSamples.USStockWithPrimaryExch, False, "1 week")
  • m_pClient->reqHistogramData(15001, ContractSamples::IBMUSStockAtSmart(), false, "1 weeks");

and data is returned to IBApi::EWrapper::histogramData

  • public void histogramData(int reqId, HistogramEntry[] data)
    {
    Console.WriteLine("Histogram data. Request Id: {0}, data size: {1}", reqId, data.Length);
    data.ToList().ForEach(i => Console.WriteLine("\tPrice: {0}, Size: {1}", Util.DoubleMaxString(i.Price), Util.DecimalMaxString(i.Size)));
    }
  • @Override
    public void histogramData(int reqId, List<HistogramEntry> items) {
    System.out.println(EWrapperMsgGenerator.histogramData(reqId, items));
    }
  • Public Sub histogramData(reqId As Integer, data As HistogramEntry()) Implements EWrapper.histogramData
    Console.WriteLine("Histogram data. Request Id: {0}, data size: {1}", reqId, data.Length)
    data.ToList().ForEach(Sub(i) Console.WriteLine(vbTab & "Price: {0}, Size: {1}", Util.DoubleMaxString(i.Price), Util.DecimalMaxString(i.Size)))
    End Sub
  • void TestCppClient::histogramData(int reqId, const HistogramDataVector& data) {
    printf("Histogram. ReqId: %d, data length: %lu\n", reqId, data.size());
    for (const HistogramEntry& entry : data) {
    printf("\t price: %s, size: %s\n", Utils::doubleMaxString(entry.price).c_str(), DecimalFunctions::decimalStringToDisplay(entry.size).c_str());
    }
    }
  • 1  def histogramData(self, reqId:int, items:HistogramDataList):
    2  print("HistogramData. ReqId:", reqId, "HistogramDataList:", "[%s]" % "; ".join(map(str, items)))

An active histogram request which has not returned data can be cancelled with IBApi::EClient::cancelHistogramData

  • client.cancelHistogramData(15001);
  • client.cancelHistogramData(4004);*/
  • client.cancelHistogramData(15001)
  • m_pClient->cancelHistogramData(15001);