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/

    I want to determine my position type in next (), buy or sell. What should I write?

    General Discussion
    2
    3
    57
    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.
    • MuSaCN
      MuSaCN last edited by

      I want to determine my position type in next (), buy or sell. What should I write?

      1 Reply Last reply Reply Quote 0
      • run-out
        run-out last edited by

        Your question is unclear to me. Are you looking for trade position (number of units long or short), or if an order is buy sell?

        For trade position in next use:

        getposition(data=None, broker=None)
        

        For order:
        Strategy class offers three methods to assist you with orders.

        User Methods:
            isbuy(): returns bool indicating if the order buys
            issell(): returns bool indicating if the order sells
            alive(): returns bool if order is in status Partial or Accepted
        
        MuSaCN 1 Reply Last reply Reply Quote 3
        • MuSaCN
          MuSaCN @run-out last edited by

          @run-out
          Thanks,
          getposition(data=None, broker=None) is helpfull.

          1 Reply Last reply Reply Quote 1
          • 1 / 1
          • First post
            Last post
          Copyright © 2016, 2017, 2018 NodeBB Forums | Contributors
          $(document).ready(function () { app.coldLoad(); }); }