/// <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); }
/// <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); }
/// <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); }
/// <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); }