- ago
SplitPosition doesn't exist in the current context.

In the conversion PDF it gives a -- but I think there was another place where there was a -- for WL7 but the function still existed.

How can you split a position in WL7 if you can please?

Can you add more shares to a position?

Thanks as always
0
181
Solved
3 Replies

Reply

Bookmark

Sort
- ago
#1
It's unlikely that WL7 will retain SplitPosition but we may have something in the pipeline as a replacement. Please stay tuned.
0
- ago
#2
Ok thank you.

This relates to pair trading and is an issue since the position sizes are determined by the backtest and not the strategy code.

Let's say I definitely want to own INTC or AMD at all times but don't know which is better so just periodically rebalance to the one that's underperforming compared to the other by changing the ratio of the ownership over time. I don't want to be short and don't mind owning both.

You can do that by being 100% invested with let's say all INTC to start (probably would start at 50/50). If it goes up 5% and AMD only goes up 2.5%, then you would sell a portion, let's say 25% of your INTC and get AMD with that capital. And vice-versa.

That could be done by splitting the INTC position into 75%/25%, selling the 25% and buying 100% of remaining capital in AMD.

I'm not asking you to write the code for the whole thing, but if SplitPosition isn't available, is it possible to implement such a strategy in WL7 and if so how do you deal with changing the position size?

I guess you could potentially close the INTC position and put in buy orders for both but the problem with that is I don't want to use margin (i.e. only use the capital available) and I don't see how to set a position size in the code since that's determined by the position sizer in the backtest which seems to be unavailable to the code.

Thanks
0
- ago
#3
QUOTE:
This relates to pair trading and is an issue since the position sizes are determined by the backtest and not the strategy code.

WL7 lets you determine the position size in the strategy code. It's possible to assign a custom value based on the portfolio's current equity, for example:

CODE:
var pct = 1; //% var size = CurrentEquity / 100 * pct; PlaceTrade(bars, TransactionType.Buy, OrderType.Market).Quantity = size;


QUOTE:
but if SplitPosition isn't available, is it possible to implement such a strategy in WL7 and if so how do you deal with changing the position size?

As a workaround for now, you could take N positions in INTC and sell 1 of them if AMD goes up, then another 1 and so on.

CODE:
var pct = 1; //% var size = CurrentEquity / 100 * pct; var posTag = 123; //tag, PlaceTrade(bars, TransactionType.Buy, OrderType.Market, 0, posTag).Quantity = size; PlaceTrade(bars, TransactionType.Buy, OrderType.Market, 0, posTag).Quantity = size; PlaceTrade(bars, TransactionType.Buy, OrderType.Market, 0, posTag).Quantity = size; PlaceTrade(bars, TransactionType.Buy, OrderType.Market, 0, posTag).Quantity = size;


To identify the Position to unload, the Position.Tag property could be used.
0
Best Answer

Reply

Bookmark

Sort