For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

Oanda v20 API



  • Hi Guys,

    yes again this topic. I have already tried the solution mentioned in a other topic just to ask for a other version.
    I have ask and here the answer and here for all that are properly not prepared:

    Thank you for contacting OANDA.
    Unfortunately that is not possible , our V1 API will be phasing out by the end of the year.

    The documentation of the Rest v20 API seams to be complete like the v1 API.

    Maybe its time to work on a port.



  • @matthias-janssen said in Oanda v20 API:

    Thank you for contacting OANDA.
    Unfortunately that is not possible , our V1 API will be phasing out by the end of the ye

    @backtrader



  • @backtrader

    Any feedback, with regard to this?


  • administrators

    A project is being considered now, that would imply adding support. To be decided in the next days



  • @backtrader This and Interactive Brokers please.



  • I am also in need of support for Oanda V20 API and would very much appreciate any work done on adding this feature.



  • I believe my package async_v20 may be of use here.

    As the name suggests, it is implemented using asyncio and aiohttp. Which allows users to simultaneously send multiple requests. I realize that backtrader likely isn't interested in supporting this ability, due to python 3.6 only compatibility.

    Though it would be simple enough so swap out requests for aiohttp, if it were desired. Maybe a new branch could be created.

    some features of async_v20 include:

    • Create pandas dataframe from any data sent in a JSON array. Useful when wanting to process candle stick data
    • Automatically keeps track of the LastTransactionID
    • Automatically provides AccountID and LastTransactionID to
      v20 API endpoints
    • Implements the restful features of the V20 API. Via the OandaClient.account() method
    • Correctly handles decimal point accuracy.
    • Responses directly reflect OANDA's v20 documentation

    docs



  • Is someone willing to collaborate to get support for OANDA v20?



  • We got started and created a repository where to collaborate to implemente the OandaV20 support for backtrader. We are looking for more collaborators to join: https://github.com/ftomassetti/backtrader-oandav20

    Of course if there is interest for this we would be happy to contribute the result back to backtrader



  • @ftomassetti Great, would love to contribute though I'm new to trading and python.

    @backtrader Any update on this?



  • @shieldman the version in github can be used for live trading with oanda v20. We have it running since today, it is not that well tested, so any feedback and testing is welcome.



  • I downloaded the latest version today to test it and got this error in the example
    File "oandav20test.py", line 38, in <module>
    StoreCls = btoandav20.stores.OandaV20Stores
    AttributeError: module 'btoandav20.stores' has no attribute 'OandaV20Stores'
    Am I missing a package?



  • @mula29 you need to install the btoandav20 package by yourself.

    Either copy the folder btoandav20 into the example directory or
    copy the folder btoandav20 into your python packages directory or
    add the package path to your script:

    import sys
    sys.path.insert(0, 'PATH_WHERE_btoandav20_IS_IN')
    


  • @dasch Thanks. Been testing it today and the only issue I encountered was with Limit Orders. It gets rejected with an unknown situation error. The valid date needs to be added to the order and then it works.

    valid=datetime.datetime.now() + datetime.timedelta(days=3))



  • @ftomassetti Thank you for taking this on. I noticed your code uses python 3.6 in development. Is the plan to support the same versions of python as backtrader does? It seems they test against 2.7 and 3.5 (https://pypi.python.org/pypi/backtrader)



  • @mula29 Thanks for the info. Could you provide me with an example of the order creation? I understand the missing valid value, but would like to test the complete flow of this order type.



  • @dasch This is a sample of my buy order
    lprice = Decimal(miround(self.data0.close[0]*1.01)).quantize(FIVEPLACES)
    price = Decimal(miround(self.data0.close[0])).quantize(FIVEPLACES)
    self.order = self.buy(size=self.p.stake,
    exectype=self.p.exectype,
    price=price,
    plimit=lprice,
    valid=datetime.datetime.now() + datetime.timedelta(days=1)

    Per Oanda support, the price needs to have not more than 5 decimal precision. In a market order, it works fine but requires more testing for Stoplimit and limit orders.



  • @mula29 said in Oanda v20 API:

    Per Oanda support, the price needs to have not more than 5 decimal precision. In a market order, it works fine but requires more testing for Stoplimit and limit orders.

    I have commited today some updates. I hope, your issues are gone now. If not, please open a issue on github.

    For the precision, we have details for the traded instrument, so the price precision is known. We use these details for calculting position sizes. Thanks for the code!