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

            WasViaSingleMethod = true;
        }
Exemplo 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));
        }
Exemplo 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));
        }
Exemplo 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);
            }
        }
Exemplo n.º 6
0
 public AuditEntry(DateTime utcCreated, Money value, MarketPrice tradePrice = null)
 {
     UtcCreated = utcCreated;
     Value      = value;
     TradePrice = tradePrice;
 }
Exemplo n.º 7
0
 public AuditByAsset(Money startingBalance, MarketPrice price = null)
 {
     Asset = startingBalance.Asset;
     Add(startingBalance, price);
 }