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



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


  • administrators

    @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.