Exemplo n.º 1
0
    def historicalData(self, reqId: int, bar: BarData):
        """ returns the requested historical data bars

        reqId    - the request's identifier
        date     - the bar's date and time (either as a yyyymmss hh:mm:ss
                   formatted string or as system time according to the request)
        open     - the bar's open point
        high     - the bar's high point
        low      - the bar's low point
        close    - the bar's closing point
        volume   - the bar's traded volume if available
        barCount - the number of trades during the bar's timespan (only available for TRADES).
        average  - the bar's Weighted Average Price
        hasGaps  - indicates if the data has gaps or not. """

        EWrapper.historicalData(self, reqId, bar)
        #print("historical data id ",reqId)
        #date, time = bar.date.split()
        self.downloadHistInfo[self.nextIDconID[reqId]].oneStock.addOneBar(bar)
Exemplo n.º 2
0
    def historicalData(self, reqId: int, bar: BarData):
        """ returns the requested historical data bars

        reqId    - the request's identifier
        date     - the bar's date and time (either as a yyyymmss hh:mm:ss
                   formatted string or as system time according to the request)
        open     - the bar's open point
        high     - the bar's high point
        low      - the bar's low point
        close    - the bar's closing point
        volume   - the bar's traded volume if available
        barCount - the number of trades during the bar's timespan (only available for TRADES).
        average  - the bar's Weighted Average Price
        hasGaps  - indicates if the data has gaps or not. """

        EWrapper.historicalData(self, reqId, bar)

        date, time = bar.date.split()
        self._write(
            f'{date},{time},{bar.open},{bar.close},{bar.low},{bar.high},{bar.barCount},{bar.volume},{bar.average}'
        )
        self.tws2gui.put('NEWROW')