コード例 #1
0
        /// <summary>
        /// Gets the closed Points on a specific account, all symbols.
        /// </summary>
        /// <param name="account">The account.</param>
        /// <returns></returns>
        public decimal GetClosedPT(Account account)
        {
            Dictionary <string, Position> poslist = new Dictionary <string, Position>();
            Dictionary <string, decimal>  ptlist  = new Dictionary <string, decimal>();

            if (!MasterTrades.ContainsKey(account.ID))
            {
                return(0);
            }
            foreach (Trade trade in MasterTrades[account.ID])
            {
                if (!poslist.ContainsKey(trade.symbol))
                {
                    poslist.Add(trade.symbol, new Position(trade.symbol));
                    ptlist.Add(trade.symbol, 0);
                }
                ptlist[trade.symbol] += BoxMath.ClosePT(poslist[trade.symbol], trade);
                poslist[trade.symbol].Adjust(trade);
            }
            decimal points = 0;

            foreach (string sym in ptlist.Keys)
            {
                points += ptlist[sym];
            }
            return(points);
        }
コード例 #2
0
        /// <summary>
        /// Gets the closed points (points = PL on per-share basis) for given symbol/account.
        /// </summary>
        /// <param name="symbol">The symbol.</param>
        /// <param name="account">The account.</param>
        /// <returns>points</returns>
        public decimal GetClosedPT(string symbol, Account account)
        {
            Position pos    = new Position(symbol);
            decimal  points = 0;

            if (!MasterTrades.ContainsKey(account.ID))
            {
                return(points);
            }
            foreach (Trade t in MasterTrades[account.ID])
            {
                points += BoxMath.ClosePT(pos, t);
                pos.Adjust(t);
            }
            return(points);
        }