本文整理汇总了C#中SecurityPortfolioManager.GetBuyingPower方法的典型用法代码示例。如果您正苦于以下问题:C# SecurityPortfolioManager.GetBuyingPower方法的具体用法?C# SecurityPortfolioManager.GetBuyingPower怎么用?C# SecurityPortfolioManager.GetBuyingPower使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SecurityPortfolioManager
的用法示例。
在下文中一共展示了SecurityPortfolioManager.GetBuyingPower方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetSufficientCapitalForOrder
/// <summary>
/// Check if there is sufficient capital to execute this order.
/// </summary>
/// <param name="portfolio">Our portfolio</param>
/// <param name="order">Order we're checking</param>
/// <returns>True if suficient capital.</returns>
public bool GetSufficientCapitalForOrder(SecurityPortfolioManager portfolio, Order order)
{
if (Math.Abs(GetOrderRequiredBuyingPower(order)) > portfolio.GetBuyingPower(order.Symbol, order.Direction))
{
//Log.Debug("Symbol: " + order.Symbol + " Direction: " + order.Direction.ToString() + " Quantity: " + order.Quantity);
//Log.Debug("GetOrderRequiredBuyingPower(): " + Math.Abs(GetOrderRequiredBuyingPower(order)) + " PortfolioGetBuyingPower(): " + portfolio.GetBuyingPower(order.Symbol, order.Direction));
return false;
}
return true;
}
示例2: GetSufficientCapitalForOrder
/// <summary>
/// Check if there is sufficient capital to execute this order.
/// </summary>
/// <param name="portfolio">Our portfolio</param>
/// <param name="order">Order we're checking</param>
/// <returns>True if suficient capital.</returns>
public bool GetSufficientCapitalForOrder(SecurityPortfolioManager portfolio, Order order)
{
//First simple check, when don't hold stock, this will always increase portfolio regardless of direction
if (Math.Abs(GetOrderRequiredBuyingPower(order)) > portfolio.GetBuyingPower(order.Symbol, order.Direction)) {
//Log.Debug("Symbol: " + order.Symbol + " Direction: " + order.Direction.ToString() + " Quantity: " + order.Quantity);
//Log.Debug("GetOrderRequiredBuyingPower(): " + Math.Abs(GetOrderRequiredBuyingPower(order)) + " PortfolioGetBuyingPower(): " + portfolio.GetBuyingPower(order.Symbol, order.Direction));
return false;
} else {
return true;
}
}
示例3: GetExpectedFinalHoldings
/// <summary>
/// Given this portfolio and order, what would the final portfolio holdings be if it were filled.
/// </summary>
/// <param name="portfolio">Portfolio we're running</param>
/// <param name="order">Order requested to process </param>
/// <returns>decimal final holdings </returns>
private decimal GetExpectedFinalHoldings(SecurityPortfolioManager portfolio, Order order)
{
decimal expectedFinalHoldings = 0;
if (portfolio.TotalAbsoluteHoldings > 0) {
foreach (Security company in Securities.Values)
{
if (order.Symbol == company.Symbol)
{
//If the same holding, we must check if its long or short.
expectedFinalHoldings += Math.Abs(company.Holdings.HoldingValue + (order.Price * (decimal)order.Quantity));
Log.Debug("HOLDINGS: " + company.Holdings.HoldingValue + " - " + "ORDER: (P: " + order.Price + " Q:" + order.Quantity + ") EXPECTED FINAL HOLDINGS: " + expectedFinalHoldings + " BUYING POWER: " + portfolio.GetBuyingPower(order.Symbol));
} else {
//If not the same asset, then just add the absolute holding to the final total:
expectedFinalHoldings += company.Holdings.AbsoluteHoldings;
}
}
} else {
//First purchase: just make calc abs order size:
expectedFinalHoldings = (order.Price * (decimal)order.Quantity);
}
return expectedFinalHoldings;
}