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 load stock list into strategy

    General Discussion
    2
    2
    686
    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.
    • S
      stentor last edited by

      Hi,
      I have a dictionary of stock list which is generated outside the strategy,
      the list looks like:
      {"2017-1-1": stock_list1,
      "2017-1-2": stock_list2,
      ......
      }
      My question is how I can load the dictionary into strategy so that I can use buy order to buy them?

      thanks a lot

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

        First you will need to load all data feeds for all stocks into bt. You may want to parse your dictionary and compile this list of all stocks and then load data feeds into bt.

        Then every time you do your calculations in the next() to issue buy order you need to check if the stock is included in your original stock_list_# on that date.

        • If my answer helped, hit reputation up arrow at lower right corner of the post.
        • Python Debugging With Pdb
        • New to python and bt - check this out
        1 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post
        Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors