public ExtCustodianPositionRowView(ITradeableInstrument instrument, decimal size)
 {
     this.instrumentId = instrument.Key;
     this.isin = instrument.Isin;
     this.instrumentName = instrument.Name;
     this.size = size;
 }
 public ExtCustodianPositionRowView(ITradeableInstrument instrument, decimal size)
 {
     this.instrumentId   = instrument.Key;
     this.isin           = instrument.Isin;
     this.instrumentName = instrument.Name;
     this.size           = size;
 }
Esempio n. 3
0
 public static IInstrumentSymbol GetSymbol(IDalSession session, ITradeableInstrument Instrument, IExternalInterface externalInterface)
 {
     List<ICriterion> expressions = new List<ICriterion>();
     expressions.Add(Expression.Eq("Instrument.Key", Instrument.Key));
     expressions.Add(Expression.Eq("ExternalInterface", externalInterface));
     IList result = session.GetList(typeof(InstrumentSymbol), expressions);
     return (result.Count > 0) ? (IInstrumentSymbol)result[0] : null;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="T:B4F.TotalGiro.Instruments.InstrumentExchangeCollection">InstrumentExchangeCollection</see> class.
        /// </summary>
        internal InstrumentExchangeCollection(IExchange exchange, ITradeableInstrument parent)
            : base()
        {
            IInstrumentExchange ie = new InstrumentExchange(parent, exchange, Convert.ToByte(parent.DecimalPlaces));

            Add(ie);
            this.Parent = parent;
        }
Esempio n. 5
0
 public RebalanceExcludedInstrument(ITradeableInstrument instrument)
 {
     if (instrument == null)
     {
         throw new ApplicationException("The instrument can not be null");
     }
     this.Instrument = instrument;
 }
Esempio n. 6
0
 protected SecurityOrder(IAccountTypeInternal account, InstrumentSize value, ITradeableInstrument tradedInstrument, bool doNotChargeCommission)
     : base(account, value)
 {
     if (tradedInstrument == null)
     {
         throw new ApplicationException("TradedInstrument is mandatory on an order.");
     }
     this.tradedInstrument = tradedInstrument;
     this.DoNotChargeCommission = doNotChargeCommission;
     if (DoNotChargeCommission)
         this.OrderInfo = "No commission charged";
 }
Esempio n. 7
0
        public void AddInstrument(ITradeableInstrument instrument)
        {
            if (instrument == null)
            {
                throw new ApplicationException("It is not possible to map a null instrument to an assetmanager");
            }

            if (this.Where(u => u.Instrument.Key == instrument.Key).Count() > 0)
            {
                throw new ApplicationException(string.Format("The instrument {0} is already mapped to assetmanager {1}", instrument.DisplayNameWithIsin, Parent.CompanyName));
            }

            this.Add(new AssetManagerInstrument(Parent, instrument));
        }
Esempio n. 8
0
        public static IGLAccount GetSettlementDifferenceGLAccount(IDalSession session, ICurrency currency, ITradeableInstrument instrument)
        {
            IGLAccount glAccount = null;
            if (instrument.SettlementDifferenceAccount != null)
                glAccount = instrument.SettlementDifferenceAccount;
            else
            {
                List<ICriterion> expressions = new List<ICriterion>();
                expressions.Add(Expression.Eq("IsSettlementDifference", true));
                IList<IGLAccount> list = session.GetTypedList<GLAccount, IGLAccount>(expressions);
                if (list != null)
                {
                    if (list.Count == 1)
                        glAccount = list[0];
                    else if (list.Count > 1)
                        glAccount = list.Where(x => x.DefaultCurrency.Equals(currency)).FirstOrDefault();
                }
            }

            if (glAccount == null)
                throw new ApplicationException("Lookup of Settlement Difference GL Account produced no account.");
            else
                return glAccount;
        }
 public RebalanceExcludedInstrument(ITradeableInstrument instrument)
 {
     if (instrument == null)
         throw new ApplicationException("The instrument can not be null");
     this.Instrument = instrument;
 }
 internal LastValuationCashMutationHolder(IAccountTypeCustomer account, ITradeableInstrument instrument, ValuationCashTypes valuationCashType, IValuationCashMutation lastCashMutation)
 {
     this.CashMutKey = new ValuationCashMutationKey(account, instrument, valuationCashType);
     this.LastCashMutation = lastCashMutation;
 }
Esempio n. 11
0
 internal AssetManagerInstrument(IAssetManager assetManager, ITradeableInstrument instrument)
     : this()
 {
     this.AssetManager = assetManager;
     this.Instrument = instrument;
 }
Esempio n. 12
0
            public InstrumentConversionDetails(IInstrumentsHistoryConversion conv)
            {
                if (conv != null)
                {
                    this.Key = conv.Key;
                    this.Instrument = (ITradeableInstrument)conv.Instrument;
                    this.InstrumentID = conv.Instrument.Key;
                    this.NewInstrument = (ITradeableInstrument)conv.NewInstrument;
                    this.NewInstrumentID = conv.NewInstrument.Key;
                    this.OldChildRatio = conv.OldChildRatio;
                    this.NewParentRatio = conv.NewParentRatio;
                    this.IsSpinOff = conv.IsSpinOff;
                    this.ChangeDate = conv.ChangeDate;
                    this.ExecutionDate = conv.ExecutionDate;
                    this.IsExecuted = conv.IsExecuted;
                    this.IsInitialised = conv.IsInitialised;

                    if (conv.IsInitialised && conv.Conversions != null && conv.Conversions.Count > 0)
                    {
                        InstrumentSize size  = conv.Conversions.TotalOriginalSize();
                        this.TotalOriginalSize = size != null ? size.Quantity * -1M : 0M;
                        InstrumentSize newsize = conv.Conversions.TotalConvertedSize();
                        this.TotalConvertedSize = newsize != null ? newsize.Quantity : 0M;
                    }
                }
            }
Esempio n. 13
0
 public InstrumentExchange(ITradeableInstrument instrument, IExchange exchange, byte numberOfDecimals)
 {
     Instrument = instrument;
     Exchange = exchange;
     NumberOfDecimals = numberofdecimals;
 }
Esempio n. 14
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!ClientScript.IsClientScriptBlockRegistered("clientScript"))
        {
            String scriptString = "<script language=JavaScript> var _oldColor;";
            scriptString += "function SetNewColor(source) { ";
            scriptString += "_oldColor = source.style.backgroundColor;";
            scriptString += "source.style.backgroundColor = '#AAB9C2'; } ";
            scriptString += "function SetOldColor(source) { ";
            scriptString += "source.style.backgroundColor = _oldColor; }";
            scriptString += "</";
            scriptString += "script>";
            ClientScript.RegisterClientScriptBlock(this.GetType(), "clientScript", scriptString);

        }

        if (!IsPostBack)
        {
            ((EG)this.Master).setHeaderText = "Maintenance Mutual Fund";

            Session["TradeableInstrumentID"] = 33;
            // From page TradeableInstrument
            if (Session["TradeableInstrumentID"] != null)
            {
                pnlExchanges.Visible = true;

                IInstrumentExchange exchange;

                // odsExchanges parameter
                hfInstrumentID.Value = Session["TradeableInstrumentID"].ToString();
                IDalSession session = NHSessionFactory.CreateSession();
                tradInstr = InstrumentMapper.GetTradeableInstrument(session,
                        (int)Session["TradeableInstrumentID"]);
                if (tradInstr != null)
                {
                    this.InitializeInstrumentDetails();

                    exchange = (IInstrumentExchange)tradInstr.DefaultExchange;
                    if (exchange != null && exchange.Key > 0)
                    {
                        pnlExchangeDetails.Visible = true;
                        this.InitializeExchangeDetails(exchange);
                    }
                    else
                    {
                        pnlExchangeDetails.Visible = false;
                    }
                }
                session.Close();
            }
            else
            {
                pnlExchangeDetails.Visible = false;
                pnlExchanges.Visible = false;
            }

        }
    }
