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/

    Forcing the price that backtrader uses for trades

    General Code/Help
    2
    2
    25
    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.
    • F
      floomi last edited by

      I would like to write a strategy that trades options using only the underlying for its price signals.

      Rather than giving backtrader a data feed for every option strike and expiration over my time period I figured it would be easier to write a strategy that uses the underlying, fetches the option I want to trade on a buy/sell signal, and force the broker to fill a trade at that option's price. I know this will horribly miscalculate portfolio value any time I'm in a position but I'm okay with that for now.

      So: can I force the broker to fill an order at a price I define? I notice that the buy/sell functions have a price parameter but the docs indicate that's for setting stop/limit order execution prices. From poking around in the code it seems like exectype = Order.Historical might be what I want, but I figured I should check first. Is this doable without too much pain?

      Alternatively: can I build my own price feed every tick in strategy next() and have the broker's fill and portfolio value calculators use that data line instead? Thanks!

      A 1 Reply Last reply Reply Quote 0
      • A
        ab_trader @floomi last edited by

        @floomi orders are issued for certain data feed. you can easily get signals on one data feed and issue buy/sell orders on another. data feeds are added to cerebro before the strategy is backtested, therefore you can not create a data feed inside the strategy.

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