I would like to place different size positions long and short on multiple stocks. For example, let's assume the whole portfolio should be long $100 and short $100, and I have 5 stocks that I am trading. My algorithm computes a "weight" to put on each stock, with 1.0 being the total portfolio weight on each side long or short. Meaning, if I assign a weight of .5 to a stock, then it should have a position of long $50, or if I have a weight of -.25, then the position should be short $25. My algorithm ensures that each side (long or short) adds up to 1.0 (or -1.0 on the short side), so this way the long and short sides are the same size, so the portfolio always remains dollar-neutral (long and short same amount).
Can you please show me some simple code that would take the weights for stocks that my algorithm produces (on a daily basis) and place the appropriate trade entries? For example, can I specify a dollar amount of stock to buy in my trade order? What should the NinjaScript command look like?
Thanks!
Protis
Comment