Navigation

    Backtrader Community

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

    benmercerdev

    @benmercerdev

    7
    Reputation
    9
    Profile views
    18
    Posts
    0
    Followers
    1
    Following
    Joined Last Online

    benmercerdev Unfollow Follow

    Best posts made by benmercerdev

    • RE: Backtrader not showing hours

      @benmercerdev

      looks like you're using minute resolution, so maybe:

      data = btfeeds.GenericCSVData(
           dataname="d_comma.csv",
           nullvalue=0.0,
           dtformat=('%d/%m/%Y %H:%M:%S'),
           timeframe=bt.TimeFrame.Minutes,
           datetime=0,
           time=-1,
           high=2,
           low=3,
           open=4,
           close=5,
           volume=6,
           openinterest=-1
       )
      posted in General Discussion
      B
      benmercerdev
    • RE: GenericCSVData does not take time, only takes date

      @run-out great, thank you.

      posted in General Code/Help
      B
      benmercerdev
    • RE: Best approach to limit strategy to certain times of day?

      I ended up using a version of @run-out 's suggestion without the datetimerange, using two custom trade hour params with corresponding params in my strategy

      cth_start = datetime.datetime.strptime(args.cth_start, '%H:%M:%S').time()
      cth_end = datetime.datetime.strptime(args.cth_end, '%H:%M:%S').time()
      

      and then within my strategy simply:

      def next(self):
                  if (self.data.datetime.time() < self.p.cth_start) or (self.data.datetime.time() > self.p.cth_end):
                      return
      posted in General Discussion
      B
      benmercerdev
    • RE: My stop-loss order is getting executed when it shouldn't

      "And some bug in my code (I know where it is) is posting the prev-bar datetime in my logging."

      In some ways these types of bugs are the worst and the best. They're good because it means you were probably right about the logic. They're horrible because you spend hours trying to find them.

      Good luck!

      posted in General Code/Help
      B
      benmercerdev
    • Best approach to limit strategy to certain times of day?

      I'd like to limit my strategy/backtesting not only to certain days of data, but also to certain times during those days, for example +/- 30 minutes of BOD and EOD.

      Can anyone recommend the best approach to this?

      posted in General Discussion
      B
      benmercerdev
    • RE: Can't import a custom indicator from default folder.

      Did you check your path is importing your customized bt library and not another version on your system?

      posted in General Code/Help
      B
      benmercerdev

    Latest posts made by benmercerdev

    • RE: Backtrader's Future

      Hi guys, nice work getting the ball rolling. I'd love to be a part of this. Whether it's as an admin or contributor. My github id is benmercerdev.

      posted in General Discussion
      B
      benmercerdev
    • RE: Best approach to limit strategy to certain times of day?

      I ended up using a version of @run-out 's suggestion without the datetimerange, using two custom trade hour params with corresponding params in my strategy

      cth_start = datetime.datetime.strptime(args.cth_start, '%H:%M:%S').time()
      cth_end = datetime.datetime.strptime(args.cth_end, '%H:%M:%S').time()
      

      and then within my strategy simply:

      def next(self):
                  if (self.data.datetime.time() < self.p.cth_start) or (self.data.datetime.time() > self.p.cth_end):
                      return
      posted in General Discussion
      B
      benmercerdev
    • RE: Best approach to limit strategy to certain times of day?

      Excellent, thanks, guys. Let me give these a go.

      posted in General Discussion
      B
      benmercerdev
    • Best approach to limit strategy to certain times of day?

      I'd like to limit my strategy/backtesting not only to certain days of data, but also to certain times during those days, for example +/- 30 minutes of BOD and EOD.

      Can anyone recommend the best approach to this?

      posted in General Discussion
      B
      benmercerdev
    • RE: Problem with analyzers of optstrategy

      @Shivanshu-Bohara given the code example from above you could print out the params for each, like this:

      
          strats = [x[0] for x in results]
      
          for strat in enumerate(strats):
              print('Params: ', s.p._kwargs())
              print('Returns:', strat.analyzers.returns.get_analysis())
              print('Sharpe Ratio:', strat.analyzers.sharperatio.get_analysis())
      
      posted in General Code/Help
      B
      benmercerdev
    • RE: bt.analyzers.PyFolio

      Best copy and paste your full code, and use the ```, so it looks like this and makes it easier to read:

      cerebro.adddata(b1)
      
      posted in Indicators/Strategies/Analyzers
      B
      benmercerdev
    • RE: bt.analyzers.PyFolio

      Show us your datafeed code, make sure to use the three backticks ;)

      posted in Indicators/Strategies/Analyzers
      B
      benmercerdev
    • RE: Backtrader not showing hours

      @benmercerdev

      looks like you're using minute resolution, so maybe:

      data = btfeeds.GenericCSVData(
           dataname="d_comma.csv",
           nullvalue=0.0,
           dtformat=('%d/%m/%Y %H:%M:%S'),
           timeframe=bt.TimeFrame.Minutes,
           datetime=0,
           time=-1,
           high=2,
           low=3,
           open=4,
           close=5,
           volume=6,
           openinterest=-1
       )
      posted in General Discussion
      B
      benmercerdev
    • RE: Backtrader not showing hours

      try adding this to your datafeed:

      timeframe=bt.TimeFrame.Seconds,
      
      posted in General Discussion
      B
      benmercerdev
    • RE: Backtrader not showing hours

      How are you adding the data feed to cerebro?

      posted in General Discussion
      B
      benmercerdev