Guest andreif Report post Posted July 21, 2013 How I can get type of the market (CFD or Spread Betting), given it’s market ID? Share this post Link to post
wilsoncg 1 Report post Posted July 25, 2013 Currently we don’t provide the market type on the market information response. This works fine if you use the market search to find a market (the type is contained within the url). However, this causes problems when you use the watchlist to place trades on saved markets. This is something we’re looking at adding to the market information call. Share this post Link to post
Guest mrdavidlaing Report post Posted July 25, 2013 Until this gets added to the market information call, here is a workaround: /// <summary> /// Given a market, figures out which of the available TradingAccounts to use /// TODO - when the API is extended to include market type on the marketInfo object this method can be removed. /// </summary> /// <param name="marketInfo">The market that we want to trade on</param> /// <param name="accountInfo">The account we want to trade with</param> /// <returns></returns> public ApiTradingAccountDTO GetTradingAccountForMarket(ApiMarketInformationDTO marketInfo, AccountInformationResponseDTO accountInfo) { //Check if this is market appears in the CFD search var cfdMarkets = _client.CFDMarkets.ListCfdMarkets(marketInfo.Name, "", accountInfo.ClientAccountId, 50); if ( (cfdMarkets.Markets.Count() > 0 ) && (cfdMarkets.Markets.FirstOrDefault(market => market.MarketId == marketInfo.MarketId)!=null) ) { var tradingAccountForMarket = accountInfo.TradingAccounts.FirstOrDefault(ta => ta.TradingAccountType.ToUpper() == "CFD"); if (tradingAccountForMarket == null) throw new NoTradingAccountForMarketTypeException( string.Format("No trading account can be found that is able to trade on CFD market {0}, MarketId {1}", marketInfo.Name, marketInfo.MarketId)); return tradingAccountForMarket; } //If not, try the spread markets var spreadMarkets = _client.SpreadMarkets.ListSpreadMarkets(marketInfo.Name, "", accountInfo.ClientAccountId, 50); if ((spreadMarkets.Markets.Count() > 0) && (spreadMarkets.Markets.FirstOrDefault(market => market.MarketId == marketInfo.MarketId) != null) ) { var tradingAccountForMarket = accountInfo.TradingAccounts.FirstOrDefault(ta => ta.TradingAccountType.ToUpper().StartsWith("SPREAD")); if (tradingAccountForMarket == null) throw new NoTradingAccountForMarketTypeException( string.Format("No trading account can be found that is able to trade on Spread market {0}, MarketId {1}", marketInfo.Name, marketInfo.MarketId)); return tradingAccountForMarket; } //If we can't find a either a CFD or a Spread market, thrown an exception throw new UnknownMarketException(string.Format("Unable for find either a CFD or Spread market named {0} with MarketId {1}", marketInfo.Name, marketInfo.MarketId)); } Share this post Link to post
Guest sky.sanders Report post Posted August 5, 2013 Currently we don’t provide the market type on the market information response. This works fine if you use the market search to find a market (the type is contained within the url). However, this causes problems when you use the watchlist to place trades on saved markets. This is something we’re looking at adding to the market information call. it would be of value to have market type as a property of PriceDTO as well Share this post Link to post