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/

    can we use self.position.set(size=100, price=15.01) to initialize a data's initial size and price?

    General Discussion
    2
    2
    137
    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.
    • Li Mike
      Li Mike last edited by

      in this post , it use data_pos.set(pos_size, pos_price) in a analyzer. So my question is: in a strategy's init method, can we use self.position.set(size=100, price=15.01) to initialize a data's initial size and price? Is it safe?

      1 Reply Last reply Reply Quote 0
      • vladisld
        vladisld last edited by

        Technically it should work ( in start method for example), however IMHO it is better to set the position outsize the strategy code - just in case you would like to re-use your strategy in live-trading or otherwise keep you strategy code independent of external setup.

        Analyzer is probably a better place - you may always switch the analyzer on for back testing and off for live trading for example - leaving your strategy code intact.

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