private decimal slipage;     //weighted slipage of the specific strategy of a specific client.

        public StrategyStatistics(OrderAlgo algo_)
        {
            this.algo       = algo_;
            this.turnover   = 0;
            this.slipage    = 0;
            this.orderCount = 0;
            this.sliceCount = 0;
        }
        public override void parseQueryResult(Client client_, SqlDataReader reader_)
        {
            while (reader_.Read())
            {
                string           acct          = reader_["accountId"].ToString();
                string           orderId       = reader_["orderId"].ToString();
                string           symbol        = reader_["symbol"].ToString();
                string           stockName     = reader_["stockName"].ToString();
                MarginType       marginType    = (MarginType)Int32.Parse(reader_["marginType"].ToString());
                decimal          participation = MathUtil.round((decimal)reader_["participationRate"]);
                OrderAlgo        algo          = (OrderAlgo)Int32.Parse(reader_["algo"].ToString());
                OrderSide        side          = (OrderSide)Int32.Parse(reader_["side"].ToString());
                decimal          avgPrice      = MathUtil.round((decimal)reader_["avgPrice"]);
                decimal          slipageInBps  = MathUtil.round((decimal)reader_["slipageInBps"]);
                decimal          cumQty        = (decimal)reader_["cumQty"];
                string           tradingDay    = reader_["tradingDay"].ToString();
                string           effectiveTime = reader_["effectiveTime"].ToString();
                string           expireTime    = reader_["expireTime"].ToString();
                int              sliceCount    = Int32.Parse(reader_["SliceCount"].ToString());
                int              cancelCount   = Int32.Parse(reader_["cancelCount"].ToString());
                int              sentQty       = Int32.Parse(reader_["totalSentQty"].ToString());
                int              filledQty     = Int32.Parse(reader_["totalFilledQty"].ToString());
                int              filledCount   = Int32.Parse(reader_["filledCount"].ToString());
                SecurityType     securityType  = (SecurityType)Int32.Parse(reader_["securityType"].ToString());
                SavedClientOrder order         = new SavedClientOrder(acct, orderId, symbol, stockName, marginType, participation,
                                                                      algo, side, avgPrice, slipageInBps, cumQty, tradingDay, effectiveTime, expireTime,
                                                                      sliceCount, cancelCount, filledCount, sentQty, filledQty, securityType);

                // If configed to include orders with zero cumQty
                if (ConfigParser.CONFIG.getRunTimeConfig().reportZeroQtyOrders())
                {
                    client_.addClientOrder(order);
                }
                else if (order.getCumQty() > 0)
                {
                    // Only include orders with positive cumQty
                    client_.addClientOrder(order);
                }
            }
        }
        /// <summary>
        /// Construct an order from Database, used to prepare client report. Turnover is calculate according to symbol type.
        /// </summary>
        /// <param name="acct_">client account</param>
        /// <param name="symbol_">stock symbol</param>
        /// <param name="stockName_">stock name in Chinese</param>
        /// <param name="side_">Direction of the trade</param>
        /// <param name="avgPrice_">Average execution price</param>
        /// <param name="slipageInBps_">Order slipage.</param>
        /// <param name="cumQty_">Order cumQty</param>
        /// <param name="tradingDay_">Order tradingDay</param>
        /// <param name="effectiveTime_">Order start time</param>
        /// <param name="expireTime_">order end time</param>
        /// <param name="securityType">order end time</param>
        public SavedClientOrder(string acct_, string orderId_, string symbol_, string stockName_,
                                MarginType marginType_, decimal participationRate_,
                                OrderAlgo algo_, OrderSide side_,
                                decimal avgPrice_, decimal slipageInBps_, decimal cumQty_, string tradingDay_,
                                string effectiveTime_, string expireTime_, int sliceCount_, int cencelCount_, int filledCount_,
                                int sentQty_, int filledQty_, SecurityType securityType_)
        {
            this.acct      = acct_;
            this.orderId   = orderId_;
            this.symbol    = symbol_;
            this.stockName = stockName_;

            this.marginType        = marginType_;
            this.participationRate = participationRate_;
            this.algo               = algo_;
            this.side               = side_;
            this.avgPrice           = avgPrice_;
            this.slipageInBps       = slipageInBps_;
            this.cumQty             = cumQty_;
            this.tradingDay         = tradingDay_;
            this.effectiveTime      = effectiveTime_;
            this.expireTime         = expireTime_;
            this.exchangeOrders     = new List <SavedExchangeOrder>();
            this.exchangeOrderCount = 0;

            this.sliceCount   = sliceCount_;
            this.cancelCount  = cencelCount_;
            this.sentQty      = sentQty_;
            this.filledQty    = filledQty_;
            this.filledCount  = filledCount_;
            this.securityType = securityType_;

            //if (StoredProcMgr.MANAGER.isRepo(this.symbol))
            if (securityType.Equals(AlgoTrading.Data.SecurityType.RPO))
            {
                this.turnover = this.cumQty * StoredProcMgr.MANAGER.getMultiplier(this.symbol);
            }
            //else if (StoredProcMgr.MANAGER.isFuture(this.symbol))
            else if (securityType.Equals(AlgoTrading.Data.SecurityType.FTR))
            {
                if (symbol.StartsWith("IF"))
                {
                    this.turnover = this.cumQty * this.avgPrice * 300;
                }
                else if (symbol.StartsWith("IH"))
                {
                    this.turnover = this.cumQty * this.avgPrice * 300;
                }
                else if (symbol.StartsWith("IC"))
                {
                    this.turnover = this.cumQty * this.avgPrice * 200;
                }
            }
            else if (securityType.Equals(AlgoTrading.Data.SecurityType.BDC))
            {
                if (symbol.EndsWith("sh"))
                {
                    this.turnover = this.cumQty * this.avgPrice * 10;
                }
                else
                {
                    this.turnover = this.cumQty * this.avgPrice;
                }
            }
            //else if (StoredProcMgr.MANAGER.isEqt(this.symbol))
            else if (securityType.Equals(AlgoTrading.Data.SecurityType.EQA) || securityType.Equals(AlgoTrading.Data.SecurityType.FDO) || securityType.Equals(AlgoTrading.Data.SecurityType.FDC))
            {
                this.turnover = this.cumQty * this.avgPrice;
            }
        }
Esempio n. 4
0
 public StrategyStatistics getByAlgo(OrderAlgo algo_)
 {
     return(tradeResult[algo_]);
 }