Order execution errors

All posts which do not fit into any other sections of the forum.

Moderator: admin

Order execution errors

Postby Loggy48 » Tue Dec 13, 2016 8:57 am

Is there a way to get an order execution error number when a fault occurs?

A comprehensive list is available at http://www.fxcodebase.com/documents/Ind ... rrors.html but the message that is returned is a text message and in general this will stop a strategy rather than allowing the strategy to parse the error.

For example if a limit entry order is placed that is too close to the current value (or the wrong side), you get the message "The value of the rate is incorrect. It must be a number < than 1.12345" or whatever.

I have checked the returns from

Code: Select all
success, message = terminal:execute(OPEN_REQUEST, valuemap)


which would be the sensible place but there are only the two variables populated - the boolean success and text message. There are no further parameters to AsyncOperationFinished after message2.

It would be useful to know that this is error 20105 and what the max or min value is because the price may have changed while the order was being prepared.

Any ideas?
Loggy48
 
Posts: 89
Joined: Tue Jun 24, 2014 8:39 am
Location: Manchester, UK

Re: Order execution errors

Postby Loggy48 » Wed Dec 14, 2016 11:50 am

The reson for asking this is that I am trying to code a conditional trading strategy that will enter a trade if the price is (for long) below a certain level. This level can be above or below the current level. In theory a limit entry order (LE) should do this because the order is allowed to wait until the conditions are satisfied but if the current level is above the requested rate, it faults and stops the strategy completely. I want to trap that eventuality.

So I tried a range order (OR) where you specify a maximum and minimum price, setting the minimum well below the current price.

Where (for long) the maximum is greater than the current value (and the minimum less), a position is opened immediately as expected and at the current price.

But where the maximum price is less than the current price, it still appears to be treated as open at the current price - ie open at market. At least I would have expected the range order to fail if the conditions are not satisfied and give some message to this effect. Ideally it should behave like a limit order.

Sometimes the market moves quite rapidly and it is possible for the entry price achieved not to reflect the price when the decision was taken to trade. This may be quite a rare occurrence but I don't want the strategy to stop because of an error that I shold be able to trap and I don't want to enter at current market level unless I want it to.

Is there a simple way round this?
Loggy48
 
Posts: 89
Joined: Tue Jun 24, 2014 8:39 am
Location: Manchester, UK

Re: Order execution errors

Postby Loggy48 » Fri Dec 16, 2016 12:17 pm

I think I've found the solution.

Assuming a long trade, set the Side field of the valuemap as 1 (-1 for short). This stops the strategy failing, the most important issue.

The maximum level for limit entry is then 0.1 pip below the current price.

Where I want a positve limit (ie to enter a trade as long as the level is not greater than a current level plus a pip or two) I needed to splice in a range order (Type OR), minimum level 0.0 pips, max level (say) 2.0 pips (again assuming a long trade).

For a range order above or equal to the current price, the success parameter from executing the order tells me whether the corresponding trade has worked. If it fails, try a limit entry with level 0.1 pips. If the range order has failed because the price was too high then the entry limit order will also fail.

And vice versa for short of course.

:D
Loggy48
 
Posts: 89
Joined: Tue Jun 24, 2014 8:39 am
Location: Manchester, UK


Return to General Discussions

Who is online

Users browsing this forum: No registered users and 5 guests