本文整理汇总了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;
}
示例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;
}