Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Record_vars for weightings?

I have a two asset portfolio which rebalances between the two only. How can I have the record_vars function give me the weightings in each asset so I can see it record when building the algorithm, and watching the backtest going.

4 responses

@Nathan,

You may try something like this:

    for i, sec in enumerate(ASSETS):  
        if data.can_trade(sec):  
            record(**{sec.symbol: wt[i]})  
            order_target_percent(sec, wt[i])  

@Vladimir

Thanks for the reply. Could you tell me where that goes in the algorithm posted here?

Stock & Bond Risk Parity

@Nathan,

You should insert after line 69 this:

record(**{context.asserts[i].symbol: context.asserts_position[i]})  

@Vladimir,

Thanks a lot, that works.