Backtrader Community

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. D. Virant
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
    D
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 7
    • Best 0
    • Controversial 0
    • Groups 0

    D. Virant

    @D. Virant

    0
    Reputation
    164
    Profile views
    7
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    D. Virant Unfollow Follow

    Latest posts made by D. Virant

    • RE: Oanda data feed

      @backtrader Thank you!! I didn't realize I needed an external thing, but it actually works now. Can finally get to the actual fun part of coding out the strategy.

      posted in General Code/Help
      D
      D. Virant
    • RE: Oanda data feed

      Hm, when I try to pip install backtrader v20, I get an error in the command prompt (oh, I'm on a Windows system):
      0_1548223522693_7370b212-9fb0-4f05-aff9-4d9199bd5921-image.png

      I'm not sure if that's the main issue, backtrader itself seems to be isntalled. However, if I proceed and try to import the package with

      from .btoandav20 import OandaV20Store
      

      I get this error:

      ModuleNotFoundError: No module named '__main__.btoandav20'; '__main__' is not a package
      

      I do have the btoandav20 folder in my directory. Thanks for all the help, I've been struggling with this for a while. Even tried with a friend that's a little bit more IT savvy and he couldn't figure it out either. I installed Visual C++ Tools and added the cl.exe to my PATH, and I jsut get a different error (error: cl.exe failed with exit status 2).

      posted in General Code/Help
      D
      D. Virant
    • RE: Oanda data feed

      @dasch I think it does, but just in case, can you tell me if I'm doing something horribly wrong if I go through it step by step?

      1. I'm using the Anaconda distribution, so I do msot stuff through the Anaconda prompt.
      2. I run a "pip install backtrader" in the Anaconda prompt, it runs
      3. I clone the btoandaV20 github repository into some folder on my PC (wherever my script is saved)
      4. I navigate Anaconda prompt to that folder and run a "pip install v20"

      That sound right or am I missing something?

      posted in General Code/Help
      D
      D. Virant
    • RE: Oanda data feed

      @dasch I'm trying it and would love to keep using it, but I can't even seem to get past the set-upstage. No matter what I try, I always get an error saying

      AttributeError: module 'btoandav20.stores' has no attribute 'OandaV20Store'
      

      Tried manually installing it, pip installing it and just putting the whole folder into the same directory as my script, nothing really helps. If I add

      from btoandav20.stores import oandav20store
      

      I just get

      ModuleNotFoundError: No module named 'v20'
      

      So it seems I get errors every step of the way, even with just the sample script from the github repo...

      posted in General Code/Help
      D
      D. Virant
    • RE: Oanda data feed

      @backtrader Ok, I'll see what I can do. This isn't meant as a prod or anything, but will the v20 eventually be supported by the "official" Backtrader? Just so I know if I should invest lots of time in trying to make it work now (not in a hurry), or wait until someone who actually knows their stuff does it.

      posted in General Code/Help
      D
      D. Virant
    • RE: Oanda data feed

      @backtrader A previous post mentioned that oandapy was based on an older version of the oanda API. I guess I assumed wrong, but that's why I posted this question on a platform frequented by people far more knowledgeable than me.
      Thanks for the link, I'll check it out.

      posted in General Code/Help
      D
      D. Virant
    • Oanda data feed

      Hey everyone!

      I'm trying to get the Quickstart example to work with Oanda EURUSD data instead of the provided csv example. I'm a Oanda customer (in Europe), I've generated the API token and installed OandaPy through pip. I was hoping I would get a similar output to what is shown in the quickstart guide (starting equity, some close prices, final equity). However, the code doesn't seem to be getting any data from Oanda and only prints out the equity twice.
      Just as a disclaimer, I really appreciate what you're doing with Backtrader, I love the concept of it. I'm just not a very experienced programmer and it's difficult for me to learn stuff from just the documentation, without a bit of input.

      Create a Strategy

      class TestStrategy(bt.Strategy):
      
          def log(self, txt, dt=None):
              ''' Logging function for this strategy'''
              dt = dt or self.datas[0].datetime.date(0)
              print('%s, %s' % (dt.isoformat(), txt))
      
          def __init__(self):
              # Keep a reference to the "close" line in the data[0] dataseries
              self.dataclose = self.datas[0].close
      
          def next(self):
              # Simply log the closing price of the series from the reference
              self.log('Close, %.2f' % self.dataclose[0])
      
      
      if __name__ == '__main__':
      
          # Create a cerebro entity
          cerebro = bt.Cerebro()
      
          # Create oandastore
          oandastore = bt.stores.OandaStore(token = token, account = account)
      ![alt text](image url)
          # instantiate data    
          data = oandastore.getdata(dataname='EUR_USD', 
                             compression=1,
                             backfill=False,
                             fromdate=datetime.datetime(2018, 1, 1),
                             todate=datetime.datetime(2019, 1, 1),
                             qcheck=0.5,
                             timeframe=bt.TimeFrame.Minutes,
                             backfill_start=False,
                             historical=False)
      
      
          # Add the Data Feed to Cerebro
          cerebro.adddata(data)
      
          # Set cash of default broker
          cerebro.broker.setcash(10000.0)
      
          # Add a strategy
          cerebro.addstrategy(TestStrategy)
      
          # Print out the starting conditions
          print('Starting Portfolio Value: %.2f' % cerebro.broker.getvalue())
      
          # Run over everything
          cerebro.run()
      
          # Print out the final result
          print('Final Portfolio Value: %.2f' % cerebro.broker.getvalue())
      

      I know there's been a similar post recently, but I assume that installing OandaPy avoids the issue of V20 not being supported? Or, does Oanda simply not work at the moment? If anyone has any advice on why this isn't working, I'd be super grateful!
      0_1547706184351_9aa3b22a-747a-4fd2-816e-590924efd9cd-image.png This is the output I get.

      posted in General Code/Help oanda live data oandapy oanda access
      D
      D. Virant