Navigation

    Backtrader Community

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

    benjomeyer

    @benjomeyer

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

    benjomeyer Unfollow Follow

    Latest posts made by benjomeyer

    • RE: Timers

      Got it sorted! Thanks.

      def notify_timer(self, timer, when, timername, *args, **kwargs):
          if timername=='buytimer':
              self.buy_stocks()
          if timername=='selltimer':
              self.sell_stocks()
      
      posted in Blog
      benjomeyer
      benjomeyer
    • RE: Timers

      But it's still not working. Any ideas?

      posted in Blog
      benjomeyer
      benjomeyer
    • RE: Timers

      The timers reference had some obvious errors, it's meant to be this:

      def notify_timer(self, timer, when, *args, **kwargs):
          if timername=='buytimer':
              self.buy_stocks()
          if timername=='selltimer':
              self.sell_stocks()
      
      posted in Blog
      benjomeyer
      benjomeyer
    • RE: Timers

      OK, so I tried this:

          self.add_timer(
              when=bt.Timer.SESSION_START,
              weekdays=[self.params.buy_day],
              weekcarry=True,
              timername='buytimer',
              )
      
          self.add_timer(
              when=bt.Timer.SESSION_START,
              weekdays=[self.params.sell_day],
              weekcarry=True,
              timername='selltimer',
              )
      

      and then referred to these timers here:

      def notify_timer1(self, timer1, when, *args, **kwargs):
          if timername=='buytimer':
              self.buy_stocks()
      
      def notify_timer2(self, timer2, when, *args, **kwargs):
          if timername=='selltimer':
              self.sell_stocks()
      

      Is this what you mean? Something's not quite working.

      posted in Blog
      benjomeyer
      benjomeyer
    • RE: Timers

      I have a question about timers. I want to create two timers, one to initiate some sell activities on a Monday and another to initiate buy activities on a Wednesday. I understand how to create two timers, but how do I associate each timer with a different activity/function?

      posted in Blog
      benjomeyer
      benjomeyer