|
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.
orders history |
[timurila]
|
Post subject: orders history |
Post rating: 0
|
Posted: Fri 26 Jun, 2009, 10:03
|
|
User rating: 0
Joined: Fri 26 Jun, 2009, 10:01 Posts: 2
|
Is it possible to get access to orders history(closed orders) from jforex strategy?
|
|
|
|
 |
API Support
|
Post subject: Re: orders history |
Post rating: 0
|
Posted: Fri 26 Jun, 2009, 10:11
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
Question right in time ... next week will be released new version with lot of cool stuff including access to historical orders. If you need just get closed orders during strategy run , you can do it right now by catching order_close_ok message ...
|
|
|
|
 |
[timurila]
|
Post subject: Re: orders history |
Post rating: 0
|
Posted: Wed 19 Aug, 2009, 22:34
|
|
User rating: 0
Joined: Fri 26 Jun, 2009, 10:01 Posts: 2
|
Is order history access already available? How to work with it?
Thanks
|
|
|
|
 |
API Support
|
Post subject: Re: orders history |
Post rating: 0
|
Posted: Thu 20 Aug, 2009, 10:29
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
|
|
|
 |
Guest
|
Post subject: Re: orders history |
Post rating: 0
|
Posted: Mon 17 May, 2010, 16:10
|
|
User rating: -
|
The order data returned by getOrdersHistory() and readOrdersHistory() calls contain only Fill time, Order command, Amount and Fill price data. Other methods like getLabel(), getClosePrice, get CloseTime on the returned order returns null. I need the Label, Close Price and CloseTime data for historical orders to analyze different strategies. How I can get them? Thank you Peter
|
|
|
|
 |
API Support
|
Post subject: Re: orders history |
Post rating: 0
|
Posted: Tue 18 May, 2010, 09:53
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
Hi, at the moment we are not storing orders labels, but we are planing to do this in a near future. Please consider this sample to see how to get values from getClosePrice and getCloseTime package jforex;
import java.util.Calendar; import java.util.List;
import com.dukascopy.api.*; import com.dukascopy.api.IEngine.OrderCommand;
public class TestStrategy implements IStrategy { private IEngine engine; private IOrder order; private IContext context; private IConsole console;
public void onStart(IContext context) throws JFException { this.engine = context.getEngine(); this.context = context; this.console = context.getConsole(); }
public void onAccount(IAccount account) throws JFException { }
public void onMessage(IMessage message) throws JFException { }
public void onStop() throws JFException { if(order != null && !order.getState().equals ( IOrder.State.CLOSED ) && !order.getState().equals ( IOrder.State.CANCELED ) ) { order.close(); } }
public void onTick(Instrument instrument, ITick tick) throws JFException { if ( instrument == Instrument.EURUSD) { if ( order == null ){ order = engine.submitOrder("Order2", instrument, OrderCommand.SELL, 0.1); console.getOut().println("Order placed: "+order.getLabel()); } } }
public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException { if (instrument == Instrument.EURUSD && period == Period.TEN_SECS){ console.getOut().println("Order state: "+order.getState()); Calendar startDate = Calendar.getInstance(); startDate.roll(10, -1); Calendar endDate = Calendar.getInstance(); console.getOut().print("startDate: "+startDate.getTime()); console.getOut().println(", endDate: "+endDate.getTime()); List<IOrder> orders = context.getHistory().getOrdersHistory(Instrument.EURUSD, startDate.getTimeInMillis(), endDate.getTimeInMillis()); if (!orders.isEmpty()){ console.getOut().println("ClosePrice: "+orders.get(orders.size()-1).getClosePrice()+", closeTime: "+orders.get(orders.size()-1).getCloseTime()); } } } } If you still have questions, please do not hesitate to ask.
|
|
|
|
 |
[arnab]
|
Post subject: Re: orders history |
Post rating: 0
|
Posted: Wed 08 Sep, 2010, 05:28
|
|
User rating: 0
Joined: Tue 25 May, 2010, 04:21 Posts: 21
|
Is it possible to retrieve OP_BUYSTOP deleted order details from the order history?
|
|
|
|
 |
API Support
|
Post subject: Re: orders history |
Post rating: 0
|
Posted: Wed 08 Sep, 2010, 16:09
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
|
|
|
 |
[arnab]
|
Post subject: Re: orders history |
Post rating: 0
|
Posted: Thu 09 Sep, 2010, 00:15
|
|
User rating: 0
Joined: Tue 25 May, 2010, 04:21 Posts: 21
|
|
|
|
 |
