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


C# Order.GetValue方法代码示例

本文整理汇总了C#中Order.GetValue方法的典型用法代码示例。如果您正苦于以下问题:C# Order.GetValue方法的具体用法?C# Order.GetValue怎么用?C# Order.GetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Order的用法示例。


在下文中一共展示了Order.GetValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetOrderFee

        /// <summary>
        /// Gets the order fee associated with the specified order. This returns the cost
        /// of the transaction in the account currency
        /// </summary>
        /// <param name="security">The security matching the order</param>
        /// <param name="order">The order to compute fees for</param>
        /// <returns>The cost of the order in units of the account currency</returns>
        public decimal GetOrderFee(Security security, Order order)
        {
            switch (security.Type)
            {
                case SecurityType.Forex:
                    // get the total order value in the account currency
                    var totalOrderValue = order.GetValue(security);
                    var fee = Math.Abs(_forexCommissionRate*totalOrderValue);
                    return Math.Max(_forexMinimumOrderFee, fee);

                case SecurityType.Equity:
                    var tradeValue = Math.Abs(order.GetValue(security));

                    //Per share fees
                    var tradeFee = 0.005m * order.AbsoluteQuantity;

                    //Maximum Per Order: 0.5%
                    //Minimum per order. $1.0
                    var maximumPerOrder = 0.005m * tradeValue;
                    if (tradeFee < 1)
                    {
                        tradeFee = 1;
                    }
                    else if (tradeFee > maximumPerOrder)
                    {
                        tradeFee = maximumPerOrder;
                    }

                    //Always return a positive fee.
                    return Math.Abs(tradeFee);
            }

            // all other types default to zero fees
            return 0m;
        }
开发者ID:kaffeebrauer,项目名称:Lean,代码行数:42,代码来源:InteractiveBrokersFeeModel.cs

示例2: GetOrderFee

        /// <summary>
        /// Gets the order fee associated with the specified order. This returns the cost
        /// of the transaction in the account currency
        /// </summary>
        /// <param name="security">The security matching the order</param>
        /// <param name="order">The order to compute fees for</param>
        /// <returns>The cost of the order in units of the account currency</returns>
        public decimal GetOrderFee(Security security, Order order)
        {
            if (security.Type == SecurityType.Forex)
            {
                var forex = (Forex)security;

                // get the total order value in the account currency
                var price = order.Status.IsFill() ? order.Price : security.Price;
                var totalOrderValue = order.GetValue(price) * forex.QuoteCurrency.ConversionRate;
                var fee = Math.Abs(_commissionRate*totalOrderValue);
                return Math.Max(_minimumOrderFee, fee);
            }

            if (security.Type == SecurityType.Equity)
            {
                var price = order.Status.IsFill() ? order.Price : security.Price;
                var tradeValue = Math.Abs(order.GetValue(price));

                //Per share fees
                var tradeFee = 0.005m * order.AbsoluteQuantity;

                //Maximum Per Order: 0.5%
                //Minimum per order. $1.0
                var maximumPerOrder = 0.005m * tradeValue;
                if (tradeFee < 1)
                {
                    tradeFee = 1;
                }
                else if (tradeFee > maximumPerOrder)
                {
                    tradeFee = maximumPerOrder;
                }

                //Always return a positive fee.
                return Math.Abs(tradeFee);
            }

            // all other types default to zero fees
            return 0m;
        }
开发者ID:skyfyl,项目名称:Lean,代码行数:47,代码来源:InteractiveBrokersFeeModel.cs


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