Esempio n. 1
0
 public void Add(Money balance, MarketPrice price = null)
 {
     lock (_lock)
     {
         CurrentBalance = balance;
         Audits.Add(new AuditEntry(DateTime.UtcNow, balance, price));
     }
 }
Esempio n. 2
0
        public MarketPricesResult(MarketPrice price)
        {
            if (price != null)
            {
                MarketPrices.Add(price);
            }

            WasViaSingleMethod = true;
        }
Esempio n. 3
0
        public void Add(Money balance, MarketPrice price = null)
        {
            if (balance.Asset.Id != Asset.Id)
            {
                throw new Exception($"You cant add this balance to {nameof(AuditByAsset)} as it has the wrong asset class: {balance.Asset.ShortCode} needs {Asset.ShortCode}");
            }

            lock (_lock)
                Audit.Add(new AuditEntry(DateTime.UtcNow, balance, price));
        }
Esempio n. 4
0
        public decimal PercentageDifference(MarketPrice secondPrice)
        {
            if (secondPrice.Reversed.Pair.Id == this.Pair.Id)
            {
                secondPrice = secondPrice.Reversed;
            }

            if (secondPrice.Pair.Id != Pair.Id)
            {
                throw new Exception($"Can't calculate percentage difference for {nameof(MarketPrice)}, as pairs don't match: {secondPrice.Pair} - {Pair}");
            }

            return(Price.PercentageProfit(secondPrice.Price));
        }
Esempio n. 5
0
        public void Add(MarketPrice price)
        {
            lock (_lock)
            {
                if (!_prices.ContainsKey(price.Pair.Id))
                {
                    _prices.Add(price.Pair.Id, new List <MarketPrice>());
                }

                var col = _prices[price.Pair.Id];
                var dt  = DateTime.UtcNow.Add(-FlushSpan);
                col.RemoveAll(x => x.UtcCreated < dt);
                col.Add(price);
            }
        }
Esempio n. 6
0
 public AuditEntry(DateTime utcCreated, Money value, MarketPrice tradePrice = null)
 {
     UtcCreated = utcCreated;
     Value      = value;
     TradePrice = tradePrice;
 }
Esempio n. 7
0
 public AuditByAsset(Money startingBalance, MarketPrice price = null)
 {
     Asset = startingBalance.Asset;
     Add(startingBalance, price);
 }