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/

    How to use a dataframe with weights to open/close positions?

    Indicators/Strategies/Analyzers
    2
    2
    109
    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.
    • J
      JFilho last edited by

      Hello guys, i'm new with backtrader lib and would like to know if is possible to migrate a simple strategy that I had previously tested using the 'bt' library. The strategy weekly buys n shares and sells n shares (long / short). The process of choosing the shares to be bought / sold were made externally in another framework and were saved in a csv. In this case, these data are organized in such a way that the columns correspond to the shares and the values ​​correspond to the weights that each of them would have for each date.
      That is, I have the data with dates and weights for each stock that will be traded. Please, if anyone has a reference or an example of how to create a backtest based on these conditions.

      Any help will be good :-)

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

        Here are examples of custom loaders for Pandas:

        https://community.backtrader.com/topic/2971/multiple-assets-with-custom-pandas-dataframe/2

        https://community.backtrader.com/topic/2428/create-indicator-line-from-dataframe-not-from-data-in-cerebros/5

        RunBacktest.com

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