[Frank]
|
Post subject: Re: orders history |
Post rating: 0
|
Posted: Thu 09 Sep, 2010, 00:39
|
|
User rating: 0
Joined: Thu 02 Sep, 2010, 05:01 Posts: 49
|
Hi Support, I even have trouble with function IHistory.getOrdersHistory(). The function return always an empty list of orders, even if there are filled orders on the server and the time interval is correct. I used the following code: public void onStart(IContext context) throws JFException { this.engine = context.getEngine(); this.indicators = context.getIndicators(); this.console = context.getConsole(); console.getOut().println("---Started---"); this.history = context.getHistory(); this.context = context; this.userInterface = context.getUserInterface(); numberOrdersHistory(2010,9,1);
}
//--------------------------------------------------------------------------------------------------------------------------- //read from server the number of previous orders // private int numberOrdersHistory(int year,int month, int day ) throws JFException { Calendar startDate = Calendar.getInstance(); startDate.set(year,month -1,day,0,0,0); Calendar endDate = Calendar.getInstance(); console.getOut().print("startDate: " + startDate.getTime()); console.getOut().println(", endDate: " + endDate.getTime()); int numberOrders = 0; List<IOrder> listOrders = null; try{ listOrders = context.getHistory().getOrdersHistory(myInstrument, startDate.getTimeInMillis(), endDate.getTimeInMillis());
if(listOrders .isEmpty()) console.getOut().println("LIST ORDERS EMPTY"); numberOrders = listaOrdini.size(); console.getOut().println("NUMBER ORDERS: " + numberOrders ); }catch (Exception e) { console.getErr().println("ERROR: " + e.toString()); return -1; } return numberOrders } It always print: startDate: ... endDate: ... LIST ORDERS EMPTY NUMBER ORDERS: 0 Best regards, Frank
|
|
|
|
 |
[Frank]
|
Post subject: Re: orders history |
Post rating: 0
|
Posted: Thu 09 Sep, 2010, 01:11
|
|
User rating: 0
Joined: Thu 02 Sep, 2010, 05:01 Posts: 49
|
The line numberOrders = listaOrdini .size(); has wrong variable name the right line is numberOrders = listOrders .size(); Best regards, Frank
|
|
|
|
 |
API Support
|
Post subject: Re: orders history |
Post rating: 0
|
Posted: Thu 09 Sep, 2010, 08:52
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
|
|
|
 |
[Frank]
|
Post subject: Re: orders history |
Post rating: 0
|
Posted: Thu 09 Sep, 2010, 19:25
|
|
User rating: 0
Joined: Thu 02 Sep, 2010, 05:01 Posts: 49
|
Hi Support, the code at link "https://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?p=24812#p24812" that you show me, doesn't work. Could you, please, verify it. I changed the line //engine.submitOrder("eurusd_order", Instrument.EURUSD, OrderCommand.BUY, 0.01); because the server didn't accept order less than 10000 with this one //engine.submitOrder("eurusd_order", Instrument.EURUSD, OrderCommand.BUY, 0.01); then the strategy open a position but the function printOrderHistory doesn't show the order. The output is the following 2010-09-09 17:58:17 Checking USD/CAD: 2010-09-09 17:58:17 Checking USD/CHF: 2010-09-09 17:58:17 Checking GBP/USD: 2010-09-09 17:58:17 Checking AUD/CAD: 2010-09-09 17:58:17 Checking EUR/CHF: 2010-09-09 17:58:17 Checking USD/JPY: 2010-09-09 17:58:17 Checking EUR/USD: 2010-09-09 17:58:17 Checking EUR/CAD: 2010-09-09 17:58:17 startDate: Wed Sep 08 19:58:17 CEST 2010, endDate: Thu Sep 09 19:58:17 CEST 2010 2010-09-09 17:58:17 Strategy "TestStrategy" is started at 2010-09-09 17:58:17.285 GMT on the local computer 2010-09-09 17:58:17 Strategy Disclaimer rev.1 is accepted. 2010-09-09 17:58:17 Starting "TestStrategy" strategy at 2010-09-09 17:58:17.284 GMT on the local computer Best regards, Frank
|
|
|
|
 |
