Algotopian is starting. Let it be the future of backtrader. Check it out! https://www.algotopian.com
For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

OandapyV20: Tick to OHLC



  • Tick stream structure:
    {
    'type': 'PRICE',
    'time': '2018-01-12T20:59:01.706352414Z',
    'bids': [
    {'price': '13227.9', 'liquidity': 25},
    {'price': '13227.8', 'liquidity': 25},
    {'price': '13227.7', 'liquidity': 50},
    {'price': '13227.5', 'liquidity': 50},
    {'price': '13227.3', 'liquidity': 50}],
    'instrument': 'DE30_EUR',
    'status': 'non-tradeable',
    'asks': [
    {'price': '13229.8', 'liquidity': 50},
    {'price': '13229.9', 'liquidity': 50},
    {'price': '13230.1', 'liquidity': 50},
    {'price': '13230.3', 'liquidity': 50}],
    'closeoutAsk': '13230.3',
    'closeoutBid': '13227.3',
    'tradeable': False}

    is it true?

        # Common fields
        self.lines.datetime[0] = parse_date(msg['time'])
        self.lines.volume[0] = 0.0
        self.lines.openinterest[0] = 0.0
    
        # Put the prices into the bar
        tick = float(msg['asks'][0]['price']) if self.p.useask else float(msg['bids'][0]['price'])
        
        self.lines.open[0] = tick
        self.lines.high[0] = tick
        self.lines.low[0] = tick
        self.lines.close[0] = tick
        self.lines.volume[0] = 0.0
        self.lines.openinterest[0] = 0.0


  • @chuka said in OandapyV20: Tick to OHLC:

    is it true?

    I believe we need a more elaborated question. What is it that you are expecting to be true? (or false)


Log in to reply
 

Looks like your connection to Backtrader Community was lost, please wait while we try to reconnect.