|
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.
Question about order state. |
[hanghangzhu]
|
Post subject: Question about order state. |
Post rating: 0
|
Posted: Mon 07 Mar, 2011, 16:23
|
|
User rating: 0
Joined: Sat 06 Nov, 2010, 02:22 Posts: 8 Location: Canada
|
first i submit a order with specified label and other setting like price, stop loss, take profit, and so on, i cannot find this order by the label after this order was closed. it always say that the null pointer. i found the value of [ order ] was always null. where am i wrong?
my purpose is, if you submitted several orders and they are filled, in the running time, how can you figure out which one close. i want to use the label to identify different orders, but seems order was null after they are closed.
Attachments: |
1.jpg [172 KiB]
Downloaded 452 times
|
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on
this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control
on their content. Anyone accessing this webpage and downloading or otherwise making use of any document,
data or information found on this webpage shall do it on his/her own risks without any recourse against
Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from
the use and/or reliance on any document, data or information found on this webpage.
|
|
|
|
|
 |
API Support
|
Post subject: Re: question about order state. |
Post rating: 0
|
Posted: Tue 08 Mar, 2011, 09:23
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
Hi, You can get an order label after it is closed in the onMessage method. Please consider the following code: public void onMessage(IMessage message) throws JFException { if (message.getType().equals(IMessage.Type.ORDER_CLOSE_OK)) { console.getOut().println("Order was closed: " + message.getOrder()); console.getOut().println("Order label: " + message.getOrder().getLabel()); } }
|
|
|
|
 |
[hanghangzhu]
|
Post subject: Re: question about order state. |
Post rating: 0
|
Posted: Tue 08 Mar, 2011, 11:55
|
|
User rating: 0
Joined: Sat 06 Nov, 2010, 02:22 Posts: 8 Location: Canada
|
no, you did not understand my question, i know the label for certain order. my problem is, if i have several filled positions, if one or several of them were closed, i want to use the label to figure out the closed position, and then to get the close time or close price as below
// after order was closed IOrder order = engine.getOrder( label ); // but when it goes here, it always say null pointer long close_time = order.getCloseTime() / 1000;
can you give me some code samples if we know the label and want to use the label to find the order?
|
|
|
|
 |
[hanghangzhu]
|
Post subject: Re: question about order state. |
Post rating: 0
|
Posted: Wed 09 Mar, 2011, 07:53
|
|
User rating: 0
Joined: Sat 06 Nov, 2010, 02:22 Posts: 8 Location: Canada
|
o, i think i found the reason, i guess, if a position was closed, it is not in ENGINE, so if you want to use engine.getOrder to find some order, the states of the order can only be CANCELED, CREATED, FILLED, and OPENED, if you want to find a closed order, you should use message function to find the closed order.
is that right, supporter?
|
|
|
|
 |
API Support
|
Post subject: Re: question about order state. |
Post rating: 0
|
Posted: Wed 09 Mar, 2011, 13:25
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
Yes, it is right. Or you can add orders labels in the List<String> and then check if order with label from the list exists in the ENGINE, if no, then order is closed.
|
|
|
|
 |
[hanghangzhu]
|
Post subject: Re: question about order state. |
Post rating: 0
|
Posted: Wed 09 Mar, 2011, 15:47
|
|
User rating: 0
Joined: Sat 06 Nov, 2010, 02:22 Posts: 8 Location: Canada
|
thanks, why not add some explaination in the API, something like this is very hard to find the answer.
|
|
|
|
 |
API Support
|
Post subject: Re: question about order state. |
Post rating: 0
|
Posted: Wed 09 Mar, 2011, 18:51
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
|
|
|
 |
|
Pages: [
1
]
|
|
|
|
|