[Frank]
|
Post subject: Re: orders history |
Post rating: 0
|
Posted: Fri 10 Sep, 2010, 14:22
|
|
User rating: 0
Joined: Thu 02 Sep, 2010, 05:01 Posts: 49
|
Sorry, I changed this line Quote: engine.submitOrder("eurusd_order", Instrument.EURUSD, OrderCommand.BUY, 0.001); with this one engine.submitOrder("eurusd_order", Instrument.EURUSD, OrderCommand.BUY, 0.01); Best regards, Frank
|
|
|
|
 |
API Support
|
Post subject: Re: orders history |
Post rating: 0
|
Posted: Fri 10 Sep, 2010, 15:48
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
Hi, IHistory.getOrdersHistory() returns closed orders only. Could you please manually open and close an order and rerun the strategy?
|
|
|
|
 |
[Frank]
|
Post subject: Re: orders history |
Post rating: 0
|
Posted: Fri 10 Sep, 2010, 16:49
|
|
User rating: 0
Joined: Thu 02 Sep, 2010, 05:01 Posts: 49
|
Support wrote: Hi, IHistory.getOrdersHistory() returns closed orders only. Could you please manually open and close an order and rerun the strategy? I even opened and closed a position, function printOrderHistory does checking but doesn't show order. It seems that returned list of orders is empty, like in my program. Best regards, Frank
|
|
|
|
 |
API Support
|
Post subject: Re: orders history |
Post rating: 0
|
Posted: Tue 14 Sep, 2010, 14:45
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
Hi, Please run the following strategy on your computer and then copy and paste strategy output here: package jforex;
import java.util.Calendar; import java.util.TimeZone;
import com.dukascopy.api.IAccount; import com.dukascopy.api.IBar; import com.dukascopy.api.IConsole; import com.dukascopy.api.IContext; import com.dukascopy.api.IEngine; import com.dukascopy.api.IHistory; import com.dukascopy.api.IMessage; import com.dukascopy.api.IStrategy; import com.dukascopy.api.ITick; import com.dukascopy.api.Instrument; import com.dukascopy.api.JFException; import com.dukascopy.api.Period; import com.dukascopy.api.IEngine.OrderCommand; import com.dukascopy.api.IMessage.Type;
public class OrdersHistoryTest implements IStrategy { private IEngine engine; private IConsole console; private IHistory history; private IContext context; public void onStart(IContext context) throws JFException { this.engine = context.getEngine(); this.console = context.getConsole(); this.history = context.getHistory(); this.context = context; console.getOut().println("submitting the initial order"); engine.submitOrder("eurusd_order", Instrument.EURUSD, OrderCommand.BUY, 0.01); }
public void onAccount(IAccount account) throws JFException { }
public void onMessage(IMessage message) throws JFException { if (message.getType() == Type.ORDER_FILL_OK){ console.getOut().println("order filled successfully: " + message.getOrder().getLabel()); message.getOrder().close(); } if (message.getType() == Type.ORDER_CLOSE_OK){ console.getOut().println(message.getOrder().getLabel() + " order closed successfully, printing order history"); printOrderHistory(); context.stop(); } }
public void onStop() throws JFException { }
public void onTick(Instrument instrument, ITick tick) throws JFException { } public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException { } private void printOrderHistory() throws JFException{ Calendar from = Calendar.getInstance(); from.setTimeZone(TimeZone.getTimeZone("GMT")); from.roll(Calendar.DAY_OF_YEAR, -1); Calendar to = Calendar.getInstance(); to.setTimeZone(TimeZone.getTimeZone("GMT")); console.getOut().println("from: " + from.getTime()); console.getOut().println("to: " + to.getTime()); console.getOut().println("order history: " + history.getOrdersHistory(Instrument.EURUSD, from.getTimeInMillis(), to.getTimeInMillis() )); } }
|
|
|
|
 |
