17 using System.Collections.Generic;
28 private readonly
int _numberOfDays;
29 private readonly TimeSpan _timeOfDay;
35 private readonly Queue<UnsettledCashAmount> _unsettledCashAmounts;
44 _timeOfDay = timeOfDay;
45 _numberOfDays = numberOfDays;
46 _unsettledCashAmounts =
new();
57 var security = applyFundsParameters.
Security;
58 var portfolio = applyFundsParameters.
Portfolio;
66 var settlementDate = applyFundsParameters.
UtcTime.ConvertFromUtc(security.Exchange.TimeZone).Date;
67 for (var i = 0; i < _numberOfDays; i++)
69 settlementDate = settlementDate.AddDays(1);
72 if (!security.Exchange.Hours.IsDateOpen(settlementDate))
77 var settlementTimeUtc = settlementDate.Add(_timeOfDay).ConvertToUtc(security.Exchange.Hours.TimeZone);
79 lock (_unsettledCashAmounts)
81 _unsettledCashAmounts.Enqueue(
new UnsettledCashAmount(settlementTimeUtc, currency, amount));
88 portfolio.CashBook[currency].AddAmount(amount);
92 if (_cashBook ==
null)
94 _cashBook = portfolio.UnsettledCashBook;
104 lock (_unsettledCashAmounts)
106 while (_unsettledCashAmounts.TryPeek(out var item)
108 && settlementParameters.
UtcTime >= item.SettlementTimeUtc)
111 _unsettledCashAmounts.Dequeue();
129 lock (_unsettledCashAmounts)
131 if (_unsettledCashAmounts.Count == 0)