public void Update(DbExecution exec) { High = Math.Max(High, exec.Price); Low = Math.Min(Low, exec.Price); Close = exec.Price; UpdateSize(exec); _amount += exec.Price * exec.Size; if (Volume > 0m) { VWAP = Convert.ToDouble(_amount / Volume); } else { VWAP = Convert.ToDouble((Open + High + Low + Close) / 4.0m); } ExecutionCount++; if (EndExecutionId > exec.ExecutionId) { ExecutionIdOutOfOrder = true; } else { EndExecutionId = exec.ExecutionId; } }
public DbOhlc(TimeSpan frameSpan, DbExecution exec) { FrameSpan = frameSpan; Start = exec.ExecutedTime.Round(frameSpan); Open = High = Low = Close = exec.Price; UpdateSize(exec); _amount = exec.Price * exec.Size; VWAP = Convert.ToDouble(exec.Price); ExecutionCount = 1; StartExecutionId = EndExecutionId = exec.ExecutionId; ExecutionIdOutOfOrder = false; }
void UpdateSize(DbExecution exec) { switch (exec.Side) { case BfTradeSide.Buy: BuyVolume += exec.Size; break; case BfTradeSide.Sell: SellVolume += exec.Size; break; default: ExecutedVolume += exec.Size; break; } }
public void Add(DbExecution exec) => _ctxExec.Instance.Add(exec);
public void Add(DbExecution exec) => _ctx.Executions.Add(exec);