Esempio n. 15
0
    protected void gvExchanges_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
    {
        IList<ICurrency> currencies;
        ListItem lstItem;
        IList countries;
        string strAbbr;

        pnlExchangeDetails.Visible = true;
        Int32 dataKey = (Int32)gvExchanges.DataKeys[e.NewSelectedIndex].Value;

        IDalSession session = NHSessionFactory.CreateSession();
        tradInstr = InstrumentMapper.GetTradeableInstrument(session,
                                (int)Session["TradeableInstrumentID"]);

        if (tradInstr != null)
        {
            IInstrumentExchangeCollection collExchanges = tradInstr.InstrumentExchanges;
            IInstrumentExchange exchange = collExchanges.GetItemByExchange(dataKey);

            tbExchangeName.Text = exchange.Exchange.ExchangeName;
            tbNumberOfDecimals.Text = exchange.NumberOfDecimals.ToString();

            currencies = InstrumentMapper.GetCurrencies(session);
            ddDefaultExchangeCurrency.Items.Clear();
            ddDefaultExchangeCurrency.Items.Add(firstLstItem);

            foreach (IInstrument curr in currencies)
            {
                lstItem = new ListItem(curr.Name.ToString(), curr.Key.ToString());
                if (exchange.Exchange.DefaultCurrency != null &&
                    (exchange.Exchange.DefaultCurrency.Key == curr.Key))
                {
                    lstItem.Selected = true;
                }
                ddDefaultExchangeCurrency.Items.Add(lstItem);
            }
            ddDefaultExchangeCurrency.DataBind();

            countries = CountryMapper.GetCountries(session);
            ddDefaultExchangeCountry.Items.Clear();
            ddDefaultExchangeCountry.Items.Add(firstLstItem);
            foreach (ICountry country in countries)
            {
                if (country.CountryName.ToString().Length > 18)
                {
                    strAbbr = country.CountryName.ToString().Substring(0, 18);
                }
                else
                {
                    strAbbr = country.CountryName.ToString();
                }
                lstItem = new ListItem(strAbbr, country.Key.ToString());
                if (exchange.Exchange.DefaultCurrency != null &&
                    ((ICountry)exchange.Exchange.DefaultCountry).Key == country.Key)
                {
                    lstItem.Selected = true;
                }
                ddDefaultExchangeCountry.Items.Add(lstItem);
            }
            ddDefaultExchangeCountry.DataBind();
        }
        session.Close();
    }
