예제 #1
0
 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;
     }
 }
예제 #2
0
 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;
 }
예제 #3
0
        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;
            }
        }
예제 #4
0
 public void Add(DbExecution exec) => _ctxExec.Instance.Add(exec);
 public void Add(DbExecution exec) => _ctx.Executions.Add(exec);