Esempio n. 1
0
        public BfTradingMarketTickerSource(BfTradingMarket market)
        {
            // If market is FX_BTC_JPY, get BTC_JPT ticker to calculate realtime SFD rate.
            if (market.ProductCode == BfProductCode.FXBTCJPY)
            {
                _source = Observable.Create <BfTradingMarketTicker>(observer =>
                {
                    // Merge order book, native ticker and market health(REST)
                    market.GetOrderBookSource().CombineLatest
                    (
                        market.RealtimeSource.GetTickerSource(BfProductCode.FXBTCJPY),
                        market.RealtimeSource.GetTickerSource(BfProductCode.BTCJPY),
                        Observable.Timer(TimeSpan.Zero, market.Config.MarketStatusConfirmInterval)
                        .Select(count => market.Client.GetMarketHealth(BfProductCode.FXBTCJPY).GetResult()),
                        (ob, fxbtcjpy, btcjpy, health) =>
                    {
                        if (fxbtcjpy.Timestamp > _lastServerTime)
                        {
                            _lastServerTime = fxbtcjpy.Timestamp;
                            _serverTimeDiff = _lastServerTime - DateTime.UtcNow;
                        }
                        return(new BfTradingMarketTicker(ob, fxbtcjpy, btcjpy, health, _serverTimeDiff));
                    }
                    )
                    .Subscribe(observer).AddTo(_disposables);

                    return(_disposables.Dispose);
                });
            }
            else
            {
                _source = Observable.Create <BfTradingMarketTicker>(observer =>
                {
                    // Merge order book, native ticker and market health(REST)
                    market.GetOrderBookSource().CombineLatest
                    (
                        market.RealtimeSource.GetTickerSource(market.ProductCode),
                        Observable.Timer(TimeSpan.Zero, market.Config.MarketStatusConfirmInterval)
                        .Select(count => market.Client.GetMarketHealth(market.ProductCode).GetResult()),
                        (ob, nt, health) =>
                    {
                        if (nt.Timestamp > _lastServerTime)
                        {
                            _lastServerTime = nt.Timestamp;
                            _serverTimeDiff = _lastServerTime - DateTime.UtcNow;
                        }
                        return(new BfTradingMarketTicker(ob, nt, health, _serverTimeDiff));
                    }
                    )
                    .Subscribe(observer).AddTo(_disposables);

                    return(_disposables.Dispose);
                });
            }
        }
Esempio n. 2
0
 public BfxParentOrderTransactionState(BfTradingMarket market, BfParentOrderRequest request)
     : base(request)
 {
     _market = market;
 }
Esempio n. 3
0
 public BfxOrderFactory(BfTradingMarket market)
 {
     _market = market;
 }
 public BfxParentOrderTransaction(BfTradingMarket market, BfParentOrderRequest request)
 {
     DebugEx.EnterMethod();
     _market = market;
     State   = new BfxParentOrderTransactionState(_market, request);
 }
Esempio n. 5
0
 public BfxChildOrderTransactionState(BfTradingMarket market, BfChildOrderRequest request)
     : base(request)
 {
     _market = market;
 }