Posted 9/28/2010 08:29:32
|
|
|
|
Hi,
I'm under impression that the PositionState works as follow:
1. Pending
Order entered and has not been filled (including the order that has been partially filled).
2. Open
Order has been fully filled (including the order that has been closed which has been partially filled).
3. Closed
Order has been closed and all the related positions has been fully closed.
Is my logic right?
If so, what happen to PositionState when:
1. Order is closed forcefully by the broker?
2. Order is closed when the order is in Pending state with partially filled?
Thanks,
Felix Tjung
|
|
Posted 9/28/2010 11:41:03
|
|
|
|
You are mostly correct about PositionState. Positions with partially filled entry orders have a PositionState of Open.
If an order is cancelled (either forcefully by the broker or by the user), the order will be removed from the pending order list for the position (note that this isn't related to whether the position state is pending or not). If this causes pending position to have no pending orders, then it will be removed from the pending position list, and will have a position state of PositionState.None.
Thanks,
Daniel
|
|
Posted 9/28/2010 16:53:27
|
|
|
|
Hi,
does that mean, if I have open position which has been fully filled, and I cancel that position, the position state for that position is PositionState.None?
Thanks again,
Felix
|
|
Posted 9/28/2010 19:56:26
|
|
|
|
Oh, another question that I got is how do I get the position size of "in total (filled + unfilled)" and "filled size only"?
Thanks again,
Felix
|
|
Posted 9/28/2010 21:43:39
|
|
|
|
does that mean, if I have open position which has been fully filled, and I cancel that position, the position state for that position is PositionState.None?
No, once the state of a position is Open, it can only eventually go to Closed, but not None. And note that a position becomes Open on the first fill, even if that's only a partial fill.
Oh, another question that I got is how do I get the position size of "in total (filled + unfilled)" and "filled size only"?
Position.CurrentSize is the "filled size only". To figure out the unfilled size, look at the Orders list for the position. For each order, add up the Quantity for each fill in the Fills list, and subtract that from the Order.Size to get the unfilled amount for the order. Add up the unfilled amount for all the orders to get the unfilled amount for the position.
Thanks,
Daniel
|
|
Posted 9/29/2010 17:05:29
|
|
|
|
Am I correct to say:
* Order.Size represents the total size?
* Trade.Size represents the filled size?
and also, I noticed each position has itsown stop loss and take profit. Do they have any implication to Position.Orders? (e.g. having stop loss and take profit will create a new order)
Thanks again.
Felix
|
|
Posted 9/30/2010 01:07:51
|
|
|
|
You are correct. But note that Order.Size is the total size of just one order, and there can be more than one. Likewise Trade.Size is the size of a single fill, but there can be more than one.
RightEdge manages the stop loss and profit target orders for you. They will show up in the Orders list. You can look at the TradeType property of the order to distinguish these from orders you submitted.
Thanks,
Daniel
|
|
Posted 9/30/2010 17:35:49
|
|
|
|
Okay, this is a bit confusing =/.
Let say you I open a position with size (200), it has been partially filled with size (100).
Does that means I have:
* 1 Order of size 200?
and
* 1 Trade of size 100?
Suppose if I close this position before it's fully filled, what will happen? does the order with size 200 gets removed from order list and trade is still there in trade list?
Thanks,
Felix
|
|
Posted 10/3/2010 17:02:34
|
|
|
|
Yes, you would have a partially filled order with a total size of 200, and a trade of size 100. If you call ClosePosition, RightEdge will send a cancellation for all pending orders, as well as submit an order to close the position. So in this case the partially filled order would be cancelled and RightEdge would send a market sell order of size 100. The order list only includes active orders, so once the order was cancelled it wouldn't be in the list anymore. The trade would remain in the trade list.
Thanks,
Daniel
|
|
Posted 10/3/2010 21:14:51
|
|
|
|
Hi,
Thanks a lot Daniel. It's all clear to me now. I only hope this would be documented somewhere. I can't find any documentation about it.
Thanks again,
Felix
|
|
|
|