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();