How to use a dataframe with weights to open/close positions?
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 :-)
run-out last edited by
Here are examples of custom loaders for Pandas: