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 get the (live) broker's API response data for bracket order?

    General Code/Help
    2
    6
    1508
    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.
    • T
      Taewoo Kim last edited by

      Is there one?

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

        Not sure what you mean with live API response. When the broker sends the confirmation of a bracket order or cancellation, an Order object is sent to your strategy via the notify_order with the current status.

        Oanda doesn't have bracket orders, but rather an order with bracketing prices and the 2 of the 3 orders which make up the bracket order set are simulated.

        T 1 Reply Last reply Reply Quote 0
        • T
          Taewoo Kim @backtrader last edited by Taewoo Kim

          Oanda doesn't have bracket orders, but rather an order with bracketing prices and the 2 of the 3 orders which make up the bracket order set are simulated.

          1. Yes I remember this part from another forum post.

          2. I figured it out. This works:

            valid=datetime.utcnow() + timedelta( hours=num_hours_traversed)

          This, however, does not:

          valid=self.datas[0].datetime.datetime() + timedelta( hours=num_hours_traversed)
          

          How do I force BT to deal everything in UTC ? I see in your docs:

          Unless a tz parameter (a pytz-compatible object) is passed to the data feed, all time output is in UTC format as expressed above.
          

          But above it says "pytz is not really recommended"...?

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

            valid=self.datas[0].datetime.datetime() + timedelta( hours=num_hours_traversed)
            ```
            

            What's not actually working?

            @Taewoo-Kim said in How to get the (live) broker's API response data for bracket order?:

            How do I force BT to deal everything in UTC ?

            Everything is done in UTC unless told otherwise.

            But above it says "pytz is not really recommended"...?

            To have all us on the same page, you can point to the specific documentation page.

            1 Reply Last reply Reply Quote 0
            • T
              Taewoo Kim last edited by

              not working => the order doesn't register at all

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

                See:

                • Thread title: How to get the (live) broker's API response data for bracket order?

                • This doesn't work:

                  valid=self.datas[0].datetime.datetime() + timedelta( hours=num_hours_traversed)
                  
                • not working => the order doesn't register at all

                They are for sure connected in your code, tests and line of thought, but they provide no information here becase there is no context to bind them together.

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