суббота, 2 августа 2014 г.
воскресенье, 27 июля 2014 г.
2
var v = (from p in db.Totals.Include(t => t.Strategy)
group p by p.Strategy.Account.Code
into g
select new Position2
{
StrategyCodeEx = "All",
AccountCodeEx = g.Key,
TickerCodeEx = "All",
Quantity = g.Sum(p=>p.Quantity),
// PnL = g.Sum(p=>(short)p.Operation*p.Quantity*(p.Price2-p.Price1)),
PnL = g.Sum(p => p.Quantity * (p.Price2 - p.Price1)),
// PnL = g.Sum(p=>p.PnL),
PnL3 = g.Sum(p=>p.PnL3),
FirstTradeNumber = g.Min(p => p.FirstTradeNumber),
FirstTradeDT = g.Min(p => p.FirstTradeDT),
LastTradeNumber = g.Max(p => p.LastTradeNumber),
LastTradeDT = g.Max(p => p.LastTradeDT),
Count = g.Count()
}).ToList();
var totals = (from p in db.Totals.Include(t => t.Strategy).Where(t => t.Strategy.Code != "Default")
group p by new { AccKey = p.Strategy.Account.Key}
into g
select new Position2
{
StrategyCodeEx = g.Key.AccKey,
AccountCodeEx = g.Key.AccKey,
TickerCodeEx = "All",
Quantity = g.Sum(p => p.Quantity),
//PnL = g.Sum(p => (short)p.Operation * p.Quantity * (p.Price2 - p.Price1)),
PnL = g.Sum(p => p.Quantity * (p.Price2 - p.Price1)),
// PnL = g.Sum(p=>p.PnL),
PnL3 = g.Sum(p => p.PnL3),
FirstTradeNumber = g.Min(p => p.FirstTradeNumber),
FirstTradeDT = g.Min(p => p.FirstTradeDT),
LastTradeNumber = g.Max(p => p.LastTradeNumber),
LastTradeDT = g.Max(p => p.LastTradeDT),
Count = g.Count()
}).ToList();
var v = (from p in db.Totals.Include(t => t.Strategy)
group p by new
{
TickKey = p.Strategy.Ticker.Key,
StratKey = p.Strategy.Code,
TimeKey = p.Strategy.TimeInt
}
into g
select new Position2
{
StrategyCodeEx = g.Key.StratKey,
AccountCodeEx = "All",
TickerCodeEx = g.Key.TickKey,
TimeInt = g.Key.TimeKey,
Quantity = g.Sum(p => p.Quantity),
//PnL = g.Sum(p => (short)p.Operation * p.Quantity * (p.Price2 - p.Price1)),
//PnL = g.Sum(p => p.Quantity * (p.Price2 - p.Price1)),
PnL = g.Sum(p => p.PnL),
PnL3 = g.Sum(p => p.PnL3),
FirstTradeNumber = g.Min(p => p.FirstTradeNumber),
FirstTradeDT = g.Min(p => p.FirstTradeDT),
LastTradeNumber = g.Max(p => p.LastTradeNumber),
LastTradeDT = g.Max(p => p.LastTradeDT),
Count = g.Count()
}).ToList();
var vv = v.OrderBy(p => p.TickerCodeEx + p.StrategyCodeEx + p.TimeInt.ToString(FormatTimeInt)).ToList();
group p by p.Strategy.Account.Code
into g
select new Position2
{
StrategyCodeEx = "All",
AccountCodeEx = g.Key,
TickerCodeEx = "All",
Quantity = g.Sum(p=>p.Quantity),
// PnL = g.Sum(p=>(short)p.Operation*p.Quantity*(p.Price2-p.Price1)),
PnL = g.Sum(p => p.Quantity * (p.Price2 - p.Price1)),
// PnL = g.Sum(p=>p.PnL),
PnL3 = g.Sum(p=>p.PnL3),
FirstTradeNumber = g.Min(p => p.FirstTradeNumber),
FirstTradeDT = g.Min(p => p.FirstTradeDT),
LastTradeNumber = g.Max(p => p.LastTradeNumber),
LastTradeDT = g.Max(p => p.LastTradeDT),
Count = g.Count()
}).ToList();
var totals = (from p in db.Totals.Include(t => t.Strategy).Where(t => t.Strategy.Code != "Default")
group p by new { AccKey = p.Strategy.Account.Key}
into g
select new Position2
{
StrategyCodeEx = g.Key.AccKey,
AccountCodeEx = g.Key.AccKey,
TickerCodeEx = "All",
Quantity = g.Sum(p => p.Quantity),
//PnL = g.Sum(p => (short)p.Operation * p.Quantity * (p.Price2 - p.Price1)),
PnL = g.Sum(p => p.Quantity * (p.Price2 - p.Price1)),
// PnL = g.Sum(p=>p.PnL),
PnL3 = g.Sum(p => p.PnL3),
FirstTradeNumber = g.Min(p => p.FirstTradeNumber),
FirstTradeDT = g.Min(p => p.FirstTradeDT),
LastTradeNumber = g.Max(p => p.LastTradeNumber),
LastTradeDT = g.Max(p => p.LastTradeDT),
Count = g.Count()
}).ToList();
var v = (from p in db.Totals.Include(t => t.Strategy)
group p by new
{
TickKey = p.Strategy.Ticker.Key,
StratKey = p.Strategy.Code,
TimeKey = p.Strategy.TimeInt
}
into g
select new Position2
{
StrategyCodeEx = g.Key.StratKey,
AccountCodeEx = "All",
TickerCodeEx = g.Key.TickKey,
TimeInt = g.Key.TimeKey,
Quantity = g.Sum(p => p.Quantity),
//PnL = g.Sum(p => (short)p.Operation * p.Quantity * (p.Price2 - p.Price1)),
//PnL = g.Sum(p => p.Quantity * (p.Price2 - p.Price1)),
PnL = g.Sum(p => p.PnL),
PnL3 = g.Sum(p => p.PnL3),
FirstTradeNumber = g.Min(p => p.FirstTradeNumber),
FirstTradeDT = g.Min(p => p.FirstTradeDT),
LastTradeNumber = g.Max(p => p.LastTradeNumber),
LastTradeDT = g.Max(p => p.LastTradeDT),
Count = g.Count()
}).ToList();
var vv = v.OrderBy(p => p.TickerCodeEx + p.StrategyCodeEx + p.TimeInt.ToString(FormatTimeInt)).ToList();
1
http://msdn.microsoft.com/ru-ru/library/ybsdta26(v=vs.110).aspx
http://www.dotnetperls.com/openfiledialog
http://www.dotnetperls.com/split
http://code.msdn.microsoft.com/101-LINQ-Samples-3fb9811b
private void button1_Click(object sender, EventArgs e)
{
int size = -1;
DialogResult result = openFileDialog1.ShowDialog(); // Show the dialog.
if (result == DialogResult.OK) // Test result.
{
string file = openFileDialog1.FileName;
try
{
string text = File.ReadAllText(file);
size = text.Length;
}
catch (IOException)
{
}
}
Console.WriteLine(size); // <-- Shows file size in debugging mode.
Console.WriteLine(result); // <-- For debugging use.
}
http://stackoverflow.com/questions/7387085/how-to-read-an-entire-file-to-a-string-using-c-sharp
string readContents;
using (StreamReader streamReader = new StreamReader(path, Encoding.UTF8))
{
readContents = streamReader.ReadToEnd();
}
public partial class Form1 : Form
{
//private PortfolioViewForm _pvForm ;
private PortfolioManagerForm2 _pmForm;
private readonly PortfolioManager _pm;
public Form1()
{
InitializeComponent();
_pm = PortfolioManager.Instance;
}
private void Form1_Load(object sender, EventArgs e)
{
_pmForm = new PortfolioManagerForm2(_pm);
_pmForm.Show();
}
private void btnSelectFile_Click(object sender, EventArgs e)
{
int size = -1;
DialogResult result = openFileDialog1.ShowDialog(); // Show the dialog.
if (result == DialogResult.OK) // Test result.
{
string file = openFileDialog1.FileName;
try
{
string text = File.ReadAllText(file);
size = text.Length;
txtFileSelected.Text = file;
//var sr = new StringReader(text);
//var lst = new List<string>();
//string str = string.Empty;
//while ((str = sr.ReadLine()) != null)
//{
// lst.Add(str);
//}
//listFileLines.DataSource = lst;
string readContents;
var lst = new List<string>();
using (var streamReader = new StreamReader(file, Encoding.UTF8))
{
//readContents = streamReader.ReadToEnd();
while (!streamReader.EndOfStream)
{
//lst.Add(streamReader.ReadLine());
var s = streamReader.ReadLine();
if (s != null) listFileLines.Items.Add(s);
}
}
//listFileLines.DataSource = lst;
}
catch (IOException)
{
}
}
}
}
воскресенье, 1 июня 2014 г.
воскресенье, 18 мая 2014 г.
Подписаться на:
Сообщения (Atom)