public async Task <T> ResolveInstrumentAsync(
            IInstrumentConverterContext <T> context,
            Instrument instrument,
            bool isTestVendorCodeRequired = false)
        {
            if (_instrumentDataByInstrument.TryGetValue(instrument, out var data))
            {
                return(data);
            }

            data = await ResolveInstrumentImplAsync(context, instrument, isTestVendorCodeRequired);

            if (data == null)
            {
                return(null);
            }

            if (isTestVendorCodeRequired)
            {
                var tester = context.SubscriptionTester;
                if (tester != null)
                {
                    var result = await tester.TestSubscriptionAsync(data);

                    if (!result.Ok)
                    {
                        return(null);
                    }
                }
            }

            _instrumentDataByInstrument.TryAdd(instrument, data);

            return(data);
        }
Exemplo n.º 2
0
 protected override Task <Instrument> ResolveSymbolImplAsync(
     IInstrumentConverterContext <IQFeedInstrumentData> context,
     string symbol,
     string dependentObjectDescription)
 {
     return(Task.FromResult(new Instrument(symbol)));
 }
Exemplo n.º 3
0
 protected override Task <InstrumentData> ResolveInstrumentImplAsync(IInstrumentConverterContext <InstrumentData> context, Instrument instrument,
                                                                     bool isTestVendorCodeRequired)
 {
     return(Task.FromResult(new InstrumentData()
     {
         Symbol = instrument.Code, Instrument = instrument
     }));
 }
        public async Task <Instrument> ResolveSymbolAsync(
            IInstrumentConverterContext <T> context,
            string symbol,
            string dependentObjectDescription = null)
        {
            if (_instrumentBySymbol.TryGetValue(symbol, out var instrument))
            {
                return(instrument);
            }

            instrument = await ResolveSymbolImplAsync(context, symbol, dependentObjectDescription);

            if (instrument == null)
            {
                return(null);
            }

            _instrumentBySymbol.TryAdd(symbol, instrument);

            return(instrument);
        }
Exemplo n.º 5
0
 protected override Task <Instrument> ResolveSymbolImplAsync(IInstrumentConverterContext <InstrumentData> context, string symbol, string dependentObjectDescription)
 {
     throw new NotImplementedException();
 }
 protected abstract Task <Instrument> ResolveSymbolImplAsync(
     IInstrumentConverterContext <T> context,
     string symbol,
     string dependentObjectDescription);
 protected abstract Task <T> ResolveInstrumentImplAsync(
     IInstrumentConverterContext <T> context,
     Instrument instrument,
     bool isTestVendorCodeRequired);