private string NewStra(string pInst1, string pInst2, DirectionType pDire, OffsetType pOffset, double pPrice, double pRate1, double pRate2, int pVol1, int pVol2, bool pIsMarket) { Stra stra = new Stra { StraID = _maxStraID++.ToString(CultureInfo.InvariantCulture), Instrument1 = pInst1, Instrument2 = pInst2, Direction = pDire, Offset = pOffset, Price = pPrice, Rate1 = pRate1, Rate2 = pRate2, Volume1 = pVol1, Volume2 = pVol2, Status = ArbStatus.NotTouch, IsMarket = pIsMarket, }; if (_dicStra.TryAdd(stra.StraID, stra)) { DataRow dr = _dt.NewRow(); foreach (FieldInfo fi in typeof(Stra).GetFields()) { dr[fi.Name] = fi.GetValue(stra); } _dt.Rows.Add(dr); string txt = _dicStra.Aggregate(string.Empty, (current1, vi) => vi.GetType().GetFields().Aggregate(current1, (current, fi) => current + (fi.GetValue(vi) + ",")).TrimEnd(',') + "\r\n"); File.WriteAllText(this.GetType().Name + ".txt", txt); } return(stra.StraID); }
private string NewStra(string pInst1, string pInst2, DirectionType pDire, OffsetType pOffset, double pPrice, double pRate1, double pRate2, int pVol1, int pVol2, bool pIsMarket) { Stra stra = new Stra { StraID = _maxStraID++.ToString(CultureInfo.InvariantCulture), Instrument1 = pInst1, Instrument2 = pInst2, Direction = pDire, Offset = pOffset, Price = pPrice, Rate1 = pRate1, Rate2 = pRate2, Volume1 = pVol1, Volume2 = pVol2, Status = ArbStatus.NotTouch, IsMarket = pIsMarket, }; if (_dicStra.TryAdd(stra.StraID, stra)) { DataRow dr = _dt.NewRow(); foreach (FieldInfo fi in typeof(Stra).GetFields()) dr[fi.Name] = fi.GetValue(stra); _dt.Rows.Add(dr); string txt = _dicStra.Aggregate(string.Empty, (current1, vi) => vi.GetType().GetFields().Aggregate(current1, (current, fi) => current + (fi.GetValue(vi) + ",")).TrimEnd(',') + "\r\n"); File.WriteAllText(this.GetType().Name + ".txt", txt); } return stra.StraID; }