|
Attention! Read the forum rules carefully before posting a topic.
Try to find an answer in Wiki before asking a question. Submit programming questions in this forum only. Off topics are strictly forbidden.
Any topics which do not satisfy these rules will be deleted.
getRequestedAmount and getAmount |
cb888trader
|
Post subject: getRequestedAmount and getAmount |
Post rating: 0
|
Posted: Wed 18 Jan, 2012, 16:55
|
|
User rating: 0
Joined: Tue 22 Nov, 2011, 12:47 Posts: 130 Location: United States,
|
I have a question in regards to getRequestedAmount and getAmount
If I'm doing partial closes in multiple steps - will those methods return different values after each partial close request / fill ?
Scenario Example Step 1: Open a trade with 10,000 amount.
Step 2:
Close 2,000
onMessage: FILL_OK
getAmount = ? getRequestedAmount = ?
Step 3:
Close 8,000
onMessage: FILL_OK
getAmount = ? getRequestedAmount = ?
can you please elaborate? From the javadoc it is not clear.
|
|
|
|
 |
API Support
|
Post subject: Re: getRequestedAmount and getAmount |
Post rating: 0
|
Posted: Thu 19 Jan, 2012, 15:01
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
The messages that you receive are: IMessage.Type.ORDER_CLOSE_OK, this is according to https://www.dukascopy.com/wiki/#Orders_o ... es_diagramFor checking amounts please consider changing in the partial close example message logging in onBar method to the following: print(String.format("%s closePrice=%.5f, amount=%.3f, requestedAmount=%.3f, closeTime=%s, state=%s", order.getLabel(), order.getClosePrice(), order.getAmount(), order.getRequestedAmount(), sdf.format(order.getCloseTime()), order.getState()));
|
|
|
|
 |
cb888trader
|
Post subject: Re: getRequestedAmount and getAmount |
Post rating: 0
|
Posted: Thu 19 Jan, 2012, 16:13
|
|
User rating: 0
Joined: Tue 22 Nov, 2011, 12:47 Posts: 130 Location: United States,
|
I did what you told me but I'm still confused.
getRequestedAmount - will it return different values during the life time of the position? for example - if I perform multiple partial close - will it return different values?
getAmount -should it always return the remaining amount that is not filled PER request? so if multiple partial close operations are done, is it possible to receive multiple zero values PER request?
|
|
|
|
 |
API Support
|
Post subject: Re: getRequestedAmount and getAmount |
Post rating: 0
|
Posted: Thu 19 Jan, 2012, 16:40
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
cb888trader wrote: getRequestedAmount - will it return different values during the life time of the position? for example - if I perform multiple partial close - will it return different values? No, the value is relevant when you consider partial fill, not partial close. If the order was filled in full then amount and requested amount will match regardless of what kind of close operations you perform on the order. cb888trader wrote: getAmount -should it always return the remaining filled amount that is not filled PER request? Presumably you meant - amount that is not closed. When order is in state FILLED IOrder.getAmount() returns the remaining amount of the order, at any point in time, regardless of close amounts and their repetitions. cb888trader wrote: so if multiple partial close operations are done, is it possible to receive multiple zero values PER request? Order can't have IOrder.getAmount() = 0, since - Order can't get filled with 0 amount.
- If after close operation the order amount is 0, then it has status CLOSED.
|
|
|
|
 |
cb888trader
|
Post subject: Re: getRequestedAmount and getAmount |
Post rating: 0
|
Posted: Thu 19 Jan, 2012, 17:15
|
|
User rating: 0
Joined: Tue 22 Nov, 2011, 12:47 Posts: 130 Location: United States,
|
In that case -
When performing a partial close. How should one check that the partial close was committed successfully?
Initial Order is for 1M
Order is in status FILLED and IOrder.getRequestedAmount() == IOrder.getAmount()
Now - I perform a Partial Close.
How can I tell if the partial close was fully executed at the ECN ?
|
|
|
|
 |
API Support
|
Post subject: Re: getRequestedAmount and getAmount |
Post rating: 0
|
Posted: Thu 19 Jan, 2012, 17:25
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
cb888trader wrote: When performing a partial close. How should one check that the partial close was committed successfully? On successful close: You receive ORDER_CLOSE_OK message, order amount changes, order close time and very likely that order close price does change. On failed close: You receive ORDER_CLOSE_REJECTED message and the other parameters stay the same. cb888trader wrote: How can I tell if the partial close was fully executed at the ECN ? By checking IOrder.getAmount() after you receive ORDER_CLOSE_OK message. The aforementioned Partial close example strategy lets you test almost all of these cases (with exception of ORDER_CLOSE_REJECTED and partial close only partially executed).
|
|
|
|
 |
cb888trader
|
Post subject: Re: getRequestedAmount and getAmount |
Post rating: 0
|
Posted: Fri 20 Jan, 2012, 14:02
|
|
User rating: 0
Joined: Tue 22 Nov, 2011, 12:47 Posts: 130 Location: United States,
|
thank you support for the clarifications.
After rethinking - I find it more suitable to check the state of the order at the IStrategy.onMessage() and only after that inspect the message type.
So here is the pseudo:
onMessage: -> if IMessage.getOrder() != null --> check IOrder.getState() --> for each possible IOrder.State handle according to IMessage.getType() and other specific logic (including IOrder.getAmount(), IOrder.getRequestedAmount() etc.)
|
|
|
|
 |
|
Pages: [
1
]
|
|
|
|
|