Backtrader Community

    • 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/

    Placing order to broker from notify_order() causing 1 candle lag

    General Code/Help
    2
    2
    134
    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.
    • Tejas Pinge
      Tejas Pinge last edited by

      We have created live DataFeed where _load() returns 1 min live candle.
      This data is being used in the strategy's next(self).
      The issue is if the signal is generated for a candle in next() then notify_order() is called after receiving next candle. This is causing 1 candle delay in live trading as we are placing order to broker from notify_order().

      Scenario:

      1. _load(self): - Returns 1 min candle at 9:30
      2. next(self) - Strategy creates Buy signal for 9:30 candle.
      3. notify_order(self, order) - Places order after getting 9:31 candle.

      Are we missing anything? Kindly guide.

      1 Reply Last reply Reply Quote 0
      • A
        ab_trader last edited by

        Share the script please. It is not clear what do you try to achieve.

        notify_order() is called than your orders are processing, but looks that you don't have them yet. So it should not be called at all.

        • If my answer helped, hit reputation up arrow at lower right corner of the post.
        • Python Debugging With Pdb
        • New to python and bt - check this out
        1 Reply Last reply Reply Quote 1
        • 1 / 1
        • First post
          Last post
        Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors