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_trade()

    General Code/Help
    2
    2
    1450
    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
      blonc last edited by

      I believe this has already been answered in the following post:

      notify_trade-not-firing

      But I just wanna confirm before I go writing new code.

      notify_trade() is only called on the complete closing of a position, so if you have a strategy that for example buys XYZ stock once, but closes it over multiple signals, the notify_trade() will not be called till the last share of XYZ is sold?

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

        @blonc said in notify_trade():

        notify_trade() is only called on the complete closing of a position

        notify_trade is called:

        • When a trade is started
        • When a trade is closed

        @blonc said in notify_trade():

        but closes it over multiple signals,

        You know you are closing it, but the platform cannot know it. A Trade may go down from having a size of 50 units to 1. Is that closing? No. Because it may go again up to 100.

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