Esempio n. 16
0
        public static bool ProcessBondPosition(IDalSession session, IAccountTypeInternal account, ITradeableInstrument instrument, IExchange exchange, DateTime upToDate, IGLLookupRecords lookups)
        {
            bool success = false;
            IFundPosition pos = account.Portfolio.PortfolioInstrument.Where(x => x.Instrument.Key == instrument.Key).FirstOrDefault();

            if (pos != null)
            {
                IList<IBondCouponPaymentDailyCalculation> oldCalculations = null;
                if (pos.BondCouponCalculations != null)
                    oldCalculations = pos.BondCouponCalculations
                        .Where(x => x.CalcDate > upToDate && x.Parent.Status == BondCouponPaymentStati.Settled && x.Parent.StornoBooking == null)
                        .ToList();

                IBondCouponPaymentDailyCalculation lastCalc =  pos.BondCouponPayments.Get(e => e.ActivePayment).Get(e => e.DailyCalculations).Get(e => e.LastCalculation);

                success = processBondPosition(pos, exchange, lastCalc != null ? lastCalc.CalcDate : upToDate, oldCalculations, lookups, session);
            }
            // Check for cancel
            InstrumentSize size = pos.PositionTransactions.Where(x => x.TransactionDate <= upToDate).Select(x => x.Size).Sum();
            if (size != null && size.IsZero && pos.BondCouponPayments.ActivePayment != null)
            {
                IBondCouponPayment bip = pos.BondCouponPayments.ActivePayment;
                if (Util.DateBetween(bip.CouponHistory.StartAccrualDate, bip.CouponHistory.EndAccrualDate, upToDate))
                    success = bip.Cancel();
            }
            return success;
        }
