MarketData.GetSymbol overload for separate currencies.
MarketData.GetSymbol overload for separate currencies.
03 Jan 2019, 13:53
Hello again.
Currently, "MarketData.GetSymbol" only accepts one parameter, the symbol code. It implies that our code knows the precedence order of one currency over the other.
I would like to have an overload method for passing two parameters, like so:
MarketData.GetSymbol("EUR", "USD"); // Symbol EURUSD MarketData.GetSymbol("USD", "EUR"); // Symbol EURUSD
Kind regards.
Replies
oliveira.phc
03 Jan 2019, 14:45
RE:
Panagiotis Charalampous said:
Hi oliveira.phc,
Thank you for your suggestion. Can you describe to us a use case for this? Symbol names are standard amongst almost all brokers. Also the order of the symbols is significant since it determines the price e.g. EURUSD is EUR/USD = 1.13. if it was USD/EUR it would be 0.88.
Best Regards,
Panagiotis
Thanks for your readiness.
You see, for determining the volume of an order, I would like to use some percentage of my free margin. My current code works well for FOREX because my account is in euros, and the Euro takes precedence over all other currencies.
private double _volume { get { double volumeInUnits = (Quantity * Account.FreeMargin * Account.PreciseLeverage) / 100; string thisCurrency = Account.Currency; string baseCurrency = Symbol.Code.Substring(0, 3); if (thisCurrency != baseCurrency) { string code = string.Concat(thisCurrency, baseCurrency); Symbol symbol = MarketData.GetSymbol(code); volumeInUnits = volumeInUnits * symbol.Ask; } return Symbol.NormalizeVolumeInUnits(volumeInUnits); } }
Should I use another account in dollars, it wouldn't work.
@oliveira.phc
PanagiotisCharalampous
03 Jan 2019, 15:01
Hi oliveira.phc,
You can solve your problem by checking both combinations. If the one returns null then you can reverse the strings and check again.
Best Regards,
Panagiotis
@PanagiotisCharalampous
oliveira.phc
03 Jan 2019, 15:02
RE:
Panagiotis Charalampous said:
Hi oliveira.phc,
You can solve your problem by checking both combinations. If the one returns null then you can reverse the strings and check again.
Best Regards,
Panagiotis
Alright, then.
@oliveira.phc
PanagiotisCharalampous
03 Jan 2019, 14:35
Hi oliveira.phc,
Thank you for your suggestion. Can you describe to us a use case for this? Symbol names are standard amongst almost all brokers. Also the order of the symbols is significant since it determines the price e.g. EURUSD is EUR/USD = 1.13. if it was USD/EUR it would be 0.88.
Best Regards,
Panagiotis
@PanagiotisCharalampous