/// <summary> /// Creates the account information message for a portfolio /// </summary> /// <param name="portfolioid">The portfolio id.</param> /// <param name="accountid">The account id.</param> /// <param name="values">The values.</param> /// <param name="currency">The currency.</param> /// <param name="displaycurrency">The display currency.</param> /// <param name="fundid"></param> /// <returns></returns> public static AccountInfoMessage Create(string portfolioid, string accountid, CalculatedFunds values, Currency currency, CurrencyType displaycurrency, string fundid = "") { if (displaycurrency == values.BaseCurrency) { //Return generated object return new AccountInfoMessage { PorfoltioId = portfolioid, Values = values, AccountId = accountid, FundId = fundid } } ; else { //Return currency adjusted values return(new AccountInfoMessage { PorfoltioId = portfolioid, Values = values.ConvertCurrency(currency, displaycurrency), AccountId = accountid, FundId = fundid }); } }
/// <summary> /// Create position info message instance /// </summary> /// <param name="fundid"></param> /// <param name="pos"></param> /// <param name="universe"></param> /// <param name="funds"></param> /// <returns></returns> public static PositionInfoMessage Create(string fundid, Position pos, Universe universe, CalculatedFunds funds) { return(new PositionInfoMessage { AveragePrice = pos.AveragePrice, Currency = pos.Security.BaseCurrency, CurrentPrice = pos.CurrentPrice, Direction = pos.Direction, FundId = fundid, LastModifiedUtc = pos.LastModifiedUtc, MarginInUse = pos.MarginInUse, NetProfit = pos.NetProfit, Quantity = pos.Quantity, Ticker = pos.Security.Ticker.Name, CurrentWeight = pos.TotalValue / funds.Equity, UniverseWeight = universe.GetWeight(pos.Security) }); }