private static string TryGetPrimaryExch(IBInstrumentData instrumentData) { var exchange = instrumentData.ExchangeCode; switch (exchange) { case "NYSE_ARCA": return("ARCA"); case "NYSE_MKT": return("AMEX"); case "NCM": case "NGM": case "NGSM": case "NSDQ": return("NASDAQ"); case "NYSE": return("NYSE"); default: return(null); } }
public static Contract GetAssetContractStub(IBInstrumentData instrumentData) { // Мы ожидаем, что внешний конвертер сформирует код в формате LOCALSYMBOL var symbol = instrumentData.Symbol; GetCustomSymbolAndExchangeCode(instrumentData, SMART, ref symbol, out string exchangeCode); var contract = new Contract { Exchange = exchangeCode, LocalSymbol = symbol, PrimaryExch = TryGetPrimaryExch(instrumentData) }; switch (instrumentData.InstrumentType) { case IBInstrumentType.Index: contract.SecType = "IND"; break; case IBInstrumentType.FX: contract.SecType = "CASH"; break; default: contract.SecType = "STK"; break; } return(contract); }
/// <summary> /// Если узел принадлежит пользовательской (созданной руками) бирже, метод возвращает её код. /// Для бирж из символ-сервиса возвращается <paramref name="defaultExchange"/>. /// </summary> private static void GetCustomSymbolAndExchangeCode([CanBeNull] IBInstrumentData instrumentData, string defaultExchange, ref string symbol, [NotNull] out string exchangeCode) { var match = _SymbolRegex.Match(symbol); // Если площадка явно указана в символе if (match.Success) { symbol = match.Groups["symbol"].Value; exchangeCode = match.Groups["exchange"].Value; if (!string.IsNullOrEmpty(exchangeCode)) { return; } } if (instrumentData == null) { exchangeCode = defaultExchange; return; } exchangeCode = instrumentData?.ExchangeCode ?? defaultExchange; // Хардкод для CBOT if (exchangeCode == "CBT") { exchangeCode = "ECBOT"; return; } if (exchangeCode == "HKEX") { exchangeCode = "HKFE"; return; } switch (instrumentData.InstrumentType) { case IBInstrumentType.Equity: // Для акций exchangeCode = defaultExchange; break; case IBInstrumentType.AssetOption: case IBInstrumentType.FutureOption: case IBInstrumentType.Future: // Для опционов и фьючерсов не CBOT exchangeCode = defaultExchange; break; } }
public static Contract GetFutureOptionContractStub(IBInstrumentData instrumentData) { // Мы ожидаем, что внешний конвертер сформирует код в формате LOCALSYMBOL var symbol = instrumentData.Symbol; GetCustomSymbolAndExchangeCode(instrumentData, GLOBEX, ref symbol, out string exchangeCode); var contract = new Contract { Exchange = exchangeCode, LocalSymbol = symbol, SecType = "FOP" }; return(contract); }
private static Contract GetContractStub(IBInstrumentData instrumentData) { switch (instrumentData.InstrumentType) { case IBInstrumentType.Equity: case IBInstrumentType.Commodity: case IBInstrumentType.Index: case IBInstrumentType.FX: return(GetAssetContractStub(instrumentData)); case IBInstrumentType.Future: return(GetFutureContractStub(instrumentData)); case IBInstrumentType.FutureOption: return(GetFutureOptionContractStub(instrumentData)); case IBInstrumentType.AssetOption: return(GetAssetOptionContractStub(instrumentData)); default: throw new ArgumentOutOfRangeException(); } }