Example #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, PositionImpl> poslist = new Dictionary <string, PositionImpl>();
            Dictionary <string, decimal>      ptlist  = new Dictionary <string, decimal>();

            if (!MasterTrades.ContainsKey(account.ID))
            {
                return(0);
            }
            List <Trade> trades = MasterTrades[account.ID];

            for (int i = 0; i < trades.Count; i++)
            {
                Trade trade = trades[i];
                if (!poslist.ContainsKey(trade.symbol))
                {
                    poslist.Add(trade.symbol, new PositionImpl(trade.symbol));
                    ptlist.Add(trade.symbol, 0);
                }
                ptlist[trade.symbol] += Calc.ClosePT(poslist[trade.symbol], trade);
                poslist[trade.symbol].Adjust(trade);
            }
            decimal points = 0;

            string[] syms = new string[ptlist.Count];
            ptlist.Keys.CopyTo(syms, 0);
            for (int i = 0; i < syms.Length; i++)
            {
                points += ptlist[syms[i]];
            }
            return(points);
        }
Example #2
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, PositionImpl> poslist = new Dictionary <string, PositionImpl>();
            Dictionary <string, decimal>      ptlist  = new Dictionary <string, decimal>();

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

            foreach (string sym in ptlist.Keys)
            {
                points += ptlist[sym];
            }
            return(points);
        }
Example #3
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)
        {
            PositionImpl pos    = new PositionImpl(symbol);
            decimal      points = 0;

            if (!MasterTrades.ContainsKey(account.ID))
            {
                return(points);
            }
            foreach (TradeImpl t in MasterTrades[account.ID])
            {
                points += Calc.ClosePT(pos, t);
                pos.Adjust(t);
            }
            return(points);
        }
Example #4
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)
        {
            PositionImpl pos    = new PositionImpl(symbol);
            decimal      points = 0;

            if (!MasterTrades.ContainsKey(account.ID))
            {
                return(points);
            }
            List <Trade> trades = MasterTrades[account.ID];

            for (int i = 0; i < trades.Count; i++)
            {
                points += Calc.ClosePT(pos, trades[i]);
                pos.Adjust(trades[i]);
            }
            return(points);
        }