Oanda - backfill limit



  • For live trading.. i read in the docs that

    Backfilling
    
    backtrader makes no special request to Oanda. For small timeframes the backfilling returned by Oanda on the practice servers has been 500 bars long
    

    Is this 500 limited by the Oanda v1 rest API? Can this limit be changed (perhaps by manual request)?

    how do you guys get around this? Start downloading data onto your server... then wait for enough data to do your analysis b4 kicking off trades?

    If 500 is the limit, is there a way to "preload" from local disk for historical data and then switch over to Oandapy?

    And does oanda API not report volume ? im always seeing zero


  • administrators


  • administrators

    @Taewoo-Kim said in Oanda - backfill limit:

    And does oanda API not report volume ? im always seeing zero

    Unknown but forex is not a market (at least not one like a Futures market for example on an Exchange). What Oanda offers you is the chance to trade prices they create (and that's why the commission is built into the spread) Competition (and real value of the currency pairs) ensure that prices are at least not unrealistic, because if they were unrealistic they would go somewhere else.

    But you may actually not be trading real currencies.

    Check Interactive Brokers, you see amounts being traded, but historical downloads show no volume (or at least they didn't in the past, feel free to check)



  • @backtrader

    If that's the case, how are these manual trading platform softwares (MT4, ctrader) showing volume in their charts?

    FYI - It turns out /v1/candles endpoint reports volume

    curl -X GET "https://api-fxtrade.oanda.com/v1/candles?instrument=EUR_USD&count=1&candleFormat=midpoint&granularity=M1&start=2017-04-26T10%3A15%3A40Z"
    

    returns

        {
                "instrument" : "EUR_USD",
                "granularity" : "M1",
                "candles" : [
                        {
                                "time" : "2017-04-26T10:15:00.000000Z",
                                "openMid" : 1.08946,
                                "highMid" : 1.08949,
                                "lowMid" : 1.08936,
                                "closeMid" : 1.08939,
                                "volume" : 93,
                                "complete" : true
                        }
                ]
        }

  • administrators

    There seems to be an apples to pears comparison in place. From Docs - Live Data Feeds and Live Trading - Oanda

          - ``bidask`` (default: ``True``)
    
            If ``True``, then the historical/backfilling requests will request
            bid/ask prices from the server
    
            If ``False``, then *midpoint* will be requested
    
          - ``useask`` (default: ``False``)
    
            If ``True`` the *ask* part of the *bidask* prices will be used instead
            of the default use of *bid*
    

    The defaults request using the BID / ASK prices and from those 2 the BID price. This is apparently what most tools do, especially those working with Interactive Brokers.

    You are requesting MIDPOINT (you can set bidask to False), which for starters is a value that never existed. What the volume for a value which never existed mean is something you would be better asking Oanda. The point made above in any case is valid: the volume in a private broker gives you no notion at all about what's being traded (leaving aside you have to trust the value actually reflects something)

    When loading historical values, the code in backtrader does

            self.lines.volume[0] = float(msg['volume'])
    

    There is actually a volume field in the messages from Oanda or else ... a exception would be immediately raised. The volume you get is the one transmitted by that field.



  • @backtrader

    But it appears that the volume reported by "BIDASK" and "MIDPOINT" are the same

        $ curl -X GET "https://api-fxtrade.oanda.com/v1/candles?instrument=EUR_USD&count=1&candleFormat=bidask&granularity=M1&start=2017-04-26T10%3A15%3A40Z"
        {
                "instrument" : "EUR_USD",
                "granularity" : "M1",
                "candles" : [
                        {
                                "time" : "2017-04-26T10:15:00.000000Z",
                                "openBid" : 1.0894,
                                "openAsk" : 1.08952,
                                "highBid" : 1.08944,
                                "highAsk" : 1.08954,
                                "lowBid" : 1.08929,
                                "lowAsk" : 1.08942,
                                "closeBid" : 1.08933,
                                "closeAsk" : 1.08945,
                                "volume" : 93,
                                "complete" : true
                        }
                ]
        }
    

    versus

        $ curl -X GET "https://api-fxtrade.oanda.com/v1/candles?instrument=EUR_USD&count=1&candleFormat=midpoint&granularity=M1&start=2017-04-26T10%3A15%3A40Z"
        {
                "instrument" : "EUR_USD",
                "granularity" : "M1",
                "candles" : [
                        {
                                "time" : "2017-04-26T10:15:00.000000Z",
                                "openMid" : 1.08946,
                                "highMid" : 1.08949,
                                "lowMid" : 1.08936,
                                "closeMid" : 1.08939,
                                "volume" : 93,
                                "complete" : true
                        }
                ]
        }
    

    So are you suggesting that this volume isn't a reliable piece of information?

    PS: I tried reaching out to Oanda's API team... either they're "really" backed up.. or im just not in their radar to warrant a response.


  • administrators

    @Taewoo-Kim said in Oanda - backfill limit:

    So are you suggesting that this volume isn't a reliable piece of information?

    Forex is not a market like the one you have if you trade ES-Mini. How many contracts were traded every day is public and recorded by the exchange. And you can get the information on a per minute basis if you wish.

    For example: http://www.cmegroup.com/trading/equity-index/us-index/e-mini-sandp500.html

    The first single question you may ask yourself is which is the official exchange for EUR_USD where the volume is recorded.



  • @backtrader

    I'm not sure if you're asking a rhetorical question ... ?

    Let me rephrase... how do MT4/ctrader (i.e. manual trading platforms) get their volume information? That must be coming through some pipe of some sort.

    For example... http://www.forexlive.com/LiveCharts


  • administrators

    It's really mostly irrelevant where they source the volume from. You fail to understand that Forex trading takes place at a specific provider and not in an exchange. The provider offering you trading doesn't even have to really trade the currencies, just offer you the prices and be prepared to cover its losses (the spread takes care of making sure there are no losses) or by offsetting your trading against real forex operators (like Banks)

    Additionally if you are a consistent winner, they may shut down your account. Forex brokers are giving you the same thing betting providers give you. If you were able to get volume information from Bet365 for a given event, would it mean that you know how much betting volume is actually taking place on that event across all betting providers? (WilliamHill, Betfair, Betdaq, BWin, Interwetten and ... and ... and ...)

    This book is really recommended for this case: Amazon.com - Trader Vic: Methods of a Wall Street Master

    It's not a great book per se, but it's worth reading. And one of the first things which the book tells you it's that you have to know the house rules, before you play whatever in the house.



    1. Yes, i understand there's no central exchange and that i'm playing under Oanda's "house rules". I am not trying to get a definitive "global" volume. I am just looking for volume for that data "house". I figure it's better than nothing.

    Additionally if you are a consistent winner, they may shut down your account.

    1. Doesn't this apply only to NDD brokers? Doesnt oanda make its money from the spread anyway?

    2. If I aggregate volumes from multiple brokers, would that be just as useless? According to this , the top 10 retail brokers dont even add up to $1T... (not even close to est'd $5T+), but still it's better than complete dark blindness, no?


  • administrators

    @Taewoo-Kim said in Oanda - backfill limit:

    1 ... I figure it's better than nothing.

    If you assume that the volume pattern in a single house conforms to the actual total volume pattern, yes.

    1. Doesn't this apply only to NDD brokers? Doesnt oanda make its money from the spread anyway?

    Without stating what Oanda does (because it is unknown here), nothing prevents Oanda from doing whatever they want with your bets in addition to the spread they introduce.

    See: Interactive Brokers started charging overnight negative interest on cash balances exceeding $100.000 (or equivalent) starting around Jan-Mar 2016. And this because the different central banks had started charging negative interest to banks depositing money in the central banks overnight.

    The question then: Was Interactive Brokers also depositing money in the central banks overnight? No. But even if only a broker and they should only have your money deposited overnight, the reality is probably other: participation in the overnight interbank lending market with all the available cash from people who for example close all open positions at the end of the trading session. The interbank lending market had negative rates (also as a consequence of the central bank policies) and Interactive Brokers passed the negative interest on to customers.

    But the moral of the story: you put your money in the broker to do thing X. And the broker uses your money overnight for purpose Y which in this case also means a cost for you.

    Without distrusting each and every broker (not even Interactive Brokers) the moral of the story: they could do whatever they want with your money if they wanted. And if it's simply by securing your bet with a 3rd party (where your money is not even involved), even more probable.

    1. If I aggregate volumes from multiple brokers, would that be just as useless? According to this , the top 10 retail brokers dont even add up to $1T... (not even close to est'd $5T+), but still it's better than complete dark blindness, no?

    If the achieved volume pattern conforms to the global volume pattern, yes. The problem being here that none of those retail brokers has any obligation to provide any kind of accurate volume record (not even the obligation to trade the actual currency pair)

    All this doesn't mean that Forex is not an appropriate trading product because it is. And it is so because the brokers are not willing to lose money either and they are forced to offer prices which are at least very close to the actual price which is being agreed by the heavy weight champions. Or else arbitrage would kill them.



  • @backtrader

    Yeah, makes sense. When people are writing checks to a black box, im sure the operators of the black box are doing whatever the hell they feel like.

    Do you trade FX yourself? One of my reasons for trading BT (which btw.. was the hardest to pick up. IMO.. but also has the best feature set) was its ease of integration with oanda... not to mention you seem to be updating the software regularly. So I assumed you traded FX..


  • administrators

    Oanda was a an early request in the project. It could have been any other.


Log in to reply
 

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