Ejemplo n.º 1
0
        private OrderResetResult CreateResetResult(Order order, Dictionary <Guid, TradeDayCommonResult> commonDict, Dictionary <Guid, OpenOrderPLOfCurrentDay> openOrderPLOfCurrentDayDict, Dictionary <Guid, InterestStorage> notValuedPLDict, Dictionary <Guid, InterestStorage> valuedPLDict)
        {
            OrderResetResult     resetResult  = new OrderResetResult();
            TradeDayCommonResult commonResult = null;

            if (commonDict != null)
            {
                commonDict.TryGetValue(order.Id, out commonResult);
            }

            OpenOrderPLOfCurrentDay openOrderPLOfCurrentDay = null;

            if (openOrderPLOfCurrentDayDict != null)
            {
                openOrderPLOfCurrentDayDict.TryGetValue(order.Id, out openOrderPLOfCurrentDay);
            }

            InterestStorage interestStoragePLNotValued = InterestStorage.Empty;

            if (notValuedPLDict != null)
            {
                notValuedPLDict.TryGetValue(order.Id, out interestStoragePLNotValued);
            }

            InterestStorage interestStoragePLValued = InterestStorage.Empty;

            if (valuedPLDict != null)
            {
                valuedPLDict.TryGetValue(order.Id, out interestStoragePLValued);
            }
            resetResult.TradeDay   = _info.TradeDay;
            resetResult.OrderId    = order.Id;
            resetResult.LotBalance = order.LotBalance;
            resetResult.CurrencyId = _info.RateSetting.CurrencyId;
            Price livePrice = order.IsBuy ? _info.Settings.SellPrice : _info.Settings.BuyPrice;

            resetResult.Margin = Calculator.MarginCalculator.CalculateMargin((int)_info.Instrument.MarginFormula, order.LotBalance, order.Owner.ContractSize(_info.TradeDay), order.ExecutePrice, livePrice, _info.RateSetting.RateIn, _info.RateSetting.RateOut, _info.RateSetting.RoundDecimals.Common, _info.RateSetting.RoundDecimals.Instrument);

            resetResult.PerLot = commonResult == null ? InterestStorage.Empty : new InterestStorage(commonResult.InterestPerLot, commonResult.StoragePerLot);

            resetResult.FloatPL = commonResult == null ? InterestStorage.Empty : new InterestStorage(_exchanger.ExchangeByCommonWithInstrumentSourceDecimals(order.LotBalance * commonResult.InterestPerLot), _exchanger.ExchangeByCommonWithInstrumentSourceDecimals(order.LotBalance * commonResult.StoragePerLot));

            resetResult.DayNotValuedPL = openOrderPLOfCurrentDay == null ? InterestStorage.Empty : new InterestStorage(openOrderPLOfCurrentDay.DayNotValued);

            resetResult.NotValuedPL = interestStoragePLNotValued + (openOrderPLOfCurrentDay == null ? InterestStorage.Empty : openOrderPLOfCurrentDay.NotValued);

            resetResult.ValuedPL = interestStoragePLValued + (openOrderPLOfCurrentDay == null ? InterestStorage.Empty : openOrderPLOfCurrentDay.Valued);

            if (_info.Instrument.Category == InstrumentCategory.Physical)
            {
                Physical.PhysicalOrder physicalOrder = (Physical.PhysicalOrder)order;
                resetResult.PhysicalPaidAmount         = physicalOrder.PaidAmount;
                resetResult.PaidPledgeBalance          = physicalOrder.PaidPledgeBalance;
                resetResult.PhysicalOriginValueBalance = physicalOrder.PhysicalOriginValueBalance;
                resetResult.InstalmentInterest         = commonResult == null ? 0m : commonResult.InstalmentInterest;
            }
            return(resetResult);
        }
Ejemplo n.º 2
0
 internal OpenOrderPLOfCurrentDay()
 {
     this.DayNotValued = InterestStorage.Empty;
     this.NotValued    = InterestStorage.Empty;
     this.Valued       = InterestStorage.Empty;
 }