|
Remote Execution Strategy Error |
carlosfx
|
Post subject: Remote Execution Strategy Error |
Post rating: 0
|
Posted: Mon 14 Oct, 2013, 10:53
|
|
User rating: 0
Joined: Thu 30 Jun, 2011, 20:11 Posts: 41 Location: Spain,
|
Hi,
Since last week I was using an strategy through remote execution, but it is not working any more. With local execution it works, but on remote execution I get plenty of errors. Did something change recently? Could you please help me?
Thanks
|
|
|
|
|
tcsabina
|
Post subject: Re: Remote Execution Strategy Error |
Post rating: 0
|
Posted: Mon 14 Oct, 2013, 14:02
|
|
User rating: 164
Joined: Mon 08 Oct, 2012, 10:35 Posts: 676 Location: NetherlandsNetherlands
|
Hi,
Even if Support is aware of what was change (if there was any), please also mention the errors that are occurring now. As without it it is just shooting in the dark...
|
|
|
|
|
carlosfx
|
Post subject: Re: Remote Execution Strategy Error |
Post rating: 0
|
Posted: Mon 14 Oct, 2013, 21:30
|
|
User rating: 0
Joined: Thu 30 Jun, 2011, 20:11 Posts: 41 Location: Spain,
|
As it was working and I didnt do any change on the strategy, and moreover it is still running locally, I think something has changed somewhere else... It seems the instrument are suddenly not suscribed, but I see many other errors which I dont understand. I attach an screenshot. Thanks
Attachments: |
remote strategy error.png [100.25 KiB]
Downloaded 697 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.
|
|
|
|
|
|
tcsabina
|
Post subject: Re: Remote Execution Strategy Error |
Post rating: 1
|
Posted: Tue 15 Oct, 2013, 09:59
|
|
User rating: 164
Joined: Mon 08 Oct, 2012, 10:35 Posts: 676 Location: NetherlandsNetherlands
|
Hi, Yes, it was changed. You have to subscribe to instruments from now on. Take a look on this topic, which gives you some tips what to do.
|
|
|
|
|
carlosfx
|
Post subject: Re: Remote Execution Strategy Error |
Post rating: 0
|
Posted: Tue 15 Oct, 2013, 18:58
|
|
User rating: 0
Joined: Thu 30 Jun, 2011, 20:11 Posts: 41 Location: Spain,
|
Thanks a lot for your help
|
|
|
|
|
hyperscalper
|
Post subject: Re: Remote Execution Strategy Error |
Post rating: 1
|
Posted: Thu 17 Oct, 2013, 03:47
|
|
User rating: 98
Joined: Mon 23 Jul, 2012, 02:02 Posts: 656 Location: United States, Durham, NC
|
Yes, you MUST subscribe to the instruments you need. This change was made, in part, in response to performance concerns which I noted. Dukascopy engineers realized that the old "auto-subscribe" behavior was not consistent with good performance. Now, you just have to do what you have to do on Demo. Explicitly subscribe to Instruments which you want to handle. In fact, performance is now very much better than it was before this welcome change was made HyperScalper It's done like this: final Set<Instrument> subscribedInstruments = new HashSet<Instrument>(); // subscribed
@Configurable("Select Instrument") public Instrument selectedInstrument = Instrument.EURUSD;
// now, in onStart
subscribedInstruments.clear(); // not necessary subscribedInstruments.add(selectedInstrument); // just a single instrument, could be more context.setSubscribedInstruments(subscribedInstruments); // subscribe
|
|
|
|
|
carlosfx
|
Post subject: Re: Remote Execution Strategy Error |
Post rating: 0
|
Posted: Thu 17 Oct, 2013, 09:42
|
|
User rating: 0
Joined: Thu 30 Jun, 2011, 20:11 Posts: 41 Location: Spain,
|
Thanks, for your help.
I have done it and it is working. But I'm experiencing a problem. My strategy mainly works to control the positions, is like a complex trailing stop. I use a loop which runs through the orders and decides whether to move the stop or not. Before the change was made it was working ok. Now it works with the positions opened after starting the strategy, but if the strategy stops and I restart it, it doesnt recognize the positions which already exist, although those instrument are suscribed on OnStart. If I run the strategy locally it does recognize those positions, so I guess it has to do with the change made.
Any idea?
Thx
|
|
|
|
|
API Support
|
Post subject: Re: Remote Execution Strategy Error |
Post rating: 0
|
Posted: Thu 17 Oct, 2013, 10:39
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
Please provide an example strategy which replicates what you have just described. Do you use a standard (i.e. hedged) or a global account?
|
|
|
|
|
carlosfx
|
Post subject: Re: Remote Execution Strategy Error |
Post rating: 0
|
Posted: Thu 17 Oct, 2013, 10:55
|
|
User rating: 0
Joined: Thu 30 Jun, 2011, 20:11 Posts: 41 Location: Spain,
|
public void OrdersData() throws JFException { for (IOrder order : engine.getOrders()) { if (order.getState() == IOrder.State.FILLED) { double tp = order.getTakeProfitPrice(); Instrument par = order.getInstrument(); double entrada = order.getOpenPrice(); double stop =order.getStopLossPrice(); double carga = order.getAmount(); print ("Instrument:"+par+" tp:" + tp+" sloss:"+stop+" carga:"+carga); }
}
}
So, if the position is already open at the moment when I launch the strategy it doesn't print anything. If I open the position after launching the strategy it works. If I run the strategy locally, it works anyway. I use a normal Demo Account at the moment, but I will use this strategy on my live account as soon as I have confidence with it.
|
|
|
|
|
API Support
|
Post subject: Re: Remote Execution Strategy Error |
Post rating: 0
|
Posted: Thu 17 Oct, 2013, 11:34
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
please provide a full example strategy which replicates the case that you described.
|
|
|
|
|
carlosfx
|
Post subject: Re: Remote Execution Strategy Error |
Post rating: 0
|
Posted: Thu 17 Oct, 2013, 12:07
|
|
User rating: 0
Joined: Thu 30 Jun, 2011, 20:11 Posts: 41 Location: Spain,
|
|
|
|
|
hyperscalper
|
Post subject: Re: Remote Execution Strategy Error |
Post rating: 0
|
Posted: Thu 17 Oct, 2013, 20:44
|
|
User rating: 98
Joined: Mon 23 Jul, 2012, 02:02 Posts: 656 Location: United States, Durham, NC
|
First of all, this loop in your code may not terminate if, for some reason the instruments cannot ALL be subscribed. For example, different accounts may be subject to a different set of "subscribable" instruments. Maybe you're just hanging because your Remote Run is in an account has a different set of "subscribables" than your Local Run account. That's my guess. So your code would hang in onStart, potentially forever. You should have an "escape" condition from this loop. Like maybe some tryCount that allows you to escape from this (potentially) infinite wait loop. while (!context.getSubscribedInstruments().containsAll(pares)) { try { Thread.sleep(1000); } catch (InterruptedException ex) { Logger.getLogger(example.class.getName()).log(Level.SEVERE, null, ex); }
Instead, for the subscriptions, just use: context.setSubscribedInstruments(pares); // no wait //// or ... context.setSubscribedInstruments(pares, true); // wait
If you must know that ALL of your instruments were subscribed and you are receiving callbacks from them, you can tally onTick or onBar callbacks later by instrument to verify you're getting market data from all of them. HyperScalper
|
|
|
|
|
carlosfx
|
Post subject: Re: Remote Execution Strategy Error |
Post rating: 0
|
Posted: Thu 17 Oct, 2013, 22:22
|
|
User rating: 0
Joined: Thu 30 Jun, 2011, 20:11 Posts: 41 Location: Spain,
|
Thanks for your help, HyperScalper.
Actually it doesnt hangs on OnStart. The strategy works, if I open a new position it recognizes it, so it is not hanging forever. Anyway, I added this on the onBar part: if (period == Period.TEN_SECS) { print ("par:"+instrument); }
and it prints every ten seconds all the instruments suscribed. So they are suscribed, but the strategy, I dont know why, only detects positions which "are born" after the strategy suscription is done.
Anyway I find useful your help, because I want the strategy to monitor positions which I open manually, and I dont want the strategy to fail because it wasnt able to suscribe to the instrument. I thought that suscribing was a matter of time, but with enough patience it would be able to suscribe to every instrument. Actually I would like that the strategy suscribes to an instrument when it detects that I opened a position with that instrument (it would be the most efficient solution),and it would be quite easy to do from the OnMessage part. But as the strategy only detects events that occur after the suscription of the instruments I'm not able to do it.
ps: I know that my code may not be very professional but I'm learning java on my own only to code the strategy, so any help to improve the code is highly appreciated.
|
|
|
|
|
carlosfx
|
Post subject: Re: Remote Execution Strategy Error |
Post rating: 0
|
Posted: Thu 17 Oct, 2013, 23:15
|
|
User rating: 0
Joined: Thu 30 Jun, 2011, 20:11 Posts: 41 Location: Spain,
|
I made another modification. I deleted all the suscriptions, and put an order on the OnMessage part to print every incoming message related to an order fill_ok. I also kept the line which prints which candles are received (every ten secs) and the line printing information about open positions.
I opened two positions (different instruments) and then I run the strategy.
Result: No prints at all. (Previous opened positions are not seen)
Then I opened a position on a third instrument. Result: I got the message and from that moment I got:
A print every 10 sec. about every one of the three positions. It is like all them are suddenly recognized and suscribed after opening a position on a different instrument.
Info about the position opened when the strategy was already running, but not about the older positions. So, the candles are received but the open positions are not recognized. I think that they are working on the issue, because this behaviour is strange.
Attachments: |
example.java [3.99 KiB]
Downloaded 274 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.
|
|
|
|
|
|
carlosfx
|
Post subject: Re: Remote Execution Strategy Error |
Post rating: 0
|
Posted: Fri 18 Oct, 2013, 10:19
|
|
User rating: 0
Joined: Thu 30 Jun, 2011, 20:11 Posts: 41 Location: Spain,
|
... And I'm trying with context.setSubscribedInstruments(pares, true); and also with false, but it doesnt recognize open positions either. Now I run a loop through the orders at history level: long now=history.getLastTick(Instrument.XAGUSD).getTime(); long begin=history.getStartTimeOfCurrentBar(Instrument.XAGUSD, Period.WEEKLY); List<IOrder> ordenes = history.getOrdersHistory(Instrument.XAGUSD, begin, now); for (IOrder order : ordenes) { print ("orden:"+order.getLabel()+" estado:"+order.getState()); if (order.getState()==IOrder.State.FILLED) { print ("orden:"+order.getLabel()+" carga:"+order.getAmount()+ "ESTADO:"+order.getState()); } } And I get a list of all the orders that are already closed, but the one which is open is not detected. And as soon as I close it, it is detected as closed. It is like open orders doesnt exist till they are closed.
|
|
|
|
|
hyperscalper
|
Post subject: Re: Remote Execution Strategy Error |
Post rating: 1
|
Posted: Fri 18 Oct, 2013, 17:46
|
|
User rating: 98
Joined: Mon 23 Jul, 2012, 02:02 Posts: 656 Location: United States, Durham, NC
|
Here's how I get all open orders, filtered by my "magic" label pattern so they are restricted to a single Strategy instance. I never used the IHistory thing to get my live open positions as you are doing... ? HyperScalper // as a side-effect, calculates PriceBreakEvenGross // called through IContext.executeTask(Callable) from another thread final class GetOpenOrdersTask implements Callable<ArrayList<IOrder>> { Instrument instrument = null; IEngine engine = null; public GetOpenOrdersTask(final IEngine engineArg, final Instrument instrumentArg) { engine = engineArg; instrument = instrumentArg; } public ArrayList<IOrder> call() { double sumPriceWeight = 0; double sumWeight = 0; checkThread(this); IOrder order = null; IOrder.State state = null; ArrayList<IOrder> resultOrders = new ArrayList<IOrder>(); try { List<IOrder> orders = null; orders = engine.getOrders(instrument); // all orders for this instrument if (orders==null) return resultOrders; // empty int ordersSize = orders.size(); // filter by state for (int i=0; i<ordersSize; i++) { order = orders.get(i); if (order!=null && isMyOrder(order)) { // only if it is one of MY orders state = order.getState(); //console.getOut().println("iterate order: "+label); // filter by state if (state.equals(IOrder.State.CLOSED) || state.equals(IOrder.State.CANCELED)) { continue; // ignore } resultOrders.add(order); if (state.equals(IOrder.State.FILLED)) { double size = order.getAmount(); double price = order.getOpenPrice(); sumPriceWeight += (price*size); sumWeight += size; } } } } catch(Exception e) { e.printStackTrace(); } if (sumWeight!=0) { priceBreakEvenGross = (sumPriceWeight/sumWeight); boolean isLong = (globalNetPositionMills>0); if (isLong) { priceBreakEvenNet = priceBreakEvenGross + (breakEvenPips*PIP); } else { priceBreakEvenNet = priceBreakEvenGross - (breakEvenPips*PIP); } //System.out.println("priceBreakEvenGross: "+priceBreakEvenGross); } else { priceBreakEvenGross = 0; priceBreakEvenNet = 0; //System.out.println("priceBreakEvenGross: "+priceBreakEvenGross); } return resultOrders; // null if not found or not open } }
|
|
|
|
|
carlosfx
|
Post subject: Re: Remote Execution Strategy Error |
Post rating: 0
|
Posted: Tue 22 Oct, 2013, 19:08
|
|
User rating: 0
Joined: Thu 30 Jun, 2011, 20:11 Posts: 41 Location: Spain,
|
Hi, HyperScalper I was not able to log in till now... I dont use that IHistory loop. I just use this loop for (IOrder order : engine.getOrders()) { if (order.getState() == IOrder.State.FILLED) { ... }
But as I saw that those already open positions were undetectable I tried to find them somehow, successless. As I said, the strategy (on remote execution) only detects them when they are already closed (unless they are open after starting the strategy). However the strategy works ok on local execution, so I thought that it is a bug. But as Support Team is not answering after sending the full strategy example which replicates the problem (at least I think it does) I dont know what to expect now. PS: I've seen your video about the DOM and it is quite interesting. Thanks for your help, Carlosfx
|
|
|
|
|
|
Pages: [
1
]
|
|
|
|
|