Jump to content
garrettkolson

GetMarketInformation - MinDistance

Recommended Posts

Hi there,

Right now, I'm calling /market/{marketId}/information only once at the beginning of my session for different market info, particularly the MinDistance property for the market. However, I'm still getting a lot of Red Cards due to being under the minimum distance to the target.

So, I guess I have two questions:

1. Is that something I should be calling periodically to get the latest MinDistance? Does the MinDistance for a market change throughout the day, or is that pretty static?

2. Which price is the MinDistance relevant to? I would assume, for a buy stop order, that the MinDistance would be from the Offer Price, and for a sell stop, it would be from the Bid Price. Is that correct?

Thanks!

Share this post


Link to post

Hello Garrett,

1) MinDistance rarely changes and is pretty static, so calling it once at the beginning of the session is fine for most cases. Only under exceptionally unusual market conditions is there a chance that the MinDistance might be changed. For example, a few weeks ago, some index markets were making record point moves in a day might have been one time they could have changed. But otherwise they usually stay the same.

2) It would be easiest to explain with example numbers. Say we have a market currently quoting as 98/100 and it has a 5 point MinDistance. 

Orders must always be outside the market spread. This means:

Buy Trade: Stops must be below the Sell price (98), and Limits must be above the Buy price (100).

Sell Trade: Stops must be above the Buy price (100), and Limits must be below the Sell price (98). 

Therefore, if we buy at 100, the stop must be below 93. Similarly, if you sell at 98, the stop must be above 103. 

Does the above help?

Kind Regards, PM

Share this post


Link to post

Thanks for your answers, PM.

1. Awesome, I was hoping that was the case.

2. However, that leads me to a follow-up question related to #2. In my case, since I'm a US client, I'm trying to place orders to buy or sell at a worse price than current (so, stop order), with no attached IfDone. I attach the related stop loss and take profit orders once the first order has become an open position (if it does).

However, I'm getting the "Minimum Distance to Target" red card upon trying to place the initial non-attached stop order, even though I've specified my trigger as more than the MinDistance from the Offer/Bid.

So, for example, I tried to place a sell stop on USD/JPY. The Bid Price I received from Lightstreamer was 107.413, so my TriggerPrice was set to 107.398 (distance of .015). The MinDistance for USD/JPY is listed as .014, but I still got red carded for being below minimum distance to target.

Do you know what I'm doing wrong?

Thanks, 

Garrett

Share this post


Link to post

Hi Garrett,

Assuming that the correct call is being sent - it should look something similar to the following screenshot of a successful test call I made just now.

I suspect strongly the reason you are reciving the error message is that the market price moved within the MinDistance of your order price by the time your order was sent to our servers. Since I'm testing manually, I had to try 7-8 times before I could time it fast enough and click the Send button before the market price moved within 15 of the order price.

To check that you can successfully place an entry order in a market, try a order price say 20 - 25 away. Then if you are successful, you could look into fully automating the process of reading in the current market price, setting your entry order price and sending it. An automated process is likely to be fast enough when compared to doing this manually!

Note that even with a fully  automated process you could still receive some rejections if the market is very volatile and moving rapidly.

Kind Regards, PM

image.png

 

Share this post


Link to post

Hi PM,

After some more testing today, I suspect you are correct - I have placed a few successful orders with wider TriggerPrice targets.

I actually do have this process automated. My code that places orders receives the latest prices from Lightstreamer just before calling /order/newstoplimitorder. However, when dealing with distances that small, it seems likely that the market will occasionally move within your target distance.

I've built in a few other checks for this eventuality, as well as some TriggerPrice modifications and retries, should the first order attempt fail for that reason.

Thank you again for all your help!

Garrett

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×