Пример #1
0
        protected decimal CalculateTotalMarginCommon(Predicate <Order> predicate)
        {
            decimal totalMargin = 0m;

            foreach (Order order in _owner.ExecutedAndHasPositionOrders)
            {
                if (predicate(order))
                {
                    totalMargin += NecessaryCalculator.CalculateNecessary(order, null, order.LotBalance, null);
                }
            }
            return(totalMargin);
        }
Пример #2
0
 internal static void CalculatePreCheckNecessary(this Order order, MarginFormula marginFormula, CurrencyRate currencyRate, decimal contractSize, Price preCheckPrice, decimal?effectiveLot)
 {
     if (preCheckPrice != null)
     {
         var lot = effectiveLot.HasValue ? effectiveLot.Value : order.Lot;
         order.PreCheckMargin = NecessaryCalculator.CalculateNecessary(order, marginFormula, lot, contractSize, preCheckPrice, currencyRate);
     }
     else if (!order.IsPreCheckCalculated)
     {
         var price = order.SetPrice == null ? order.ExecutePrice : order.SetPrice;
         order.PreCheckMargin = NecessaryCalculator.CalculateNecessary(order, marginFormula, order.Lot, contractSize, price, currencyRate);
     }
     order.IsPreCheckCalculated = true;
 }
Пример #3
0
        internal static decimal CalculatePreCheckNecessary(this Order order, Price preCheckPrice, decimal?effectiveLot)
        {
            decimal result = 0m;

            if (preCheckPrice != null)
            {
                var lot = effectiveLot.HasValue ? effectiveLot.Value : order.Lot;
                result = NecessaryCalculator.CalculateNecessary(order, preCheckPrice, lot);
            }
            else
            {
                var price = order.SetPrice == null ? order.ExecutePrice : order.SetPrice;
                result = NecessaryCalculator.CalculateNecessary(order, price, order.Lot);
            }
            return(result);
        }
Пример #4
0
        internal decimal CalculatePreCheckNecessary(Price preCheckPrice, decimal?effectiveLot)
        {
            decimal result = 0m;

            if (preCheckPrice != null)
            {
                var lot = effectiveLot.HasValue ? effectiveLot.Value : _order.Lot;
                result = NecessaryCalculator.CalculateNecessary(_order, preCheckPrice, lot, null);
            }
            else
            {
                var price = _order.SetPrice == null ? _order.ExecutePrice : _order.SetPrice;
                result = NecessaryCalculator.CalculateNecessary(_order, price, _order.Lot, null);
            }
            return(result);
        }
Пример #5
0
        private static void CalculateMarginAndQuantity(this Order order, bool isPartialPaymentPhysicalOrder, Dictionary <Guid, decimal> remainFilledLotPerOrderDict, out decimal margin, out decimal quantity)
        {
            margin = quantity = 0m;
            decimal remainLot;

            if (remainFilledLotPerOrderDict != null && remainFilledLotPerOrderDict.TryGetValue(order.Id, out remainLot))
            {
                if (remainLot > 0)
                {
                    margin   = NecessaryCalculator.CalculateNecessary(order, remainLot);
                    quantity = isPartialPaymentPhysicalOrder ? remainLot : remainLot * order.Owner.ContractSize;
                }
            }
            else
            {
                margin   = order.Necessary;
                quantity = isPartialPaymentPhysicalOrder ? order.LotBalance : order.LotBalance * order.Owner.ContractSize;
            }
        }
Пример #6
0
 public void CalculateNecessary(decimal lot)
 {
     this.Necessary = NecessaryCalculator.CalculateNecessary(_owner, null, lot, null);
 }
Пример #7
0
 protected void CalculateNecessary(Quotation quotation)
 {
     this.Necessary = NecessaryCalculator.CalculateNecessary(_owner, quotation, null);
 }
Пример #8
0
 private decimal CalculateMargin(decimal remainLot)
 {
     return(remainLot > 0 ? NecessaryCalculator.CalculateNecessary(_order, null, remainLot, null) : _order.Necessary);
 }