Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. DOM LEE
    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 1
    • Posts 3
    • Best 0
    • Groups 0

    DOM LEE

    @DOM LEE

    0
    Reputation
    3
    Profile views
    3
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    DOM LEE Unfollow Follow

    Latest posts made by DOM LEE

    • RE: How to get the first date of a datafeed?

      @vladisld Thanks for you advice. I thought about define custom data feed, but there are thousands of stocks when I run the strategy, and they share a same "my_ind_data" line(and "my_ind_data" is not the only custom data). so that will increase memory usage obviously.

      posted in Indicators/Strategies/Analyzers
      DOM LEE
      DOM LEE
    • RE: How to get the first date of a datafeed?

      I try this , but fail

      
      # Create a Stratey
      class TestStrategy(bt.Strategy):
          params = (('maperiod', 60), )
      
          def log(self, txt, dt=None):
              ''' Logging function fot 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
              self.sma = bt.indicators.SimpleMovingAverage(
                  self.datas[0], period=self.params.maperiod)
      
              # my question is here
              first_date = self.datas[0][0]
      
              my_ind_data = mydb.get_my_data("news_hit").loc[first_data:]
              news_ind = bt.indicators.SimpleMovingAverage(my_ind_data,period=5)
      
      
      
      
      posted in Indicators/Strategies/Analyzers
      DOM LEE
      DOM LEE
    • How to get the first date of a datafeed?

      In def init of a strategy, I need to get external data depend on the first day of data-feed. Is it possible to to that?

      # Create a Stratey
      class TestStrategy(bt.Strategy):
          params = (('maperiod', 60), )
      
          def log(self, txt, dt=None):
              ''' Logging function fot 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
              self.sma = bt.indicators.SimpleMovingAverage(
                  self.datas[0], period=self.params.maperiod)
      
              # my question is here
              first_date = ?????
      
              my_ind_data = mydb.get_my_data("news_hit").loc[start_day:]
              news_ind = bt.indicators.SimpleMovingAverage(my_ind_data,period=5)
      
      
      
      posted in Indicators/Strategies/Analyzers
      DOM LEE
      DOM LEE