Backtrader Community

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

    AALLI

    @AALLI

    0
    Reputation
    1
    Profile views
    5
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    AALLI Unfollow Follow

    Latest posts made by AALLI

    • Getting this error resampledata() missing 1 required positional argument: 'dataname' tried everything
      import backtrader as bt
      
      def start():
        cerebro = bt.Cerebro
      
        store = bt.stores.IBStore(port=7497)
        data = store.getdata(dataname='USD.JPY', secType='CASH', exchange='IDEALPRO', 
        timeframe=bt.TimeFrame.Seconds)
        cerebro.resampledata(data, timeframe=bt.TimeFrame.Minutes, compression=15)
      
        cerebro.run()
      
      
        start()
      

      any Idea guys?

      posted in General Code/Help
      A
      AALLI
    • RE: struggling to resample csv file

      @dasch thanks I tried this but it didnt work

      posted in General Code/Help
      A
      AALLI
    • RE: struggling to resample csv file

      @dasch how about I put in a class?

      posted in General Code/Help
      A
      AALLI
    • struggling to resample csv file

      this is my code :

      data = bt.feeds.GenericCSVData(
          dataname='USDJPY_H1.csv',
       
          fromdate=datetime.datetime(2014, 4, 2),    
          todate=datetime.datetime(2014, 4, 4),
      
          nullvalue=0.0,  
      
          dateformat='%Y-%m-%d %H:%M:%S',
      
          datetime=0,   
          time=-1,    
          open=1,    
          high=2,    
          low=3,    
          close=4,    
          adjclose=5,    
          volume=6,    
          openinterest=-1, 
      
          timeframe=bt.TimeFrame.Minutes, compression=60)
      

      and this is a part of my cvs file

          Date,Open,High,Low,Close,AdjClose,Volume
          
          2014-04-02 16:00:00 103.819	103.821	103.745	103.767	1854
          
          2014-04-02 17:00:00	103.767	103.839	103.732	103.775	1777
          
          2014-04-02 18:00:00	103.776	103.794	103.734	103.747	1072
          
          2014-04-02 19:00:00	103.749	103.867	103.748	103.852	1837
          
          2014-04-02 20:00:00	103.851	103.882	103.826	103.881	985
          
          2014-04-02 21:00:00	103.882	103.894	103.846	103.865	577  
      

      Im getting this error : raise ValueError("unconverted data remains: %s" %
      ValueError: unconverted data remains: 103.819 103.821 103.745 103.767 1854

      can anyone tell me whats wrong?

      posted in General Code/Help
      A
      AALLI
    • Building and strategy around two different indicators

      I'm new to backtrader and coding in general, I managed to add indicator to a dataset and would like to build my strategy around this and more indicators and parameters in the future this is my code rn:

      class _StochasticBase(bt.Indicator):
      lines = ('percK', 'percD',)
      params = (('period', 14), ('period_dfast', 3), ('movav', bt.indicators.SMA),
                ('upperband', 80.0), ('lowerband', 20.0),
                ('safediv', False), ('safezero', 0.0))
      
      plotlines = dict(percD=dict(_name='%D', ls='--'),
                       percK=dict(_name='%K'))
      
      def _plotlabel(self):
          plabels = [self.p.period, self.p.period_dfast]
          plabels += [self.p.movav] * self.p.notdefault('movav')
          return plabels
      
      def _plotinit(self):
          self.plotinfo.plotyhlines = [self.p.upperband, self.p.lowerband]
      
      def init(self):
          highesthigh = Highest(self.data.high, period=self.p.period)
          lowestlow = Lowest(self.data.low, period=self.p.period)
          knum = self.data.close - lowestlow
          kden = highesthigh - lowestlow
          if self.p.safediv:
              self.k = 100.0 * bt.DivByZero(knum, kden, zero=self.p.safezero)
          else:
              self.k = 100.0 * (knum / kden)
          self.d = self.p.movav(self.k, period=self.p.period_dfast)
      
          super(_StochasticBase, self).init()
      

      class StochasticFast(_StochasticBase):
      def init(self):
      super(StochasticFast, self).init()
      self.lines.percK = self.k
      self.lines.percD = self.d

      I want to make an strategy based on the two lines generated from the indicator and backtest from there but when I create my strategy class I don't know how to import the indicators to it (like I said I'm new to coding)
      Also I have a RSI indicator and another separate CI that I've added but I don't know how to bring those two in my strategy as well and mix em together, thanks in advance

      posted in Indicators/Strategies/Analyzers
      A
      AALLI