Dukascopy
 
 
Wiki JStore Search Login

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.

Executing Time of submitOrder Method Is Unstable?
 Post subject: Executing Time of submitOrder Method Is Unstable? Post rating: 0   New post Posted: Sat 31 Jan, 2015, 06:26 
User avatar

User rating: 0
Joined: Wed 07 Nov, 2012, 16:14
Posts: 28
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!


 
 Post subject: Re: Executing Time of submitOrder Method Is Unstable? Post rating: 0   New post Posted: Mon 02 Feb, 2015, 13:04 
User avatar

User rating: 164
Joined: Mon 08 Oct, 2012, 10:35
Posts: 676
Location: NetherlandsNetherlands
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...


 
 Post subject: Re: Executing Time of submitOrder Method Is Unstable? Post rating: 0   New post Posted: Tue 03 Feb, 2015, 15:23 
User avatar

User rating: 0
Joined: Wed 07 Nov, 2012, 16:14
Posts: 28
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();
}


 
 Post subject: Re: Executing Time of submitOrder Method Is Unstable? Post rating: 0   New post Posted: Wed 04 Feb, 2015, 09:05 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
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.


 
 Post subject: Re: Executing Time of submitOrder Method Is Unstable? Post rating: 0   New post Posted: Thu 05 Feb, 2015, 02:56 
User avatar

User rating: 0
Joined: Wed 07 Nov, 2012, 16:14
Posts: 28
Thank you!


 
 Post subject: Re: Executing Time of submitOrder Method Is Unstable? Post rating: 0   New post Posted: Tue 24 Feb, 2015, 15:07 
User avatar

User rating: 0
Joined: Mon 09 Feb, 2015, 13:40
Posts: 11
Location: China,
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.


 
 Post subject: Re: Executing Time of submitOrder Method Is Unstable? Post rating: 0   New post Posted: Mon 25 May, 2015, 16:59 
User avatar

User rating: 0
Joined: Wed 07 Nov, 2012, 16:14
Posts: 28
I check the program again, it's caused by CPU 50% Load Limit of Cloud Forex Casual VPS.


 

Jump to:  

  © 1998-2024 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com