Jump to content
Sign in to follow this  
Guest sky.sanders

Definition of Magic Strings and Numbers

Recommended Posts

Guest sky.sanders

Consider

GetPriceBars(string marketId, string interval, int span, string priceBars)

The demo value for interval is MINUTES.

Where would one find a complete explanation of the acceptable values for this parameter?

We run into the same issue in various request and response DTO, both as strings and as numbers (typically in Status related fields).

These types of fields, in a perfect world, would be implemented as Enum, which would serve to strongly type the value ergo pre-validation, as well as providing a self documenting API.

I realize that a change like this may not happen any time soon, if at all, but it is something to consider.

But back to the question at hand – We do need a full list of these ‘magic’ parameter and property values. Where can we find this and how will the API team ensure that this information is kept up-to-date?

Share this post


Link to post

You can make a request to the message lookup service, this will give you the message for the trade and order status codes:

/message/lookup?lookupEntityName=OrderStatusReason&CultureId=69 /message/lookup?lookupEntityName=InstructionStatusReason&CultureId=69

In the C# client api you can call GetMessageLookup(“OrderStatusReason”, 69).

Again, 69 is another magic number. We’re currently in the process of removing the cultureId from the call.

Share this post


Link to post

The possible interval types are TICK,MINUTE,HOUR,DAY and WEEK. Certain interval/span combinations are allowed (1,2,3,5,10,15 & 30 MINUTE) and (1,2,4,8 HOUR). TICK, DAY and WEEK must be supplied with a span of 1.

Any other combinations will be refused and the client will receive a response with the appropriate error. I should add that these might well change in the future.

Ideally the documentation site would be used to contain this information, in it’s most up to date form, but it needs some work in it’s current state to provide this information.

Share this post


Link to post

Consider

GetPriceBars(string marketId, string interval, int span, string priceBars)

The demo value for interval is MINUTES.

Where would one find a complete explanation of the acceptable values for this parameter?

We run into the same issue in various request and response DTO, both as strings and as numbers (typically in Status related fields).

These types of fields, in a perfect world, would be implemented as Enum, which would serve to strongly type the value ergo pre-validation, as well as providing a self documenting API.

I realize that a change like this may not happen any time soon, if at all, but it is something to consider.

But back to the question at hand – We do need a full list of these ‘magic’ parameter and property values. Where can we find this and how will the API team ensure that this information is kept up-to-date?

The “magic numbers”, or Ids that we use for localisation can change (get added to, or text rewritten etc). This is why it might not be a good idea to have a static enumeration, because it could get out of date. The recommended way is to call the GetMessageLookup API and get the text in the appropriate language for the user. If it’s for helping to write the client application code, then why not create a static enum in the client library for the Ids you use frequently?

Share this post


Link to post
Guest sky.sanders

You can make a request to the message lookup service, this will give you the message for the trade and order status codes:

/message/lookup?lookupEntityName=OrderStatusReason&CultureId=69 /message/lookup?lookupEntityName=InstructionStatusReason&CultureId=69

In the C# client api you can call GetMessageLookup(“OrderStatusReason”, 69).

Again, 69 is another magic number. We’re currently in the process of removing the cultureId from the call.

Craig, we need to get the ‘reason’ keys documented on the DTO. e.g. “The order status code. To resolve this code call GetMessageLookup(“OrderStatusReason”, 69)”

Share this post


Link to post
Guest andreif

The possible interval types are TICK,MINUTE,HOUR,DAY and WEEK. Certain interval/span combinations are allowed (1,2,3,5,10,15 & 30 MINUTE) and (1,2,4,8 HOUR). TICK, DAY and WEEK must be supplied with a span of 1.

Any other combinations will be refused and the client will receive a response with the appropriate error. I should add that these might well change in the future.

Ideally the documentation site would be used to contain this information, in it’s most up to date form, but it needs some work in it’s current state to provide this information.

Is it possible to get explanations for response codes of trade() and order() methods? Currently, they return only some magic numerical codes, so I can’t understand what is wrong when my request fails

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
Sign in to follow this  
×