当前位置: 首页>>代码示例>>C#>>正文


C# SecurityPortfolioManager.GetBuyingPower方法代码示例

本文整理汇总了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;
 }
开发者ID:intelliBrain,项目名称:Lean,代码行数:16,代码来源:SecurityTransactionManager.cs

示例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;
     }
 }
开发者ID:kevinalexanderwong,项目名称:QCAlgorithm,代码行数:17,代码来源:SecurityTransactionManager.cs

示例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;
        }
开发者ID:vdt,项目名称:QCAlgorithm,代码行数:30,代码来源:SecurityTransactionManager.cs


注:本文中的SecurityPortfolioManager.GetBuyingPower方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。