コード例 #1
0
        public void HandlePosition(UpdatePortfolioMessage positionMessage)
        {
            if (positionMessage.Contract.SecType.Equals("OPT"))
            {
                for (int i = 0; i < positionsGrid.Rows.Count; i++)
                {
                    if (positionsGrid[POS_CONTRACT_IDX, i].Value.Equals(Utils.ContractToString(positionMessage.Contract)))
                    {
                        positionsGrid[POS_ACCOUNT_IDX, i].Value = positionMessage.AccountName;
                        positionsGrid[POS_POSITION_IDX, i].Value = positionMessage.Position;
                        positionsGrid[POS_MARKET_PRICE_IDX, i].Value = positionMessage.MarketPrice;
                        positionsGrid[POS_MARKET_VALUE_IDX, i].Value = positionMessage.MarketValue;
                        positionsGrid[POS_AVG_COST_IDX, i].Value = positionMessage.AverageCost;
                        positionsGrid[POS_UNREALISED_PNL_IDX, i].Value = positionMessage.UnrealisedPNL;
                        positionsGrid[POS_REALISED_PNL_IDX, i].Value = positionMessage.RealisedPNL;
                        return;
                    }
                }

                positionsGrid.Rows.Add(1);
                positionsGrid[0, positionsGrid.Rows.Count - 1].Value = Utils.ContractToString(positionMessage.Contract);
                positionsGrid[1, positionsGrid.Rows.Count - 1].Value = positionMessage.AccountName;
                positionsGrid[2, positionsGrid.Rows.Count - 1].Value = positionMessage.Position;
                positionsGrid[3, positionsGrid.Rows.Count - 1].Value = positionMessage.AverageCost;
                currentOptionsPositions.Add(positionMessage.Contract);
            }
        }
コード例 #2
0
ファイル: AccountManager.cs プロジェクト: sergiovvfm/trading
 private void HandlePortfolioValue(UpdatePortfolioMessage updatePortfolioMessage)
 {
     
     for (int i = 0; i < accountPortfolioGrid.Rows.Count; i++)
     {
         if (accountPortfolioGrid[0, i].Value.Equals(Utils.ContractToString(updatePortfolioMessage.Contract)))
         {
             accountPortfolioGrid[1, i].Value = updatePortfolioMessage.Position;
             accountPortfolioGrid[2, i].Value = updatePortfolioMessage.MarketPrice;
             accountPortfolioGrid[3, i].Value = updatePortfolioMessage.MarketValue;
             accountPortfolioGrid[4, i].Value = updatePortfolioMessage.AverageCost;
             accountPortfolioGrid[5, i].Value = updatePortfolioMessage.UnrealisedPNL;
             accountPortfolioGrid[6, i].Value = updatePortfolioMessage.RealisedPNL;
             return;
         }
     }
     
     accountPortfolioGrid.Rows.Add(1);
     accountPortfolioGrid[0, accountPortfolioGrid.Rows.Count - 1].Value = Utils.ContractToString(updatePortfolioMessage.Contract); ;
     accountPortfolioGrid[1, accountPortfolioGrid.Rows.Count - 1].Value = updatePortfolioMessage.Position;
     accountPortfolioGrid[2, accountPortfolioGrid.Rows.Count - 1].Value = updatePortfolioMessage.MarketPrice;
     accountPortfolioGrid[3, accountPortfolioGrid.Rows.Count - 1].Value = updatePortfolioMessage.MarketValue;
     accountPortfolioGrid[4, accountPortfolioGrid.Rows.Count - 1].Value = updatePortfolioMessage.AverageCost;
     accountPortfolioGrid[5, accountPortfolioGrid.Rows.Count - 1].Value = updatePortfolioMessage.UnrealisedPNL;
     accountPortfolioGrid[6, accountPortfolioGrid.Rows.Count - 1].Value = updatePortfolioMessage.RealisedPNL;
 }