using System;
namespace Krs.Ats.IBNet
{
///
/// Update Portfolio Event Arguments
///
[Serializable()]
public class UpdatePortfolioEventArgs : EventArgs
{
private string accountName;
private decimal averageCost;
private Contract contract;
private decimal marketPrice;
private decimal marketValue;
private int position;
private decimal realizedPnl;
private decimal unrealizedPnl;
///
/// Full Constructor
///
/// This structure contains a description of the contract which is being traded.
/// The exchange field in a contract is not set for portfolio update.
/// This integer indicates the position on the contract.
/// If the position is 0, it means the position has just cleared.
/// Unit price of the instrument.
/// The total market value of the instrument.
/// The average cost per share is calculated by dividing your cost
/// (execution price + commission) by the quantity of your position.
/// The difference between the current market value of your open positions and the average cost, or Value - Average Cost.
/// Shows your profit on closed positions, which is the difference between your entry execution cost
/// (execution price + commissions to open the position) and exit execution cost ((execution price + commissions to close the position)
/// The name of the account the message applies to. Useful for Financial Advisor sub-account messages.
public UpdatePortfolioEventArgs(Contract contract, int position, decimal marketPrice, decimal marketValue,
decimal averageCost, decimal unrealizedPnl, decimal realizedPnl, string accountName)
{
this.contract = contract;
this.accountName = accountName;
this.realizedPnl = realizedPnl;
this.unrealizedPnl = unrealizedPnl;
this.averageCost = averageCost;
this.marketValue = marketValue;
this.marketPrice = marketPrice;
this.position = position;
}
///
/// Uninitialized Constructor for Serialization
///
public UpdatePortfolioEventArgs()
{
}
///
/// This structure contains a description of the contract which is being traded.
/// The exchange field in a contract is not set for portfolio update.
///
public Contract Contract
{
get { return contract; }
set { contract = value; }
}
///
/// This integer indicates the position on the contract.
/// If the position is 0, it means the position has just cleared.
///
public int Position
{
get { return position; }
set { position = value; }
}
///
/// Unit price of the instrument.
///
public decimal MarketPrice
{
get { return marketPrice; }
set { marketPrice = value; }
}
///
/// The total market value of the instrument.
///
public decimal MarketValue
{
get { return marketValue; }
set { marketValue = value; }
}
///
/// The average cost per share is calculated by dividing your cost
/// (execution price + commission) by the quantity of your position.
///
public decimal AverageCost
{
get { return averageCost; }
set { averageCost = value; }
}
///
/// The difference between the current market value of your open positions and the average cost, or Value - Average Cost.
///
public decimal UnrealizedPnl
{
get { return unrealizedPnl; }
set { unrealizedPnl = value; }
}
///
/// Shows your profit on closed positions, which is the difference between your entry execution cost
/// (execution price + commissions to open the position) and exit execution cost ((execution price + commissions to close the position)
///
public decimal RealizedPnl
{
get { return realizedPnl; }
set { realizedPnl = value; }
}
///
/// The name of the account the message applies to. Useful for Financial Advisor sub-account messages.
///
public string AccountName
{
get { return accountName; }
set { accountName = value; }
}
}
}