-
Hi! Firstly, thank you for awesome backtesting solution. I have precomputed weights for my portfolio, and trying to change weights every 30 days using |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @al33m501, specifically for the function If you want to rebalance on custom periods (for example, each 1st of the month), instead of changing The If you think you can build your weights array prior to the simulation, there is a simpler approach: https://vectorbt.dev/docs/portfolio/base.html#vectorbt.portfolio.base.Portfolio.from_orders |
Beta Was this translation helpful? Give feedback.
Hi @al33m501,
specifically for the function
pre_segment_func_nb
, you can read about variousc
fields here. The current index (= row) can be accessed usingc.i
, while the current group (= range of columns that share the same capital) ranges betweenc.from_col
andc.to_col
. You can then domy_array[c.i, c.from_col:c.to_col]
to access elements that belong to this segment, given that you built your array properly - it must be of the same shape as your price. Since inpre_sim_func_nb
we defined that each 30th segment is active while all others are inactive, yourc.i
will be 30, 60, 90, etc.If you want to rebalance on custom periods (for example, each 1st of the month), instead of changing
seg…