private static string PrepareTooltip(KeyValuePair <DateTime, IPosition> node, int curBar, PositionGridDisplayMode mode) { string res; IPosition pos = node.Value; switch (mode) { case PositionGridDisplayMode.Iv: res = "-"; // Как у Алексея сделано if (pos.Security.SecurityDescription.IsOption) { res = "na"; } break; case PositionGridDisplayMode.Px: res = pos.GetBalancePrice(curBar).ToString(CultureInfo.InvariantCulture); break; case PositionGridDisplayMode.Dir: res = pos.IsLong ? "Long" : "Short"; break; case PositionGridDisplayMode.Qty: res = pos.Shares.ToString(CultureInfo.InvariantCulture); break; case PositionGridDisplayMode.Symbol: res = pos.Security.Symbol; break; case PositionGridDisplayMode.IsVirtual: res = pos.IsVirtual.ToString(CultureInfo.InvariantCulture); break; default: res = "Mode '" + mode + "' is not implemented."; break; } return(res); }
private static double PrepareValue(KeyValuePair <DateTime, IPosition> node, int curBar, PositionGridDisplayMode mode) { double res; IPosition pos = node.Value; switch (mode) { //case PositionGridDisplayMode.Iv: // res = "Not implemented"; // break; case PositionGridDisplayMode.Px: res = pos.GetBalancePrice(curBar); break; case PositionGridDisplayMode.Qty: int sign = pos.IsLong ? 1 : -1; res = sign * Math.Abs(pos.Shares); break; //case PositionGridDisplayMode.Symbol: // res = pos.Security.Symbol; // break; default: res = Constants.NaN; break; } return(res); }