public IgEpicModel GetEpic(IgSessionModel igSession, string epic) { string action = $"/markets/{epic}"; string json = igHttpClient.Get(igSession, action, 1); IgEpicModel result = JsonConvert.DeserializeObject <IgEpicModel>(json); return(result); }
private static int Order(OrderOptions options) { SwitchAccount(options.Account); IgOrderModel igOrder = new IgOrderModel { epic = options.Epic, size = options.PositionSize, currencyCode = "GBP", level = options.Level, limitDistance = options.LimitDistance, stopDistance = options.StopDistance, direction = options.Direction.ToUpper(), dealReference = $"NMCQReference{1}", expiry = options.Expiry }; IgMarkets igMarkets = new IgMarkets(); IgEpicModel epic = igMarkets.GetEpic(session, options.Epic); Console.WriteLine($"Market Code {epic.instrument.newsCode} {epic.instrument.marketId} {epic.instrument.chartCode} Bid: {epic.snapshot.bid}"); PlaceOrder(igOrder); return(0); }
public MarketSearchModel Get(IgSessionModel igSession, string term, bool getDetail) { string action = "/markets?searchTerm=" + term; string json = igHttpClient.Get(igSession, action, 1); MarketSearchModel result = JsonConvert.DeserializeObject <MarketSearchModel>(json); if (result.Markets != null && getDetail) { foreach (var market in result.Markets) { string ticker = string.Empty; if (!IgEpicMapper.TryLookupCode(market.Epic, out ticker)) { IgEpicModel epicModel = GetEpic(igSession, market.Epic); if (!string.IsNullOrWhiteSpace(epicModel.instrument.chartCode)) { if (epicModel.instrument.country != "US") { if (epicModel.instrument.country == "GB") { epicModel.instrument.country = "LON"; } epicModel.instrument.chartCode += "." + epicModel.instrument.country; } IgEpicMapper.AddCode(market.Epic, epicModel.instrument.chartCode); ticker = epicModel.instrument.chartCode; } } market.Ticker = ticker; Console.WriteLine($"{market.Ticker} {market.InstrumentName}"); } } return(result); }