Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

    Data CSV in Strategy

    General Discussion
    2
    7
    70
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      sadegh last edited by

      Hi
      how can get dataframe in strategy and work it by pandas dataframe in init function of strategy
      and get list of close values
      like this

      import backtrader as bt
      import pandas as pd
      
      
      class test2(bt.Strategy):
      
          def __init__(self):
              print(pd.DataFrame(self.data.close[0]))
      
      1 Reply Last reply Reply Quote 0
      • S
        sadegh last edited by

        how can I get list of close values in strategy?
        I want to get all values !

        1 Reply Last reply Reply Quote 0
        • run-out
          run-out last edited by

          You can get all of the close values at the end of the backtest in stop.

              def stop(self):
                  a = self.data.get(0,len(self.data))
          
          S 1 Reply Last reply Reply Quote 0
          • S
            sadegh @run-out last edited by

            @run-out can I get that in init function? I want to use it in next function!

            run-out 1 Reply Last reply Reply Quote 0
            • run-out
              run-out @sadegh last edited by

              @sadegh said in Data CSV in Strategy:

              can I get that in init function? I want to use it in next function!

              But you already have the close values available in next. What exactly are you trying to do?

              S 1 Reply Last reply Reply Quote 0
              • S
                sadegh last edited by

                I want to get all close values in init function as a list

                1 Reply Last reply Reply Quote 0
                • S
                  sadegh @run-out last edited by

                  @run-out I mean I want to process all data in init function and use the result in next function

                  1 Reply Last reply Reply Quote 0
                  • 1 / 1
                  • First post
                    Last post
                  Copyright © 2016, 2017, 2018 NodeBB Forums | Contributors
                  $(document).ready(function () { app.coldLoad(); }); }