コード例 #1
0
ファイル: Position.cs プロジェクト: lynxliu/Backtesting
        public object Clone()
        {
            var info = new Position();

            info.InstrumentName   = InstrumentName;
            info.InstrumentTicker = InstrumentTicker;
            info.CurrentPrice     = CurrentPrice;
            //ChangeList.ForEach(v => info.ChangeList.Add(v.GetData()));
            info.CreateTime   = CreateTime;
            info.DataTime     = DataTime;
            info.CurrentPrice = CurrentPrice;

            info.Shares   = Shares;
            info.Margin   = Margin;
            info.MaxPrice = MaxPrice;
            info.MinPrice = MinPrice;
            TradeTrace.ForEach(v => { info.TradeTrace.Add(v.Clone() as ITrade); });

            return(info);
        }
コード例 #2
0
ファイル: Position.cs プロジェクト: lynxliu/Backtesting
 public void ProcessOrder(IOrder order)
 {
     if (order.Ticker != InstrumentTicker)
     {
         return;
     }
     //ChangeList.Add(new PositionModify() { ModifyCash = order.CashFlow, ModifyShares = order.Shares * order.GetOrderDirection() });
     Shares += order.Shares * order.GetOrderDirection();
     TradeTrace.Add(new Trade()
     {
         Ticker   = InstrumentTicker,
         Name     = InstrumentName,
         Currency = CurrentCurrency,
         Memo     = order.Comment,
         Owner    = order.Owner,
         Price    = order.Price,
         Shares   = Shares,
         Time     = order.SettleTime
     });
     RefreshCost();
 }
コード例 #3
0
ファイル: Position.cs プロジェクト: lynxliu/Backtesting
 void RefreshCost()
 {
     Cost = TradeTrace.Sum(v => v.Price * v.Shares) / Shares;
 }