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/

    notify_order() Race Condition

    General Code/Help
    2
    2
    521
    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.
    • A
      agserran last edited by agserran

      Hello,

      I am wondering, is it wrong to send orders inside the notify_order() method? During live trading, I wait for an entry order to be signalled as 'Complete' in the notify_order() method and immediately send 2 stop loss orders (one fixed and one trailing) but I noticed that notify_order() is never called again for those stop loss orders, more specifically I do not receive order 'Accepted' even though the orders show up on the live broker. The live broker I am using btw is Interactive Brokers. Should I not send these stop loss orders inside this method to allow it to be freed up?

      Thanks

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

        @agserran said in notify_order() Race Condition:

        notify_order() Race Condition

        The notifications are received in the main thread via a synchronized queue (standard python machinery). Your code never leaves the main thread.

        When you send orders they are managed in the main thread (ibpy puts them in a socket and there they go)

        It cannot as such be a race condition, because only 1 thread is involved.

        Some examples with what you do would be needed.

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