public void TradingStatus_Disabled_BackwardsCompatibility()
        {
            var reason = InstrumentTradingDisabledReason.InstrumentTradingDisabled;
            var status = InstrumentTradingStatus.Disabled(reason);

            Assert.True(status);
        }
Exemplo n.º 2
0
        public InstrumentTradingStatus GetInstrumentTradingStatus(string assetPairId, TimeSpan scheduleCutOff)
        {
            var assetPair = _assetPairsCache.GetAssetPairByIdOrDefault(assetPairId);

            if (assetPair == null)
            {
                _log.WriteWarningAsync(nameof(ScheduleSettingsCacheService), nameof(GetInstrumentTradingStatus),
                                       $"AssetPair [{assetPairId}] does not exist in cache. Trading is disabled.").GetAwaiter().GetResult();
                return(InstrumentTradingStatus.Disabled(InstrumentTradingDisabledReason.InstrumentNotFound));
            }

            if (assetPair.IsTradingDisabled)
            {
                return(InstrumentTradingStatus.Disabled(InstrumentTradingDisabledReason.InstrumentTradingDisabled));
            }

            if (!_marketStates.TryGetValue(assetPair.MarketId, out var marketState))
            {
                _log.WriteWarningAsync(nameof(ScheduleSettingsCacheService), nameof(GetInstrumentTradingStatus),
                                       $"Market status of market [{assetPair.MarketId}] for asset pair [{assetPairId}] does not exist in cache. Trading is disabled.").GetAwaiter().GetResult();
                return(InstrumentTradingStatus.Disabled(InstrumentTradingDisabledReason.MarketStateNotFound));
            }

            return(marketState.IsEnabled
                ? InstrumentTradingStatus.Enabled()
                : InstrumentTradingStatus.Disabled(InstrumentTradingDisabledReason.MarketDisabled));
        }
        public void TradingStatus_Disabled()
        {
            var reason = InstrumentTradingDisabledReason.InstrumentTradingDisabled;
            var status = InstrumentTradingStatus.Disabled(reason);

            Assert.False(status.TradingEnabled);
            Assert.That(status.Reason == reason);
        }
Exemplo n.º 4
0
        public void SetUp()
        {
            _bestPricesChannelMock = new Mock <IEventChannel <BestPriceChangeEventArgs> >();
            _dateServiceMock       = new Mock <IDateService>();
            _assetPairsCacheMock   = new Mock <IAssetPairsCache>();
            _cqrsSenderMock        = new Mock <ICqrsSender>();
            _identityGeneratorMock = new Mock <IIdentityGenerator>();
            _logMock             = new Mock <ILog>();
            _assetPairDayOffMock = new Mock <IAssetPairDayOffService>();
            _assetPairDayOffMock.Setup(x => x.IsAssetTradingDisabled(It.IsAny <string>()))
            .Returns(InstrumentTradingStatus.Enabled);

            _assetPairDayOffMock.Setup(x => x.IsAssetTradingDisabled(It.Is <string>(x => x == TradingDisabledAssetPair)))
            .Returns(InstrumentTradingStatus.Disabled(InstrumentTradingDisabledReason.InstrumentTradingDisabled));
            _schedulteSettingsMock = new Mock <IScheduleSettingsCacheService>();
        }