Zipline: Buy and sell orders

Created on 2 Aug 2020  路  5Comments  路  Source: quantopian/zipline

How can I specifically buy and sell an asset?

I am creating an algorithm which generates buy and sell signal from technical analysis. I want to go long and short trade using my analyzed signal.

How to proceed?

Sincerely,
Vishal

All 5 comments

The way I did it was for a pairs trading strategy for my thesis.

if signal for position:
order_target_percent(stock1, weight)
order_target_percent(stock2, -weight)

the minus sign tells the algo to go short

@cemal95
I want to do go short and long for the same stock.

Then apply it to the above, you can also use order(stock, quantitiy) or order_target(stock, %) and mess around with these. But, why go long and short the same stock? could you not use the net value of you positions to either go long or short once?

@cemal95
I am using a sma crossover to go either long or short on the same stock.

@cemal95
Thanks a lot it helped.

Was this page helpful?
0 / 5 - 0 ratings