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/

    How to create live data feed?

    General Code/Help
    2
    11
    6416
    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.
    • B
      buaya91 last edited by

      I wish to integrate with custom broker, do we have some sort of documentation to tell how can we easily achieve that?

      1 Reply Last reply Reply Quote 0
      • B
        backtrader administrators last edited by

        See Docs - Binary Datafeed Development

        There is only one thing which is needed missing in the document (tba):

        • Method live which should return True if the fee is in live mode (such a feed can be for example used to download historical data from the online source and could return False in that case)

        The rest is specific to the actual on-line source which may need:

        • One or more background threads to manage connections to the online source
        • Event-listening or polling
        • Rate-limiting intelligence
        • Time/Timezone management (to put the times in UTC format in to backtrader)

        The recommendation would be to look at the latest developed data feed which was probably the cleanest implementtion: Oanda and see if the patterns match the ones of your online data feed.

        B 1 Reply Last reply Reply Quote 1
        • B
          buaya91 @backtrader last edited by buaya91

          @backtrader Thanks, I'll read the tutorial.

          May I know how does Cerebro know if there is new tick?
          And how does Cerebro know when to stop? I wish to let it run forever by default, is it possible?

          1 Reply Last reply Reply Quote 0
          • B
            backtrader administrators last edited by backtrader

            May I know how does Cerebro know if there is new tick?

            Because as shown in the document your _load method returns True if it can load something.

            In order to support resampling, the convention for data feeds is to return None if the data is not finished but has nothing to load.

            And how does Cerebro know when to stop? I wish to let it run forever by default, is it possible?

            Cerebro won't stop if any data feed keeps on providing data.

            B 1 Reply Last reply Reply Quote 0
            • B
              buaya91 @backtrader last edited by

              @backtrader Thanks for the tip.

              Can I know how OandaData expose the underlying data to Cerebro?

              Can you point me to the relevant code in Cerebro?

              1 Reply Last reply Reply Quote 0
              • B
                backtrader administrators last edited by

                It's obviously not in cerebro. Go to the sources and see feeds/oanda.py

                B 1 Reply Last reply Reply Quote 0
                • B
                  buaya91 @backtrader last edited by buaya91

                  @backtrader

                  I guess I found it, so anyone implementing custom data feed should update self.lines in data feed.

                  1 Reply Last reply Reply Quote 0
                  • B
                    backtrader administrators last edited by

                    Out of curiosity. Isn't that in the documentation page linked above?

                    B 1 Reply Last reply Reply Quote 0
                    • B
                      buaya91 @backtrader last edited by

                      @backtrader

                      It wasn't clear to me at first. I only get it on hindsight.

                      I guess part of the reason is that I am not familiar with Python, and was expecting some method to be exposed rather than internal variables.

                      Thanks for your help !

                      1 Reply Last reply Reply Quote 0
                      • B
                        backtrader administrators last edited by

                        They are not internal variables. The entire concept of backtrader revolves around the definition of lines and accessing/manipulating them.

                        See: Docs - Platform Concepts

                        B 1 Reply Last reply Reply Quote 1
                        • B
                          buaya91 @backtrader last edited by

                          @backtrader sorry I've missed them, now everything makes more sense.

                          1 Reply Last reply Reply Quote 0
                          • 1 / 1
                          • First post
                            Last post
                          Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors