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.

Orders Cancellation in backtesting due to no liqidity
 Post subject: Orders Cancellation in backtesting due to no liqidity Post rating: 0   New post Posted: Wed 20 Jun, 2012, 20:39 
User avatar

User rating: 0
Joined: Wed 20 Jun, 2012, 19:59
Posts: 2
Location: Egypt, Alexandria
Hello,

I've been back testing a strategy on historical data using a live account , the historical data ranges from Jan-2008 till jan-2012 on currency pairs like AUD/USD GBP/JPY and i get an error telling me that the order is cancelled because of no liquidity at the price

I tried to manipulate the slippage up to 20 pips (I don't think it would be practical to try to increase slippage more than 20 it would really hurt the final strategy outcome) .but still get the error i also tried to decrease the lot size down to 0.001 and still get the same error on approximately 7 trades per year of testing on average noting that this error appears only on the sell side

Note: The type of the order submitted by the strategy is a sell limit order

Here is an example from the report generated by the historical tester:

2008-08-25 04:00:00 Order canceled AUD/USD, SELL, 300000.0 at 0.8633] canceled because of no liquidity at the price

2009-05-13 16:00:00 Order canceled AUD/USD, SELL, 30000.0 at 0.7581] canceled because of no liquidity at the price

Please help on this error

Thanks


 
 Post subject: Re: Orders Cancellation in backtesting due to no liqidity Post rating: 0   New post Posted: Thu 21 Jun, 2012, 09:25 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
We could not replicate this by the case that you described. We used the following strategy for testing:
package jforex.test.markethours;

import com.dukascopy.api.*;
import com.dukascopy.api.IEngine.OrderCommand;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.TimeZone;

/**
 * The strategy creates a single order at the given time point
 */
public class TradeMarketHoursSdf implements IStrategy {
   
    private IConsole console;
    private IEngine engine;
   
    private Period period = Period.ONE_HOUR;
    private Instrument instrument = Instrument.AUDUSD;
   
    private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    private String timeStr = "2008-08-25 04:00:00";
   
    @Override
    public void onStart(IContext context) throws JFException {
        console = context.getConsole();
        engine = context.getEngine();
        sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
    }
   
    private boolean timesEqual(String timeString, long barEndtime) throws JFException { 
        boolean result = false;
        try {
            long time = sdf.parse(timeString).getTime();           
            result = time == barEndtime;           
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return result;
    }
   
    @Override
    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
        if (period != this.period || instrument != this.instrument)
            return;

        if(this.timesEqual(timeStr, askBar.getTime() + period.getInterval())){
            engine.submitOrder("orderSellLimit", instrument, OrderCommand.SELLLIMIT, 0.3, 0.8633, 20);
        }
    }

    private void print(Object o) {
        console.getOut().println(o);
    }

    @Override
    public void onTick(Instrument instrument, ITick tick) throws JFException {    }
    @Override
    public void onMessage(IMessage message) throws JFException {
        print(sdf.format(message.getCreationTime())+ ": " +message);
    }
    @Override
    public void onAccount(IAccount account) throws JFException {    }
    @Override
    public void onStop() throws JFException {    }

}


Attachment:
TradeMarketHoursSdf.java [2.08 KiB]
Downloaded 307 times


With the following Historical Tester settings:

Image

And we received the following report data:
Time   Event type   Event text
2008-08-25 04:00:00   Order submitted   Order [orderSellLimit, AUD/USD, SELLLIMIT, 300000.0 at 0.8633] submitted by the strategy
2008-08-25 05:04:13   Order filled   Order [orderSellLimit, AUD/USD, SELL, 300000.0 at 0.8633] filled
2008-08-25 21:00:00   Commissions   Commissions [4.66]
2008-08-25 21:00:00   Overnights   Overnight commission [-1.12] pips applied to order [orderSellLimit, AUD/USD, SELL, 300000.0]
2008-08-26 21:00:00   Commissions   Commissions [0.0]
2008-08-26 21:00:00   Overnights   Overnight commission [-1.12] pips applied to order [orderSellLimit, AUD/USD, SELL, 300000.0]


Attachments:
Historical_tester_TradeMarketHoursSdf.png [25.03 KiB]
Downloaded 451 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.
 
 Post subject: Re: Orders Cancellation in backtesting due to no liqidity Post rating: 0   New post Posted: Thu 21 Jun, 2012, 15:22 
User avatar

User rating: 0
Joined: Wed 20 Jun, 2012, 19:59
Posts: 2
Location: Egypt, Alexandria
Dear Support Team,

Thanks a lot for your help, after viewing the code you sent, it is now clear that there was a problem with the order parameters in my strategy, the problem is now resolved and the error is not appearing any more.

Thanks again

Regards


 

Jump to:  

  © 1998-2025 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