[Frank]
|
Post subject: Re: orders history |
Post rating: 0
|
Posted: Thu 16 Sep, 2010, 02:18
|
|
User rating: 0
Joined: Thu 02 Sep, 2010, 05:01 Posts: 49
|
Hi Support, the program that you showed me, produced the first time that I ran it the following output: 00:50:24 Strategy "OrdersHistoryTest" is stopped at 2010-09-16 00:50:24.679 GMT on the local computer 00:50:24 Stopping "OrdersHistoryTest" strategy at 2010-09-16 00:50:24.678 GMT on the local computer 00:50:24 order history: [] 00:50:24 to: Thu Sep 16 02:50:24 CEST 2010 00:50:24 from: Wed Sep 15 02:50:24 CEST 2010 00:50:24 eurusd_order order closed successfully, printing order history 00:50:29 Order FILLED at 1.2992 USD (#49621581 SELL 0.01 mil. EUR/USD @ MKT MAX SLIPPAGE 0.0005) - Position #10248053 00:50:24 order filled successfully: eurusd_order 00:50:29 Order FILLED at 1.2993 USD (#49621580 BUY 0.01 mil. EUR/USD @ MKT MAX SLIPPAGE 0.0005) - Position #10248053 00:50:23 submitting the initial order 00:50:23 Strategy "OrdersHistoryTest" is started at 2010-09-16 00:50:23.916 GMT on the local computer 00:50:23 Starting "OrdersHistoryTest" strategy at 2010-09-16 00:50:23.915 GMT on the local computer the order history seems empty, the second time that I run it the following output 00:57:36 Strategy "OrdersHistoryTest" is stopped at 2010-09-16 00:57:36.123 GMT on the local computer 00:57:36 Stopping "OrdersHistoryTest" strategy at 2010-09-16 00:57:36.123 GMT on the local computer 00:57:36 order history: [Fill time: 2010-09-16 00:50:29, order command: BUY, amount: 10000.0, fill price 1.2993, Fill time: 2010-09-16 00:50:29, order command: BUY, amount: 10000.0, fill price 1.2993] 00:57:36 to: Thu Sep 16 02:57:36 CEST 2010 00:57:36 from: Wed Sep 15 02:57:36 CEST 2010 00:57:36 eurusd_order order closed successfully, printing order history 00:57:41 Order FILLED at 1.2992 USD (#49623282 SELL 0.01 mil. EUR/USD @ MKT MAX SLIPPAGE 0.0005) - Position #10248059 00:57:35 order filled successfully: eurusd_order 00:57:40 Order FILLED at 1.29935 USD (#49623281 BUY 0.01 mil. EUR/USD @ MKT MAX SLIPPAGE 0.0005) - Position #10248059 00:57:35 submitting the initial order 00:57:35 Strategy "OrdersHistoryTest" is started at 2010-09-16 00:57:35.104 GMT on the local computer 00:57:35 Starting "OrdersHistoryTest" strategy at 2010-09-16 00:57:35.094 GMT on the local computer now it shows the time of first order, and the third time that I ran it the output is 01:08:09 Strategy "OrdersHistoryTest" is stopped at 2010-09-16 01:08:09.012 GMT on the local computer 01:08:09 Stopping "OrdersHistoryTest" strategy at 2010-09-16 01:08:09.009 GMT on the local computer 01:08:09 order history: [Fill time: 2010-09-16 00:50:29, order command: BUY, amount: 10000.0, fill price 1.2993, Fill time: 2010-09-16 00:50:29, order command: BUY, amount: 10000.0, fill price 1.2993, Fill time: 2010-09-16 00:57:40, order command: BUY, amount: 10000.0, fill price 1.29935, Fill time: 2010-09-16 00:57:40, order command: BUY, amount: 10000.0, fill price 1.29935] 01:08:09 to: Thu Sep 16 03:08:09 CEST 2010 01:08:09 from: Wed Sep 15 03:08:09 CEST 2010 01:08:09 eurusd_order order closed successfully, printing order history 01:08:14 Order FILLED at 1.2989 USD (#49623570 SELL 0.01 mil. EUR/USD @ MKT MAX SLIPPAGE 0.0005) - Position #10248075 01:08:08 order filled successfully: eurusd_order 01:08:13 Order FILLED at 1.299 USD (#49623569 BUY 0.01 mil. EUR/USD @ MKT MAX SLIPPAGE 0.0005) - Position #10248075 01:08:08 submitting the initial order 01:08:08 Strategy "OrdersHistoryTest" is started at 2010-09-16 01:08:08.230 GMT on the local computer 01:08:08 Starting "OrdersHistoryTest" strategy at 2010-09-16 01:08:08.207 GMT on the local computer it shows again the first order; in "Portfolio/Trade Log" I can see 6 orders (3 buy and 3 sell) created by strategy. Best regards, Frank
|
|
|
|
 |
API Support
|
Post subject: Re: orders history |
Post rating: 0
|
Posted: Thu 16 Sep, 2010, 07:46
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
Hi, Thank you for the information, we will investigate the issue.
|
|
|
|
 |
|
Pages: [
1
]
|
|
|
|
|