How to liquidate all the positions of portfolio?

Hi



Can anyone tell me how to liquidate all the positions of a portfolio?



I used this code and did not worked.

open_orders = get_open_orders()
for order_id in open_orders:
    cancel_order(order_id)

Even tried to use  order_target(asset, quantity, limit_price)  with zero or minus the total lot buy.

Is there ant way to close all the positions in portfolio?

to get out of a particular asset, use order_target(asset, 0).



to get out of all positions first import the utility function as below:



from blueshift_library.utils.utils import square_off



then in a place where you want to get out of all positions, call this function with 'context' as argument:



square_off(context)