MyTrader is designed to work with FX/CFD platforms, and they have almost no standardisation of market names and IDs across different brokers, or even between accounts with the same broker. MyTrader tries to impose some standardisation of its own: for example, it will try always to give the euro-dollar FX pair the
As a result,
Does your key match an instrument's
For fx markets, does your key match the base currency + quote currency? For example, if you pass in "EURUSD" (and the
Does your key match any common known aliases? For example, is your key "GOLD" which is known to match against an instrument where the ID is "XAU/USD"?
You also need to bear in mind that a market may exist on one account and not on another, as well as having different IDs. As a result, you need to consider the following possibility:
Your widget/script stores the user's current settings, including a choice of market
The user logs in to a different broker account and your widget/script is re-loaded
The market in your saved settings does not exist on the new account
As a result, it is more common to use
Addition of
This potentially stops your code from breaking when the user logs in to an account where your saved settings refer to a market which doesn't exist. Without needing to do an explicit check for missing markets, your code will typically continue relatively gracefully - for example, displaying ? as the market's caption and zero prices.