Navigation

    Backtrader Community

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

    Serp

    @Serp

    0
    Reputation
    372
    Profile views
    4
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    Serp Unfollow Follow

    Latest posts made by Serp

    • When plot zoom, adjust axis of indicators

      I'm currently testing plotting charts with indicators.
      I noticed when eg. plotting:

      self.adosc = bt.talib.ADOSC(self.datas[0].high, self.datas[0].low, self.datas[0].close, self.datas[0].volume, fastperiod=30, slowperiod=90, plotname='ADOSC')
      

      the axis of this indicator eg. ranges from -2 to 4.
      Now I zoom in and the axis of the close price is adjusted accordingly. But the axis of the indicator is not. It is still from -2 to 4, while the highest value in this zoomed box is only ~0.25.

      Is it possible to make also indicator axis to react to zooming?

      posted in General Code/Help
      S
      Serp
    • RE: Hourly bars?

      thank you very much. English is not my native language and I thought the sentence:
      "Informative unless Data Resampling/Replaying is used" would mean, that it is just for my personal informative use (like I could print that it is "daily", but it has no other purpose).

      Thanks, so to sum it up (for other people reading here) the solution was:

       timeframe = bt.TimeFrame.Minutes, 
       compression = 60,
      
      posted in General Code/Help
      S
      Serp
    • Hourly bars?

      Hi,
      I copy pasted the quickstart code under "The broker says: Show me the money!" and adjusted filename and following feed params:

          data = data = btfeeds.GenericCSVData(
          dataname='test_ForBacktraderHourly.csv',
      
          fromdate=datetime.datetime(2017, 1, 1),
          todate=datetime.datetime(2017, 1, 5),
      
          nullvalue=0.0,
          dtformat=('%Y-%m-%d %H'), # it is hourly data
          
          
          headers = True, 
          datetime=0,
          high=1,
          low=2,
          open=3,
          close=4,
          volume=5,
          openinterest=-1
      )
      

      The csv contains datal like this:
      Date, High, Low, Open, Close, Volume
      2011-09-13 15, 6.000000000000, 5.800000000000, 5.800000000000, 6.000000000000, 25.000000000000
      2011-09-13 16 , 5.950000000000, 5.760000000000, 5.950000000000, 5.760000000000, 22.353982380000

      So that should be hourly bars.
      But when executing the self.buy() the buy is not executed at next bar, but at next day.
      How to change from Daily to Hourly?
      I tried to add

          timeframe = bt.TimeFrame.Hours
      

      but 1) this is only used for Resampling (dont know yet what it is) and 2) does Hours not exist.

      edit:
      So question is not only about "hourly" it is about customized bars, so even 2 hourly or 0.5hourly and so on.

      posted in General Code/Help
      S
      Serp
    • How to load csv with unix timestamp as dates?

      Hi,

      I'm rellay new to algorithmic trading and will test around with this backtester, but to do this I need to know how to import a csv file not meeting the standard look.

      The csv file looks like this:
      unix timestamp, close, volume

      What should I use for "dtformat" in GenericCSVData ?

      And can I use parameters like "seperator" also in this GenericCSVData? I'm not sure, cause here https://www.backtrader.com/docu/datafeed.html it is written under the "Yahoo" feed, and I don't use Yahoo. So I'm not sure if those params are also valid for GenericCSVData.. ?

      posted in General Code/Help
      S
      Serp