Example #1
0
        private decimal CaculateFeeForCuttingAll(decimal buyLotSum, ICollection <CuttingItem> openBuyOrders,
                                                 decimal sellLotSum, ICollection <CuttingItem> openSellOrders)
        {
            decimal fee       = 0;
            var     quotation = _owner.GetQuotation();

            if (quotation == null)
            {
                return(fee);
            }
            Price buy = quotation.BuyPrice, sell = quotation.SellPrice;

            if (sellLotSum > 0)
            {
                fee += this.CaculateFeeForCutting(sellLotSum, sell, openSellOrders);
            }

            if (buyLotSum > 0)
            {
                fee += this.CaculateFeeForCutting(buyLotSum, buy, openBuyOrders);
            }
            return(fee);
        }
Example #2
0
        private List <Transaction> CutNet(Instrument instrument)
        {
            bool    isBuy         = (instrument.TotalBuyLotBalance < instrument.TotalSellLotBalance);
            decimal lotBalanceSum = Math.Abs(instrument.TotalBuyLotBalance - instrument.TotalSellLotBalance);

            if (lotBalanceSum == 0)
            {
                return(null);
            }
            var quotation = instrument.GetQuotation();
            var price     = isBuy ? quotation.BuyPrice : quotation.SellPrice;
            Dictionary <Guid, decimal> closedLotPerOpenOrderDict = new Dictionary <Guid, decimal>();;
            var tran   = this.CutCommon(closedLotPerOpenOrderDict, instrument, isBuy, lotBalanceSum, price);
            var result = new List <Transaction>();

            result.Add(tran);
            return(result);
        }
Example #3
0
        private List <Transaction> CutAll(Instrument instrument)
        {
            List <Transaction> result    = new List <Transaction>(CUT_ALL_TRANSACTION_CAPACITY);
            Quotation          quotation = instrument.GetQuotation();

            if (quotation == null)
            {
                return(result);
            }
            Dictionary <Guid, decimal> closedLotPerOpenOrderDict = new Dictionary <Guid, decimal>();;

            if (instrument.TotalSellLotBalance > 0)
            {
                var tran = this.CutCommon(closedLotPerOpenOrderDict, instrument, true, instrument.TotalSellLotBalance, quotation.SellPrice);
                result.Add(tran);
            }

            if (instrument.TotalBuyLotBalance > 0)
            {
                var tran = this.CutCommon(closedLotPerOpenOrderDict, instrument, false, instrument.TotalBuyLotBalance, quotation.BuyPrice);
                result.Add(tran);
            }
            return(result);
        }