public SynthOrderBook(AssetPair assetPair, IReadOnlyList <OrderBook> originalOrderBooks)
 {
     AssetPair          = assetPair;
     OriginalOrderBooks = originalOrderBooks;
     BestBid            = Bids.Any() ? Bids.First() : (VolumePrice?)null;
     BestAsk            = Asks.Any() ? Asks.First() : (VolumePrice?)null;
 }
Exemplo n.º 2
0
 public override string ToString()
 {
     return(string.Format("ExchOB {0} {1} Asks({2}) {3:f4}@{4:f4} Bids({5}) {6:f4}@{7:f4}",
                          Exchange,
                          Pair,
                          Asks.Count,
                          Asks.Count == 0 ? 0 : Asks.First().Amount,
                          Asks.Count == 0 ? 0 : Asks.First().Price,
                          Bids.Count,
                          Bids.Count == 0 ? 0 : Bids.First().Amount,
                          Bids.Count == 0 ? 0 : Bids.First().Price));
 }
Exemplo n.º 3
0
        public void RemoveBid(Bid bid)
        {
            var existingBid = _bids.FirstOrDefault(b => b.BidId.Equals(bid.BidId));

            if (existingBid == null)
            {
                throw new DomainException($"Cannot find bid with BidId: {bid.BidId}");
            }

            _bids.Remove(existingBid);

            AddEvent(new BidRemoved(bid));
            if (existingBid.Price.Equals(ActualPrice))
            {
                var topBid = Bids.First(b => b.Price == Bids.Max(mbid => mbid.Price));
                ActualPrice = topBid.Price;
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Reserved for internal use.
        /// </summary>
        protected override void ReconstructSubTargets()
        {
            ReconstructApiBids(
                LocationTargetType.City,
                t => new CityTargetBid {
                BidAdjustment = t.BidAdjustment, City = t.Location
            },
                () => Location.CityTarget,
                _ => Location.CityTarget = _,
                () => Location.CityTarget.Bids,
                _ => Location.CityTarget.Bids = _
                );

            ReconstructApiBids(
                LocationTargetType.MetroArea,
                t => new MetroAreaTargetBid()
            {
                BidAdjustment = t.BidAdjustment, MetroArea = t.Location
            },
                () => Location.MetroAreaTarget,
                _ => Location.MetroAreaTarget = _,
                () => Location.MetroAreaTarget.Bids,
                _ => Location.MetroAreaTarget.Bids = _
                );

            ReconstructApiBids(
                LocationTargetType.State,
                t => new StateTargetBid()
            {
                BidAdjustment = t.BidAdjustment, State = t.Location
            },
                () => Location.StateTarget,
                _ => Location.StateTarget = _,
                () => Location.StateTarget.Bids,
                _ => Location.StateTarget.Bids = _
                );

            ReconstructApiBids(
                LocationTargetType.Country,
                t => new CountryTargetBid()
            {
                BidAdjustment = t.BidAdjustment, CountryAndRegion = t.Location
            },
                () => Location.CountryTarget,
                _ => Location.CountryTarget = _,
                () => Location.CountryTarget.Bids,
                _ => Location.CountryTarget.Bids = _
                );

            ReconstructApiBids(
                LocationTargetType.PostalCode,
                t => new PostalCodeTargetBid()
            {
                BidAdjustment = t.BidAdjustment, PostalCode = t.Location
            },
                () => Location.PostalCodeTarget,
                _ => Location.PostalCodeTarget = _,
                () => Location.PostalCodeTarget.Bids,
                _ => Location.PostalCodeTarget.Bids = _
                );

            if (Bids.Any())
            {
                Location.IntentOption = Bids.First().IntentOption;
            }
        }