For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See:

how to load stock list into strategy

  • 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

  • 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.

Log in to reply