예제 #1
0
        internal string[] GetUnderlying(OKExInstrumentType instrumentType, CancellationToken token, out string error)
        {
            var responce = this.SendPublicGetRequest <string[][]>($"{this.settings.RestEndpoint}/api/v5/public/underlying?instType={instrumentType.GetEnumMember()}", token);

            error = responce.Message;
            return(responce.Data.FirstOrDefault() ?? new string[0]);
        }
예제 #2
0
        internal OKExSymbol[] GetSymbols(OKExInstrumentType instrumentType, CancellationToken token, out string error)
        {
            var responce = this.SendPublicGetRequest <OKExSymbol[]>($"{this.settings.RestEndpoint}/api/v5/public/instruments?instType={instrumentType.GetEnumMember()}", token);

            error = responce.Message;
            return(responce.Data ?? new OKExSymbol[0]);
        }
예제 #3
0
        public static SymbolType ToTerminal(this OKExInstrumentType type)
        {
            return(type switch
            {
                OKExInstrumentType.Spot => SymbolType.Crypto,
                OKExInstrumentType.Swap => SymbolType.Swap,
                OKExInstrumentType.Futures => SymbolType.Futures,
                OKExInstrumentType.Option => SymbolType.Options,
                OKExInstrumentType.Index => SymbolType.Indexes,

                _ => throw new ArgumentException($"Unsupported symbol type - {type}"),
            });
예제 #4
0
        public bool TryGetSymbolById(string symbolId, OKExInstrumentType type, out OKExSymbol symbol)
        {
            symbol = null;

            foreach (var item in this.allSymbolsCache)
            {
                if (type != OKExInstrumentType.Any && type == item.Key)
                {
                    return(item.Value.TryGetValue(symbolId, out symbol));
                }
            }

            return(false);
        }
예제 #5
0
        internal void AddSymbols(OKExInstrumentType type, IEnumerable <OKExSymbol> symbols)
        {
            this.allSymbolsCache[type] = new Dictionary <string, OKExSymbol>();
            foreach (var s in symbols)
            {
                this.allSymbolsCache[type][s.OKExInstrumentId] = s;
            }

            switch (type)
            {
            case OKExInstrumentType.Futures:
            {
                this.PopulateFuturesByUnderlierCache();
                break;
            }

            case OKExInstrumentType.Option:
            {
                this.PopulateOptionsByUnderlierCache();
                break;
            }
            }
        }
예제 #6
0
 internal bool Contains(OKExInstrumentType type) => this.allSymbolsCache.ContainsKey(type);