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); } }
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; }
public 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.UnrealizedPNL; AccountPortfolioGrid[6, i].Value = updatePortfolioMessage.RealizedPNL; 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.UnrealizedPNL; AccountPortfolioGrid[6, AccountPortfolioGrid.Rows.Count - 1].Value = updatePortfolioMessage.RealizedPNL; }
private void HandlePortfolioValue(UpdatePortfolioMessage updatePortfolioMessage) { for (int i = 0; i < accountPortfolioGrid.Rows.Count; i++) { if (accountPortfolioGrid[0, i].Value.Equals(updatePortfolioMessage.Contract.LocalSymbol)) { accountPortfolioGrid[1, i].Value = updatePortfolioMessage.Position; accountPortfolioGrid[2, i].Value = updatePortfolioMessage.UnrealisedPNL; accountPortfolioGrid[3, i].Value = updatePortfolioMessage.RealisedPNL; return; } } accountPortfolioGrid.Rows.Add(1); accountPortfolioGrid[0, accountPortfolioGrid.Rows.Count - 1].Value = updatePortfolioMessage.Contract.LocalSymbol; accountPortfolioGrid[1, accountPortfolioGrid.Rows.Count - 1].Value = updatePortfolioMessage.Position; accountPortfolioGrid[2, accountPortfolioGrid.Rows.Count - 1].Value = updatePortfolioMessage.UnrealisedPNL; accountPortfolioGrid[3, accountPortfolioGrid.Rows.Count - 1].Value = updatePortfolioMessage.RealisedPNL; }
private void ibClient_HandlePortfolioValue(UpdatePortfolioMessage updatePortfolioMessage) { lock (_updateAccountLockObj) { for (int i = 0; i < _portfolios.Count; i++) { if (_portfolios[i].AccountName == updatePortfolioMessage.AccountName && Utils.ContractToString(_portfolios[i].Contract) == Utils.ContractToString(updatePortfolioMessage.Contract)) { _portfolios[i].Position = updatePortfolioMessage.Position; _portfolios[i].MarketPrice = updatePortfolioMessage.MarketPrice; _portfolios[i].MarketValue = updatePortfolioMessage.MarketValue; _portfolios[i].AverageCost = updatePortfolioMessage.AverageCost; _portfolios[i].UnrealizedPNL = updatePortfolioMessage.UnrealizedPNL; _portfolios[i].RealizedPNL = updatePortfolioMessage.RealizedPNL; return; } } _portfolios.Add(updatePortfolioMessage); } }
private void PortfolioInfoHandler(UpdatePortfolioMessage obj) { throw new NotImplementedException(); }