Ejemplo n.º 1
0
 internal HistoryOrderDeleter(Order order, Settings.Setting setting, bool isPayForInstalmentDebitInterest)
 {
     this.Account = order.Owner.Owner;
     _order       = order;
     _isPayForInstalmentDebitInterest = isPayForInstalmentDebitInterest;
     _physicalOrder       = _order as PhysicalOrder;
     _currencyId          = DBResetRepository.GetCurrencyId(this.Account.Id, order.Instrument().Id, _order.Owner.ExecuteTime.Value);
     _historyOrderRecover = new HistoryOrderRecover(this.Account, _order.Instrument().Id, OrderHelper.GetAffectedOrders(_order), new List <Guid> {
         order.Id
     }, setting);
 }
Ejemplo n.º 2
0
        internal static void Process(Transaction tran, Settings.Setting setting, DateTime tradeDay)
        {
            var      account             = tran.Owner;
            var      historyOrderRecover = new HistoryOrderRecover(account, tran.InstrumentId, GetAffectedOrders(tran), new List <Guid>(), setting);
            DateTime beginResetTradeDay  = tradeDay;
            DateTime?lastResetTradeDay   = account.LastResetDay;

            if (lastResetTradeDay == null || beginResetTradeDay > lastResetTradeDay)
            {
                RecoverBalance(new Dictionary <DateTime, decimal>(), tran, CalculateNotRecoverOrderCost(tran));
            }
            else
            {
                var     deltaAmountPerTradeDayDict = historyOrderRecover.RecoverDay(beginResetTradeDay, lastResetTradeDay.Value);
                decimal orderExecuteFee            = CalculateCost(tran);
                RecoverAccountBalanceDayHistory(deltaAmountPerTradeDayDict, orderExecuteFee, tran);
                RecoverBalance(deltaAmountPerTradeDayDict, tran, orderExecuteFee);
                UpdateInstalmentOrderDebitInterest(tran, setting, beginResetTradeDay);
                OrderUpdater.Default.UpdateOrderInterestPerLotAndStoragePerLot(tran, lastResetTradeDay.Value);
            }
            RemoveCompletedOrdersFromCache(tran);
        }