コード例 #1
0
        /// <summary>
        /// Process incoming quotes
        /// </summary>
        /// <param name="input"></param>
        protected void OnInputQuote(InputPointModel input)
        {
            var dateAsk     = input.AskDate;
            var dateBid     = input.BidDate;
            var currentAsk  = input.Ask;
            var currentBid  = input.Bid;
            var previousAsk = _point?.Ask ?? currentAsk;
            var previousBid = _point?.Bid ?? currentBid;
            var symbol      = input.Symbol;

            var point = new PointModel
            {
                Ask        = currentAsk,
                Bid        = currentBid,
                Bar        = new PointBarModel(),
                Instrument = Account.Instruments[symbol],
                AskSize    = input.AskSize,
                BidSize    = input.BidSize,
                Time       = DateTimeOffset.FromUnixTimeMilliseconds(Math.Max(dateAsk.Value, dateBid.Value)).DateTime,
                Last       = ConversionManager.Compare(currentBid, previousBid) ? currentAsk : currentBid
            };

            _point = point;

            UpdatePointProps(point);
        }
コード例 #2
0
        /// <summary>
        /// Process incoming quotes
        /// </summary>
        /// <param name="input"></param>
        protected void OnInputData(InputPointModel input)
        {
            var currentAsk  = input.Ask;
            var currentBid  = input.Bid;
            var previousAsk = _point?.Ask ?? currentAsk;
            var previousBid = _point?.Bid ?? currentBid;
            var instrument  = $"{ input.Instrument }";

            var point = new PointModel
            {
                Ask        = currentAsk,
                Bid        = currentBid,
                Time       = input.Time,
                Bar        = new PointBarModel(),
                Instrument = Account.Instruments[instrument],
                Last       = ConversionManager.Compare(currentBid, previousBid) ? currentAsk : currentBid
            };

            if (input.Asks.Any())
            {
                var edge = input.Asks.Min(o => new { o.Price, o.Size });

                point.Ask     = Math.Min(point.Ask.Value, edge.Price.Value);
                point.AskSize = edge.Size;
            }

            if (input.Bids.Any())
            {
                var edge = input.Bids.Max(o => new { o.Price, o.Size });

                point.Bid     = Math.Max(point.Bid.Value, edge.Price.Value);
                point.BidSize = edge.Size;
            }

            _point = point;

            UpdatePointProps(point);
        }