Dukascopy Support Board
http://www.dukascopy.com/swiss/english/forex/jforex/forum/

Executing Time of submitOrder Method Is Unstable?
http://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?f=65&t=52210
Page 1 of 1

Author:  davydai [ Sat 31 Jan, 2015, 06:26 ]
Post subject:  Executing Time of submitOrder Method Is Unstable?

Hello API Supporter:

The submitOrder Method is usually executed within 2 ms, but executing time is very long sometimes.

Trading Log from my automated Strategy in CloudForex VPS as follows:

2015.01.07 19:00:05.409;TraderLogic;OpenPosition; with 1,756,295 us :shock:
2015.01.09 00:33:58.160;TraderLogic;OpenPosition; with 509,811 us
2015.01.13 08:30:02.897;TraderLogic;OpenPosition; with 362,553 us
2015.01.15 00:30:01.587;TraderLogic;OpenPosition; with 922,032 us
2015.01.15 00:30:14.920;TraderLogic;OpenPosition; with 107,612 us
2015.01.26 09:00:15.898;TraderLogic;OpenPosition; with 1,163,791 us :shock:
2015.01.26 15:59:50.379;TraderLogic;OpenPosition; with 125,369 us
2015.01.28 20:00:09.131;TraderLogic;OpenPosition; with 564,929 us
2015.01.29 10:01:58.405;TraderLogic;OpenPosition; with 1,557,137 us :shock:

Thank you!

Author:  tcsabina [ Mon 02 Feb, 2015, 13:04 ]
Post subject:  Re: Executing Time of submitOrder Method Is Unstable?

I am pretty sure this log print is useless to identify the problem.
So please give details about the execution.

The best would be to attach a strategy that replicates the case, so it can be tested in other environments...

Author:  davydai [ Tue 03 Feb, 2015, 15:23 ]
Post subject:  Re: Executing Time of submitOrder Method Is Unstable?

The new positions were opened by Method as follows. It just called a submitOrder Method.

private void Block_OpenPosition( double OrderSN, double Amounts, double OpenPrice, double SLPrice, double Command, Instrument instrument, Date time, int inx)
{
//String offerside = Utility_GetInstrumentName( instrument);
@SuppressWarnings("unused")
IOrder order;
OrderCommand orderCMD = null;

double ratio = instrument.getPipValue();
int ratio1 = ( int)( 1 / ratio);
double FloatOpenPrice = OpenPrice / this.m_jnaMarketDepth[ inx].P_PriceRatio;
double FixedOpenPrice = Math.floor( OpenPrice / this.m_jnaMarketDepth[ inx].P_PriceRatio * ratio1) / ratio1;
double FixedSLPrice = Math.floor( SLPrice / this.m_jnaMarketDepth[ inx].P_PriceRatio * ratio1) / ratio1;
Amounts = Math.floor( Amounts);
double edgePrice = 0;
if ( Command > 0){
orderCMD = IEngine.OrderCommand.BUYLIMIT;
edgePrice = m_jnaMarketDepth[ inx].AskMax / this.m_jnaMarketDepth[ inx].P_PriceRatio;
if ( FixedOpenPrice < FloatOpenPrice)
FixedOpenPrice += ratio;
}
else{
orderCMD = IEngine.OrderCommand.SELLLIMIT;
edgePrice = m_jnaMarketDepth[ inx].BidMin / this.m_jnaMarketDepth[ inx].P_PriceRatio;
if ( FixedOpenPrice > FloatOpenPrice)
FixedOpenPrice -= ratio;
}

String instrName = Utility_GetInstrumentName( instrument);
String OrderLabel = instrName + "_" + String.format( "%.0f", OrderSN);
try{
long startTime = System.nanoTime();
order = m_Engine.submitOrder(
//offerside + String.valueOf( m_CurOrderNum), // label
OrderLabel, // label
instrument, // instrument
orderCMD,
Amounts * 1.0e-6, // amount
FixedOpenPrice, // price
0, // slippage
FixedSLPrice,
0, // takeprofitprice
time.getTime() + TimeUnit.SECONDS.toMillis( 60)
);
long stopTime = System.nanoTime();
this.m_LogPrintWriter.println( gDateFormatYMDHMS.format( time) + ";TraderLogic;OpenPosition;Order Parameters;" + OrderLabel +
String.format( " Command % .0f", Command) + " Equity-" + m_History.getEquity() + String.format( " Amount-%.0f", Amounts) +
String.format( " OpenPrice-%.5f", FixedOpenPrice) + String.format( " EdgePrice-%.5f", edgePrice) +
String.format( " SLPrice-%.4f", FixedSLPrice) + String.format( " with %d us", ( stopTime - startTime) / 1000));
}
catch( JFException e){
this.m_LogPrintWriter.println( gDateFormatYMDHMS.format( time) + ";TraderLogic;MakeAnOrderByFreeMargin;submitOrder() JFException;" + e.getMessage());
}
//this.m_LogPrintWriter.flush();
}

Author:  API Support [ Wed 04 Feb, 2015, 09:05 ]
Post subject:  Re: Executing Time of submitOrder Method Is Unstable?

Hi davydai!

There is no guarantee that any API method will be executed in constant time as there is such things in Java as JIT compilation, Garbage collection, Thread Scheduler and so on.

Author:  davydai [ Thu 05 Feb, 2015, 02:56 ]
Post subject:  Re: Executing Time of submitOrder Method Is Unstable?

Thank you!

Author:  SimonS [ Tue 24 Feb, 2015, 15:07 ]
Post subject:  Re: Executing Time of submitOrder Method Is Unstable?

I have encountered similar problems.
See my thread:
https://www.dukascopy.com/swiss/english ... 65&t=52327

This delay is caused by remoted JForex servers' reponse's delay, not the client code in our side.
I have tracked the GC calls in client side, there is no GC happened when dalay occurs.

We need your professional help for this issue.

Thanks.

Author:  davydai [ Mon 25 May, 2015, 16:59 ]
Post subject:  Re: Executing Time of submitOrder Method Is Unstable?

I check the program again, it's caused by CPU 50% Load Limit of Cloud Forex Casual VPS.

  Page 1 of 1