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/

    Get tradeid of order in order_notify

    General Code/Help
    1
    2
    19
    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.
    • R
      ronnyBravo last edited by

      Hi,

      How would it be possible to get the tradeid value of the order in notify_order method when the status of the order changes. For example, when my order gets completed I would like to check via tradeid which order it was.

      I found this forum post, but one of the answers did not work (int object has not attribute "ref" error) and the other answer was as useless as it can get.

      R 1 Reply Last reply Reply Quote 0
      • R
        ronnyBravo @ronnyBravo last edited by

        @ronnybravo

        Answering my own question.

        The order.ref answer that was given in that forum post actually works. My mistake was that I wanted to get the attributes directly and compare them. However the order class has overwritten the == method in which itself it compares ref attributes.

        So instead of

        if self.tradeid == order.ref:
        

        I had to write

        if self.tradeid == order:
        
        1 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post
        Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors