本文整理汇总了C#中SecurityPortfolioManager.AddUnsettledCashAmount方法的典型用法代码示例。如果您正苦于以下问题:C# SecurityPortfolioManager.AddUnsettledCashAmount方法的具体用法?C# SecurityPortfolioManager.AddUnsettledCashAmount怎么用?C# SecurityPortfolioManager.AddUnsettledCashAmount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SecurityPortfolioManager
的用法示例。
在下文中一共展示了SecurityPortfolioManager.AddUnsettledCashAmount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplyFunds
/// <summary>
/// Applies cash settlement rules
/// </summary>
/// <param name="portfolio">The algorithm's portfolio</param>
/// <param name="security">The fill's security</param>
/// <param name="applicationTimeUtc">The fill time (in UTC)</param>
/// <param name="currency">The currency symbol</param>
/// <param name="amount">The amount of cash to apply</param>
public void ApplyFunds(SecurityPortfolioManager portfolio, Security security, DateTime applicationTimeUtc, string currency, decimal amount)
{
if (amount > 0)
{
// positive amount: sell order filled
portfolio.UnsettledCashBook[currency].AddAmount(amount);
// find the correct settlement date (usually T+3 or T+1)
var settlementDate = applicationTimeUtc.ConvertFromUtc(security.Exchange.TimeZone).Date;
for (var i = 0; i < _numberOfDays; i++)
{
settlementDate = settlementDate.AddDays(1);
// only count days when market is open
if (!security.Exchange.Hours.IsDateOpen(settlementDate))
i--;
}
// use correct settlement time
var settlementTimeUtc = settlementDate.Add(_timeOfDay).ConvertToUtc(security.Exchange.Hours.TimeZone);
portfolio.AddUnsettledCashAmount(new UnsettledCashAmount(settlementTimeUtc, currency, amount));
}
else
{
// negative amount: buy order filled
portfolio.CashBook[currency].AddAmount(amount);
}
}