예제 #1
0
 void DisplayResults(Results r)
 {
     dt.Clear();
     Type t = r.GetType();
     FieldInfo[] fis = t.GetFields();
     foreach (FieldInfo fi in fis)
     {
         string format = null;
         if (fi.GetType() == typeof(Decimal)) format = "N2";
         dt.Rows.Add(fi.Name, (format!=null) ? string.Format(format,fi.GetValue(r)) : fi.GetValue(r).ToString());
     }
     PropertyInfo[] pis = t.GetProperties();
     foreach (PropertyInfo pi in pis)
     {
         string format = null;
         if (pi.GetType() == typeof(Decimal)) format = "N2";
         dt.Rows.Add(pi.Name, (format!=null) ? string.Format(format, pi.GetValue(r,null)) : pi.GetValue(r,null).ToString());
     }
 }
예제 #2
0
        Results FetchResults(string name)
        {
            if (name == null) return new Results();
            StreamReader sr = new StreamReader(fw.Path +@"\"+ name);
            sr.ReadLine();
            Results r = new Results();
            while (!sr.EndOfStream)
            {
                TradeResult tr = TradeResult.Init(sr.ReadLine());
                if (!r.SymbolsTraded.Contains(tr.Source.symbol))
                    r.SymbolsTraded += tr.Source.symbol + ",";
                r.Trades++;
                r.HundredLots += (int)(tr.Source.xsize / 100);
                r.GrossPL += tr.ClosedPL;
                if (tr.ClosedPL>0) r.Winners++;
                if (tr.ClosedPL < 0) r.Losers++;
                if ((tr.OpenSize == 0) && (tr.ClosedPL == 0)) r.Flats++;
                if (tr.ClosedPL > r.MaxWin) r.MaxWin = tr.ClosedPL;
                if (tr.ClosedPL < r.MaxLoss) r.MaxLoss = tr.ClosedPL;
                if (tr.OpenPL > r.MaxOpenWin) r.MaxOpenWin = tr.OpenPL;
                if (tr.OpenPL < r.MaxOpenLoss) r.MaxOpenLoss = tr.OpenPL;
            }
            sr.Close();
            return r;

        }