Esempio n. 17
0
        /// <summary>
        /// This method checks whether an order for this cash tx needs to be created
        /// </summary>
        /// <returns></returns>
        public bool NeedToCreateCashInitiatedOrder(out ITradeableInstrument instrument)
        {
            bool placeOrder = false;
            instrument = null;

            if (CashInitiatedOrder != null)
                throw new ApplicationException("This transaction does not need an order");

            Money orderAmount = Components.TotalAmount;
            if (Account.AccountType == AccountTypes.Customer && Account.Status == AccountStati.Active &&
                orderAmount != null && orderAmount.IsNotZero)
            {
                // check if absolutely necessary
                Money totalCash = Account.TotalCash;
                if (totalCash != null && totalCash.IsGreaterThanZero && (totalCash + orderAmount).IsGreaterThanOrEqualToZero)
                {
                    IAccountOrderCollection orders = Account.OpenOrdersForAccount.Filter(OrderTypes.AmountBased, OrderSideFilter.Buy);
                    if (orders == null || orders.Count == 0)
                        return false;
                }

                // get the instrument
                ICustomerAccount account = (ICustomerAccount)Account;
                IModelHistory modelHistory = account.ModelPortfolioChanges.GetItemByDate(this.GeneralOpsJournalEntry.TransactionDate);

                if (modelHistory == null)
                    instrument = ((IAssetManager)account.AccountOwner).CashManagementFund;
                else
                {
                    IModelVersion mv = modelHistory.ModelPortfolio.LatestVersion;
                    if (mv.ModelInstruments.Count > 0)
                        instrument = mv.GetCashFundOrAlternative();
                }

                // If instrument not null & IsTradeable -> place order for it
                if (instrument != null && instrument.IsTradeable)
                {
                    // check if there is enough the instrument
                    IFundPosition pos = Account.Portfolio.PortfolioInstrument.GetPosition(instrument);
                    if (pos != null && pos.Size.IsGreaterThanZero && ((Money)(pos.CurrentBaseValue + orderAmount)).Sign)
                    {
                        // check if an order already exists for the position
                        Money existingOrderAmt = null;
                        IAccountOrderCollection orders = account.OpenOrdersForAccount.Filter(instrument, OrderSideFilter.All);
                        if (orders != null)
                        {
                            existingOrderAmt = orders.TotalAmount();
                            if (existingOrderAmt != null && existingOrderAmt.IsNotZero)
                            {
                                if (((Money)(pos.CurrentBaseValue + orderAmount + existingOrderAmt)).Sign)
                                    placeOrder = true;
                            }
                            else
                                placeOrder = true;
                        }
                        else
                            placeOrder = true;
                    }
                    else
                    {
                        // reset instrument to null
                        instrument = null;
                    }
                }

                // If total portfolio is enough -> sell other positions
                if (!placeOrder && (Account.Portfolio.PortfolioInstrument.TotalValueInBaseCurrency + orderAmount).IsGreaterThanOrEqualToZero)
                    placeOrder = true;
            }
            return placeOrder;
        }
 private static Price getPriceForInstrument(IDalSession session, ITradeableInstrument instrument, DateTime priceDate)
 {
     return HistoricalPriceMapper.GetLastValidHistoricalPrice(session, instrument, priceDate).Price;
 }
Esempio n. 19
0
 public DividendHistoryDetails(IDividendHistory history)
 {
     if (history != null)
     {
         this.IsStockDiv = history.NeedsStockDividend;
         this.Key = history.Key;
         this.DividendType = history.DividendType;
         this.Fund = history.Instrument;
         this.FundID = history.Instrument.Key;
         this.ExDividendDate = history.ExDividendDate;
         this.SettlementDate = history.SettlementDate;
         this.UnitPrice = history.UnitPrice != null ? history.UnitPrice.Quantity : 0M;
         this.ScripRatio = history.ScripRatio;
         this.ExtDescription = history.Description;
         this.IsExecuted = history.IsExecuted;
         this.IsInitialised = history.IsInitialised;
         this.IsGelicht = history.IsGelicht;
         this.DividendTaxStyle = (int)history.TypeOfDividendTax;
         this.TaxPercentage = history.TaxPercentage;
         this.StockDivIsin = history.StockDivIsin;
         this.TotalDividendDeposited = history.TotalNumberOfUnits;
         this.TotalUnitsInPossession = this.IsStockDiv ? history.StockDividends.Get(e => e.TotalUnits).GetS(e => e.DisplayString) : history.CashDividends.Get(e => e.TotalUnits).GetS(e => e.DisplayString);
         this.TotalDividendAmount = this.IsStockDiv ? history.StockDividends.Get(e => e.TotalDividendAmount).GetS(e => e.DisplayString) : history.CashDividends.Get(e => e.TotalDividendAmount).GetS(e => e.DisplayString);
     }
 }
 public InstrumentExchangeCollection(ITradeableInstrument parent)
     : base()
 {
     Parent = parent;
 }
Esempio n. 21
0
 internal void AddReservedCash(Money amount, ITradeableInstrument cashManagementFund)
 {
     if (amount != null && amount.IsNotZero)
     {
         PositionComparer pc = getPos((IInstrument)amount.Underlying);
         if (parent.Account.BaseCurrency.Equals(amount.Underlying))
         {
             pc.ReservedCash = amount;
             if (cashManagementFund != null)
             {
                 PositionComparer pcmf = findPos(cashManagementFund);
                 if (pcmf != null)
                     pcmf.ReservedWithdrawalAmount += amount;
             }
         }
         else
             throw new ApplicationException("Not in base currency");
     }
 }
Esempio n. 22
0
 public IAssetManagerInstrument GetItemByInstrument(ITradeableInstrument instrument)
 {
     return(this.Where(u => u.Instrument.Key == instrument.Key).FirstOrDefault());
 }