コード例 #1
0
        internal GLAccountBalanceItem(MasterDataIdentity_GLAccount glAccount)
        {
            _glAccount = glAccount;
            _list = new Dictionary<MonthIdentity, CurrencyAmount>();
            _sum = new CurrencyAmount();

        }
コード例 #2
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="coreDriver"></param>
        /// <param name="management"></param>
        /// <param name="id"></param>
        /// <param name="descp"></param>
        /// <param name="bankAccount"></param>
        /// <exception cref="ArgumentNullException">Argument is null.</exception>
        /// <exception cref="NoGLAccountGroupException">No such G\L account group exception</exception>
        public GLAccountMasterData(CoreDriver coreDriver,
                MasterDataManagement management, MasterDataIdentity_GLAccount id,
                String descp, MasterDataIdentity bankAccount)
            : base(coreDriver, management, id, descp)
        {
            // check id and get group
            String groupId = id.ToString().Substring(0, 4);
            try
            {
                _group = GLAccountGroup.Parse(groupId);
            }
            catch (GLAccountGroupFormatException)
            {
                throw new NoGLAccountGroupException(groupId);
            }

            if (bankAccount == null)
            {
                _bankAccount = null;
            }
            else
            {
                MasterDataBase bankAccountId = _management.GetMasterData(
                        bankAccount, MasterDataType.BANK_ACCOUNT);
                if (bankAccountId == null)
                {
                    throw new MasterDataIdentityNotDefined(bankAccount,
                            MasterDataType.BANK_ACCOUNT);
                }
                _bankAccount = bankAccountId.GetIdentity();
            }

            // init amount
            _initAmount = new CurrencyAmount();
        }
コード例 #3
0
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="coreDriver"></param>
 /// <param name="id"></param>
 /// <param name="type"></param>
 internal DocumentIndexItemWithBalance(CoreDriver coreDriver, MasterDataIdentity id,
         MasterDataType type)
     : base(coreDriver, id)
 {
     _type = type;
     _sum = new CurrencyAmount();
 }
コード例 #4
0
        private void glAccountInitAmountChanged(MasterDataIdentity_GLAccount glAccountId
            , CurrencyAmount orgAmount, CurrencyAmount newAmount)
        {
            GLAccountBalanceItem item;
            if (!_items.TryGetValue(glAccountId, out item))
            {
                return;
            }

            // ret += newAmount - orgAmount
            item.AddAmount(_coreDriver.StartMonthId
                , CurrencyAmount.Minus(newAmount, orgAmount));
        }
コード例 #5
0
        /// <summary>
        /// Get sum of amount from start month to end month
        /// </summary>
        /// <param name="startId">id of start month</param>
        /// <param name="endId">id of end month</param>
        /// <returns></returns>
        public CurrencyAmount GetSumAmount(MonthIdentity startId,
                MonthIdentity endId)
        {
            CurrencyAmount sum = new CurrencyAmount();
            foreach (var item in _list)
            {
                if (item.Key.CompareTo(startId) >= 0 && item.Key.CompareTo(endId) <= 0)
                {
                    sum.AddTo(item.Value);
                }
            }

            return sum;
        }
コード例 #6
0
        public VendorEntry(CoreDriver coreDriver, MasterDataManagement mdMgmt)
        {
            _coreDriver = coreDriver;
            _mdMgmt = mdMgmt;
            _text = "";

            _recAcc = null;
            _glAccount = null;
            _vendor = null;
            _amount = new CurrencyAmount();
            _businessArea = null;

            _doc = null;
        }
コード例 #7
0
        /// <summary>
        /// Add amount 
        /// </summary>
        /// <param name="monthId"></param>
        /// <param name="amount"></param>
        internal void AddAmount(MonthIdentity monthId, CurrencyAmount amount)
        {
            _sum.AddTo(amount);

            if (_list.ContainsKey(monthId))
            {
                CurrencyAmount sum;
                _list.TryGetValue(monthId, out sum);
                sum.AddTo(amount);
            }
            else
            {
                _list.Add(monthId, new CurrencyAmount(amount));
            }
        }
コード例 #8
0
        public static void CheckAccountBalance(CoreDriver coreDriver)
        {
            TransactionDataManagement transMgmt = coreDriver.TransMgmt;
            GLAccountBalanceCollection balCol = transMgmt.AccountBalanceCol;

            MonthIdentity month07 = new MonthIdentity(2012, 7);
            MonthIdentity month08 = new MonthIdentity(2012, 8);

            MasterDataIdentity_GLAccount glAccount2 = new MasterDataIdentity_GLAccount(
                    TestData.GL_ACCOUNT_CASH);
            GLAccountBalanceItem balItem = balCol.GetBalanceItem(glAccount2);
            CurrencyAmount amount2 = new CurrencyAmount(123.45 - 23.45);
            Assert.AreEqual(amount2, balItem.Sum);
            Assert.AreEqual(amount2, balItem.GetAmount(month07));
            Assert.AreEqual(new CurrencyAmount(), balItem.GetAmount(month08));

            Assert.AreEqual(amount2, balCol.GetGroupBalance(GLAccountGroupENUM.CASH));
            Assert.AreEqual(amount2,
                    balCol.GetGroupBalance(GLAccountGroupENUM.CASH, month07, month07));
            Assert.AreEqual(new CurrencyAmount(),
                    balCol.GetGroupBalance(GLAccountGroupENUM.CASH, month08, month08));

            // cost
            Assert.AreEqual(new CurrencyAmount(123.45),
                    balCol.GetGroupBalance(GLAccountGroupENUM.COST_PURE));
            Assert.AreEqual(new CurrencyAmount(123.45), balCol.GetGroupBalance(
                    GLAccountGroupENUM.COST_PURE, month07, month07));
            Assert.AreEqual(new CurrencyAmount(), balCol.GetGroupBalance(
                    GLAccountGroupENUM.COST_PURE, month08, month08));

            // revenue
            Assert.AreEqual(new CurrencyAmount(-543.21),
                    balCol.GetGroupBalance(GLAccountGroupENUM.SALARY));
            Assert.AreEqual(new CurrencyAmount(-543.21),
                    balCol.GetGroupBalance(GLAccountGroupENUM.SALARY, month07, month07));
            Assert.AreEqual(new CurrencyAmount(),
                    balCol.GetGroupBalance(GLAccountGroupENUM.SALARY, month08, month08));
        }
コード例 #9
0
        /// <summary>
        /// get amount
        /// </summary>
        /// <param name="monthID"></param>
        /// <returns></returns>
        public CurrencyAmount getAmount(MonthIdentity monthID)
        {
            CurrencyAmount sum = new CurrencyAmount();
            CurrencyAmount amount;
            if (_amountList.TryGetValue(monthID, out amount))
            {
                sum.AddTo(amount);
            }

            return sum;
        }
コード例 #10
0
 /// <summary>
 /// Method which notificate national bank(print in coslole) when amount of transaction exceed 25000MKD
 /// </summary>
 /// <param name="account">acount</param>
 /// <param name="transactionType">transaction type</param>
 /// <param name="amount">amount</param>
 public static void NotifyNationalBank(IAccount account, TransactionType transactionType, CurrencyAmount amount)
 {
     if (amount.Amount > 25000 && amount.Currency.Equals("MKD"))
     {
         string result = string.Format("*NOTIFICATE NATIONAL BANK*  Account Number:{0} | Transaction Type:{1} | Amount:{2} | Currency:{3}", account.Number, transactionType, amount.Amount, amount.Currency);
         Console.WriteLine(result);
     }
 }
コード例 #11
0
        // create an FX Swap trade
        private static Trade createTrade3()
        {
            FxSwap swap = FxSwap.ofForwardPoints(CurrencyAmount.of(GBP, 10000), FxRate.of(GBP, USD, 1.62), 0.03, LocalDate.of(2014, 6, 14), LocalDate.of(2014, 9, 14));

            return(FxSwapTrade.builder().product(swap).info(TradeInfo.builder().id(StandardId.of("example", "3")).addAttribute(AttributeType.DESCRIPTION, "GBP 10,000/USD @ 1.62 swap").counterparty(StandardId.of("example", "BigBankA")).settlementDate(LocalDate.of(2014, 9, 15)).build()).build());
        }
コード例 #12
0
        //-------------------------------------------------------------------------
        /// <summary>
        /// Runs the calibration of SABR on swaptions and print on the console the present value, bucketed PV01 and
        /// the bucketed Vega of a 18M x 4Y swaption.
        /// </summary>
        /// <param name="args">  -s to use the spares data </param>
        public static void Main(string[] args)
        {
            long start, end;

            // Swaption description
            BuySell          payer            = BuySell.BUY;
            Period           expiry           = Period.ofMonths(18);
            double           notional         = 1_000_000;
            double           strike           = 0.0100;
            Tenor            tenor            = Tenor.TENOR_4Y;
            LocalDate        expiryDate       = EUR_FIXED_1Y_EURIBOR_6M.FloatingLeg.StartDateBusinessDayAdjustment.adjust(CALIBRATION_DATE.plus(expiry), REF_DATA);
            SwapTrade        underlying       = EUR_FIXED_1Y_EURIBOR_6M.createTrade(expiryDate, tenor, payer, notional, strike, REF_DATA);
            Swaption         swaption         = Swaption.builder().expiryDate(AdjustableDate.of(expiryDate)).expiryTime(LocalTime.of(11, 0x0)).expiryZone(ZoneId.of("Europe/Berlin")).underlying(underlying.Product).longShort(LongShort.LONG).swaptionSettlement(PhysicalSwaptionSettlement.DEFAULT).build();
            ResolvedSwaption resolvedSwaption = swaption.resolve(REF_DATA);

            // select data
            TenorRawOptionData data = DATA_FULL;

            if (args.Length > 0)
            {
                if (args[0].Equals("-s"))
                {
                    data = DATA_SPARSE;
                }
            }

            start = DateTimeHelper.CurrentUnixTimeMillis();
            // Curve calibration
            RatesProvider multicurve = CALIBRATOR.calibrate(CONFIGS, MARKET_QUOTES, REF_DATA);

            end = DateTimeHelper.CurrentUnixTimeMillis();
            Console.WriteLine("Curve calibration time: " + (end - start) + " ms.");

            // SABR calibration
            start = DateTimeHelper.CurrentUnixTimeMillis();
            double          beta                    = 0.50;
            SurfaceMetadata betaMetadata            = DefaultSurfaceMetadata.builder().xValueType(ValueType.YEAR_FRACTION).yValueType(ValueType.YEAR_FRACTION).zValueType(ValueType.SABR_BETA).surfaceName("Beta").build();
            Surface         betaSurface             = ConstantSurface.of(betaMetadata, beta);
            double          shift                   = 0.0300;
            Surface         shiftSurface            = ConstantSurface.of("SABR-Shift", shift);
            SabrParametersSwaptionVolatilities sabr = SABR_CALIBRATION.calibrateWithFixedBetaAndShift(DEFINITION, CALIBRATION_TIME, data, multicurve, betaSurface, shiftSurface);

            end = DateTimeHelper.CurrentUnixTimeMillis();
            Console.WriteLine("SABR calibration time: " + (end - start) + " ms.");

            // Price and risk
            Console.WriteLine("Risk measures: ");
            start = DateTimeHelper.CurrentUnixTimeMillis();
            CurrencyAmount pv = SWAPTION_PRICER.presentValue(resolvedSwaption, multicurve, sabr);

            Console.WriteLine("  |-> PV: " + pv.ToString());

            PointSensitivities             deltaPts      = SWAPTION_PRICER.presentValueSensitivityRatesStickyModel(resolvedSwaption, multicurve, sabr).build();
            CurrencyParameterSensitivities deltaBucketed = multicurve.parameterSensitivity(deltaPts);

            Console.WriteLine("  |-> Delta bucketed: " + deltaBucketed.ToString());

            PointSensitivities vegaPts = SWAPTION_PRICER.presentValueSensitivityModelParamsSabr(resolvedSwaption, multicurve, sabr).build();

            Console.WriteLine("  |-> Vega point: " + vegaPts.ToString());

            CurrencyParameterSensitivities vegaBucketed = sabr.parameterSensitivity(vegaPts);

            for (int i = 0; i < vegaBucketed.size(); i++)
            {
                Console.WriteLine("  |-> Vega bucketed: " + vegaBucketed.Sensitivities.get(i));
            }

            end = DateTimeHelper.CurrentUnixTimeMillis();
            Console.WriteLine("PV and risk time: " + (end - start) + " ms.");
        }
コード例 #13
0
        public virtual void test_currentCash_onPay()
        {
            CurrencyAmount computed = LEG_PRICER.currentCash(COUPON_LEG, RATES_PROVIDER_ON_PAY);

            assertEquals(computed.Amount, -NOTIONAL_VALUE_1 * OBS_INDEX * 367d / 360d, TOLERANCE_PV);
        }
コード例 #14
0
        /// <summary>
        /// set value
        /// </summary>
        /// <param name="fieldName"></param>
        /// <param name="value"></param>
        /// <exception cref="NoFieldNameException">No such field name</exception>
        /// <exception cref="NotInValueRangeException">The value is not supported</exception>
        public void SetValue(String fieldName, Object value)
        {
            if (_isSaved)
            {
                return;
            }

            if (value == null)
            {
                throw new NotInValueRangeException(fieldName, "");
            }

            if (fieldName.Equals(VENDOR))
            {
                if (!(value is MasterDataIdentity))
                {
                    throw new NotInValueRangeException(fieldName, value);
                }
                MasterDataIdentity vendor = (MasterDataIdentity)value;
                setVendor(vendor);
            }
            else if (fieldName.Equals(GL_ACCOUNT))
            {
                if (!(value is MasterDataIdentity_GLAccount))
                {
                    throw new NotInValueRangeException(fieldName, value);
                }
                MasterDataIdentity_GLAccount glAccount = (MasterDataIdentity_GLAccount)value;
                setGLAccount(glAccount);
            }
            else if (fieldName.Equals(REC_ACC))
            {
                if (!(value is MasterDataIdentity_GLAccount))
                {
                    throw new NotInValueRangeException(fieldName, value);
                }
                MasterDataIdentity_GLAccount recAcc = (MasterDataIdentity_GLAccount)value;
                setRecAccount(recAcc);
            }
            else if (fieldName.Equals(EntryTemplate.POSTING_DATE))
            {
                if (!(value is DateTime))
                {
                    throw new NotInValueRangeException(fieldName, value);
                }
                DateTime date = (DateTime)value;
                _date = date;
            }
            else if (fieldName.Equals(EntryTemplate.AMOUNT))
            {
                try
                {
                    CurrencyAmount amount = CurrencyAmount.Parse(value.ToString());
                    if (amount.IsZero() || amount.IsNegative())
                    {
                        throw new NotInValueRangeException(fieldName, value);
                    }
                    _amount = amount;
                }
                catch (CurrencyAmountFormatException)
                {
                    throw new NotInValueRangeException(fieldName, value);
                }
            }
            else if (fieldName.Equals(EntryTemplate.TEXT))
            {
                _text = value.ToString();
            }
            else if (fieldName.Equals(BUSINESS_AREA))
            {
                if (!(value is MasterDataIdentity))
                {
                    throw new NotInValueRangeException(fieldName, value);
                }
                MasterDataIdentity businessArea = (MasterDataIdentity)value;
                setBusinessArea(businessArea);
            }
            else
            {
                throw new NoFieldNameException(fieldName);
            }
        }
コード例 #15
0
        /// <summary>
        /// set value
        /// </summary>
        /// <param name="fieldName"></param>
        /// <param name="value"></param>
        /// <exception cref="NoFieldNameException">No such field name</exception>
        /// <exception cref="NotInValueRangeException">The value is not supported</exception>
        public void SetValue(String fieldName, Object value)
        {
            if (_isSaved)
            {
                return;
            }

            if (value == null)
            {
                throw new NotInValueRangeException(fieldName, "");
            }

            if (fieldName.Equals(DST_ACCOUNT))
            {
                if (!(value is MasterDataIdentity_GLAccount))
                {
                    throw new NotInValueRangeException(fieldName, value);
                }
                MasterDataIdentity_GLAccount id = (MasterDataIdentity_GLAccount)value;
                setDstAccount(id);
            }
            else if (fieldName.Equals(SRC_ACCOUNT))
            {
                if (!(value is MasterDataIdentity_GLAccount))
                {
                    throw new NotInValueRangeException(fieldName, value);
                }
                MasterDataIdentity_GLAccount id = (MasterDataIdentity_GLAccount)value;
                setSourceAccount(id);
            }
            else if (fieldName.Equals(EntryTemplate.TEXT))
            {
                _text = value.ToString();
            }
            else if (fieldName.Equals(EntryTemplate.AMOUNT))
            {
                try
                {
                    CurrencyAmount amount = CurrencyAmount.Parse(value.ToString());
                    if (amount.IsZero() || amount.IsNegative())
                    {
                        throw new NotInValueRangeException(fieldName, value);
                    }
                    _amount = amount;
                }
                catch (CurrencyAmountFormatException)
                {
                    throw new NotInValueRangeException(fieldName, value);
                }
            }
            else if (fieldName.Equals(EntryTemplate.POSTING_DATE))
            {
                if (!(value is DateTime))
                {
                    throw new NotInValueRangeException(fieldName, value);
                }
                DateTime pstDate = (DateTime)value;
                _pstDate = pstDate;
            }
            else
            {
                throw new NoFieldNameException(fieldName);
            }
        }
コード例 #16
0
        /// <summary>
        /// save document as template
        /// </summary>
        /// <param name="entry"></param>
        /// <param name="name">template name</param>
        /// <returns></returns>
        public async Task <EntryTemplate> SaveAsTemplate(IDocumentEntry entry, String name)
        {
            EntryTemplate template;

            // get the id
            int id = _list.Count + 1;

            try
            {
                CurrencyAmount amount = (CurrencyAmount)entry
                                        .GetValue(EntryTemplate.AMOUNT);
                String text = (String)entry.GetValue(EntryTemplate.TEXT);
                if (entry is VendorEntry)
                {
                    template = new EntryTemplate(_coreDriver, _mdMgmt,
                                                 EntryType.VendorEntry, id, name);
                    template.AddDefaultValue(EntryTemplate.AMOUNT, amount);
                    template.AddDefaultValue(EntryTemplate.TEXT, text);

                    Object vendor = entry.GetValue(VendorEntry.VENDOR);
                    if (vendor != null)
                    {
                        template.AddDefaultValue(VendorEntry.VENDOR, vendor);
                    }
                    Object recAcc = entry.GetValue(VendorEntry.REC_ACC);
                    if (recAcc != null)
                    {
                        template.AddDefaultValue(VendorEntry.REC_ACC, recAcc);
                    }
                    Object costAcc = entry.GetValue(VendorEntry.GL_ACCOUNT);
                    if (costAcc != null)
                    {
                        template.AddDefaultValue(VendorEntry.GL_ACCOUNT, costAcc);
                    }
                    Object businessArea = entry.GetValue(VendorEntry.BUSINESS_AREA);
                    if (businessArea != null)
                    {
                        template.AddDefaultValue(VendorEntry.BUSINESS_AREA,
                                                 businessArea);
                    }

                    this.addTemplate(template);
                }
                else if (entry is GLAccountEntry)
                {
                    template = new EntryTemplate(_coreDriver, _mdMgmt,
                                                 EntryType.GLEntry, id, name);

                    template.AddDefaultValue(EntryTemplate.AMOUNT, amount);
                    template.AddDefaultValue(EntryTemplate.TEXT, text);

                    Object recAcc = entry.GetValue(GLAccountEntry.SRC_ACCOUNT);
                    if (recAcc != null)
                    {
                        template.AddDefaultValue(GLAccountEntry.SRC_ACCOUNT, recAcc);
                    }
                    Object costAcc = entry.GetValue(GLAccountEntry.DST_ACCOUNT);
                    if (costAcc != null)
                    {
                        template.AddDefaultValue(GLAccountEntry.DST_ACCOUNT,
                                                 costAcc);
                    }

                    this.addTemplate(template);
                }
                else if (entry is CustomerEntry)
                {
                    template = new EntryTemplate(_coreDriver, _mdMgmt,
                                                 EntryType.CustomerEntry, id, name);

                    template.AddDefaultValue(EntryTemplate.AMOUNT, amount);
                    template.AddDefaultValue(EntryTemplate.TEXT, text);

                    Object customer = entry.GetValue(CustomerEntry.CUSTOMER);
                    if (customer != null)
                    {
                        template.AddDefaultValue(CustomerEntry.CUSTOMER, customer);
                    }
                    Object recAcc = entry.GetValue(CustomerEntry.REC_ACC);
                    if (recAcc != null)
                    {
                        template.AddDefaultValue(CustomerEntry.REC_ACC, recAcc);
                    }
                    Object costAcc = entry.GetValue(CustomerEntry.GL_ACCOUNT);
                    if (costAcc != null)
                    {
                        template.AddDefaultValue(CustomerEntry.GL_ACCOUNT, costAcc);
                    }

                    this.addTemplate(template);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception e)
            {
                _coreDriver.logDebugInfo(this.GetType(), 72, e.Message,
                                         MessageType.ERRO);
                throw new SystemException(e);
            }

            // save
            await _coreDriver.MdMgmt.StoreAsync();

            String filePath = String.Format("%s/%s", _coreDriver.RootFolder.Path,
                                            FILE_NAME);
            StorageFile file = await _coreDriver.RootFolder.CreateFileAsync(
                FILE_NAME, CreationCollisionOption.OpenIfExists);

            XDocument xdoc = this.ToXMLDoc();

            await FileIO.WriteTextAsync(file, xdoc.ToString());

            return(template);
        }
        //-------------------------------------------------------------------------
        public virtual void regressionPv()
        {
            CurrencyAmount pvComputed = SWAPTION_PRICER.presentValue(SWAPTION_PAY_LONG, RATE_PROVIDER, VOLS_REGRESSION);

            assertEquals(pvComputed.Amount, 3156216.489577751, REGRESSION_TOL * NOTIONAL);
        }
コード例 #18
0
 public CostReportItem(MasterDataIdentity_GLAccount id
                       , String name, CurrencyAmount amount, CostReportsAdapter parent)
     : base(id, name, parent)
 {
     _amount = amount;
 }
コード例 #19
0
 partial void OnCurrencyAmountChanging(CurrencyAmount value);
コード例 #20
0
 //-------------------------------------------------------------------------
 /// <summary>
 /// Calculates the current cash of the swap leg.
 /// </summary>
 /// <param name="leg">  the leg </param>
 /// <param name="provider">  the rates provider </param>
 /// <returns> the current cash of the swap leg </returns>
 public virtual CurrencyAmount currentCash(ResolvedSwapLeg leg, RatesProvider provider)
 {
     return(CurrencyAmount.of(leg.Currency, currentCashPeriodsInternal(leg, provider) + (currentCashEventsInternal(leg, provider))));
 }
コード例 #21
0
        /// <summary>
        /// get amount
        /// </summary>
        /// <param name="startId">start month identity</param>
        /// <param name="endId">end month identity</param>
        /// <returns></returns>
        public CurrencyAmount getAmount(MonthIdentity startId, MonthIdentity endId)
        {
            CurrencyAmount amount = new CurrencyAmount();
            List<HeadEntity> docs = this.getEntities(startId, endId);
            foreach (HeadEntity head in docs)
            {
                List<ItemEntity> items = head.Items;
                foreach (ItemEntity item in items)
                {
                    amount.AddTo(getAmountFromItem(item));
                }
            }

            return amount;
        }
コード例 #22
0
 /// <summary>
 /// Creates an {@code FxSingle} using a rate, specifying a date adjustment.
 /// <para>
 /// This creates a single foreign exchange specifying the amount, FX rate and value date.
 /// The amount must be specified using one of the currencies of the FX rate.
 /// </para>
 /// <para>
 /// This factory identifies the currency pair of the exchange and assigns the payments
 /// to match the base or counter currency of the standardized currency pair.
 /// For example, a EUR/USD exchange always has EUR as the base payment and USD as the counter payment.
 ///
 /// </para>
 /// </summary>
 /// <param name="amount">  the amount being exchanged, positive if being received, negative if being paid </param>
 /// <param name="fxRate">  the FX rate </param>
 /// <param name="paymentDate">  the date that the FX settles </param>
 /// <param name="paymentDateAdjustment">  the adjustment to apply to the payment date </param>
 /// <returns> the FX </returns>
 /// <exception cref="IllegalArgumentException"> if the FX rate and amount do not have a currency in common </exception>
 public static FxSingle of(CurrencyAmount amount, FxRate fxRate, LocalDate paymentDate, BusinessDayAdjustment paymentDateAdjustment)
 {
     ArgChecker.notNull(paymentDateAdjustment, "paymentDateAdjustment");
     return(create(amount, fxRate, paymentDate, paymentDateAdjustment));
 }
コード例 #23
0
        public virtual void missingFxRates()
        {
            FxRateScenarioArray    rates      = FxRateScenarioArray.of(EUR, USD, DoubleArray.of(1.61, 1.62, 1.63));
            ScenarioFxRateProvider fxProvider = new TestScenarioFxRateProvider(rates);

            IList <CurrencyAmount> values = ImmutableList.of(CurrencyAmount.of(Currency.GBP, 1), CurrencyAmount.of(Currency.GBP, 2), CurrencyAmount.of(Currency.GBP, 3));
            DefaultScenarioArray <CurrencyAmount> test = DefaultScenarioArray.of(values);

            assertThrows(() => test.convertedTo(Currency.USD, fxProvider), typeof(System.ArgumentException));
        }
コード例 #24
0
        /// <summary>
        /// Get group balance from start month to end month
        /// </summary>
        /// <param name="accountGroup"></param>
        /// <param name="startMonthId"></param>
        /// <param name="endMonthId"></param>
        /// <returns></returns>
        /// <exception cref="SystemException"></exception>
        public CurrencyAmount GetGroupBalance(GLAccountGroupENUM accountGroup,
            MonthIdentity startMonthId, MonthIdentity endMonthId)
        {
            CurrencyAmount ret = new CurrencyAmount();
            MasterDataManagement mdMgmt = this._mdMgmt;
            foreach (var item in _items)
            {
                GLAccountMasterData glAccount;
                try
                {
                    glAccount = (GLAccountMasterData)mdMgmt
                           .GetMasterData(item.Key, MasterDataType.GL_ACCOUNT);
                }
                catch (Exception e)
                {
                    _coreDriver.logDebugInfo(this.GetType(), 183, e.Message, MessageType.ERRO);
                    throw new SystemException(e);
                }
                if (glAccount.Group.Identity == accountGroup)
                {
                    ret.AddTo(item.Value.GetSumAmount(startMonthId, endMonthId));
                }
            }

            return ret;
        }
コード例 #25
0
        public virtual void wrongNumberOfFxRates()
        {
            FxRateScenarioArray    rates      = FxRateScenarioArray.of(GBP, USD, DoubleArray.of(1.61, 1.62, 1.63));
            ScenarioFxRateProvider fxProvider = new TestScenarioFxRateProvider(rates);

            IList <CurrencyAmount> values = ImmutableList.of(CurrencyAmount.of(Currency.GBP, 1), CurrencyAmount.of(Currency.GBP, 2));
            DefaultScenarioArray <CurrencyAmount> test = DefaultScenarioArray.of(values);

            assertThrows(() => test.convertedTo(Currency.USD, fxProvider), typeof(System.ArgumentException), "Expected 2 FX rates but received 3");
        }
コード例 #26
0
        /// <summary>
        /// set initialize amount, cost & revenue account cannot set init amount
        /// </summary>
        /// <param name="amount"></param>
        /// <returns></returns>
        internal bool setInitAmountInternal(CurrencyAmount amount)
        {
            // check group
            foreach(GLAccountGroupENUM group in GLAccountGroup.COST_GROUP)
            {
                if (this.Group.Identity == group)
                {
                    return false;
                }
            }
            foreach (GLAccountGroupENUM group in GLAccountGroup.REVENUE_GROUP)
            {
                if (this.Group.Identity == group)
                {
                    return false;
                }
            }

            CurrencyAmount orgAmount = _initAmount;
            _initAmount = new CurrencyAmount(amount);

            _coreDriver.ListenerMgmt.GLAccountInitAmountChanged(this, this.GLIdentity, orgAmount, amount);
            //this.SetDirtyData();
            return true;
        }
コード例 #27
0
        public virtual void noConversionNecessary()
        {
            FxRateScenarioArray    rates      = FxRateScenarioArray.of(GBP, USD, DoubleArray.of(1.61, 1.62, 1.63));
            ScenarioFxRateProvider fxProvider = new TestScenarioFxRateProvider(rates);

            IList <CurrencyAmount> values = ImmutableList.of(CurrencyAmount.of(Currency.GBP, 1), CurrencyAmount.of(Currency.GBP, 2), CurrencyAmount.of(Currency.GBP, 3));
            DefaultScenarioArray <CurrencyAmount> test = DefaultScenarioArray.of(values);

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: ScenarioArray<?> convertedList = test.convertedTo(com.opengamma.strata.basics.currency.Currency.GBP, fxProvider);
            ScenarioArray <object>         convertedList = test.convertedTo(Currency.GBP, fxProvider);
            ScenarioArray <CurrencyAmount> expectedList  = DefaultScenarioArray.of(values);

            assertThat(convertedList).isEqualTo(expectedList);
        }
コード例 #28
0
 /// <summary>
 /// Creates an {@code FxSingle} using a rate.
 /// <para>
 /// This creates a single foreign exchange specifying the amount, FX rate and value date.
 /// The amount must be specified using one of the currencies of the FX rate.
 /// </para>
 /// <para>
 /// This factory identifies the currency pair of the exchange and assigns the payments
 /// to match the base or counter currency of the standardized currency pair.
 /// For example, a EUR/USD exchange always has EUR as the base payment and USD as the counter payment.
 /// </para>
 /// <para>
 /// No payment date adjustments apply.
 ///
 /// </para>
 /// </summary>
 /// <param name="amount">  the amount being exchanged, positive if being received, negative if being paid </param>
 /// <param name="fxRate">  the FX rate </param>
 /// <param name="paymentDate">  the date that the FX settles </param>
 /// <returns> the FX </returns>
 /// <exception cref="IllegalArgumentException"> if the FX rate and amount do not have a currency in common </exception>
 public static FxSingle of(CurrencyAmount amount, FxRate fxRate, LocalDate paymentDate)
 {
     return(create(amount, fxRate, paymentDate, null));
 }
コード例 #29
0
 } public OrderNotificationReportItem()
 {
     this.itemPriceField = new CurrencyAmount();
 }
コード例 #30
0
        //-------------------------------------------------------------------------
        /// <summary>
        /// Computes the present value by replication in SABR framework with extrapolation on the right.
        /// </summary>
        /// <param name="cmsPeriod">  the CMS </param>
        /// <param name="provider">  the rates provider </param>
        /// <param name="swaptionVolatilities">  the swaption volatilities </param>
        /// <returns> the present value </returns>
        public CurrencyAmount presentValue(CmsPeriod cmsPeriod, RatesProvider provider, SwaptionVolatilities swaptionVolatilities)
        {
            Currency  ccy           = cmsPeriod.Currency;
            LocalDate valuationDate = provider.ValuationDate;

            if (valuationDate.isAfter(cmsPeriod.PaymentDate))
            {
                return(CurrencyAmount.zero(ccy));
            }
            LocalDate fixingDate = cmsPeriod.FixingDate;
            double    dfPayment  = provider.discountFactor(ccy, cmsPeriod.PaymentDate);

            if (!fixingDate.isAfter(valuationDate))
            {     // Using fixing
                double?fixedRate = provider.timeSeries(cmsPeriod.Index).get(fixingDate);
                if (fixedRate.HasValue)
                {
                    double payoff = 0d;
                    switch (cmsPeriod.CmsPeriodType)
                    {
                    case CAPLET:
                        payoff = Math.Max(fixedRate.Value - cmsPeriod.Strike, 0d);
                        break;

                    case FLOORLET:
                        payoff = Math.Max(cmsPeriod.Strike - fixedRate.Value, 0d);
                        break;

                    case COUPON:
                        payoff = fixedRate.Value;
                        break;

                    default:
                        throw new System.ArgumentException("unsupported CMS type");
                    }
                    return(CurrencyAmount.of(ccy, payoff * dfPayment * cmsPeriod.Notional * cmsPeriod.YearFraction));
                }
                else if (fixingDate.isBefore(valuationDate))
                {
                    throw new System.ArgumentException(Messages.format("Unable to get fixing for {} on date {}, no time-series supplied", cmsPeriod.Index, fixingDate));
                }
            }
            if (!cmsPeriod.CmsPeriodType.Equals(CmsPeriodType.COUPON))
            {
                throw new System.ArgumentException("Unable to price cap or floor in this pricer");
            }
            // Using forward
            SwapIndex        index              = cmsPeriod.Index;
            ResolvedSwap     swap               = cmsPeriod.UnderlyingSwap;
            ResolvedSwapLeg  fixedLeg           = swap.getLegs(SwapLegType.FIXED).get(0);
            int              nbFixedPaymentYear = (int)(long)Math.Round(1d / ((RatePaymentPeriod)fixedLeg.PaymentPeriods.get(0)).AccrualPeriods.get(0).YearFraction, MidpointRounding.AwayFromZero);
            int              nbFixedPeriod      = fixedLeg.PaymentPeriods.size();
            double           forward            = swapPricer.parRate(swap, provider);
            double           tenor              = swaptionVolatilities.tenor(swap.StartDate, swap.EndDate);
            double           expiryTime         = swaptionVolatilities.relativeTime(fixingDate.atTime(index.FixingTime).atZone(index.FixingZone));
            double           volatility         = swaptionVolatilities.volatility(expiryTime, tenor, forward, forward);
            ValueDerivatives annuityDerivatives = swapPricer.LegPricer.annuityCash2(nbFixedPaymentYear, nbFixedPeriod, volatility);
            double           forwardAdjustment  = -0.5 * forward * forward * volatility * volatility * expiryTime * annuityDerivatives.getDerivative(1) / annuityDerivatives.getDerivative(0);

            return(CurrencyAmount.of(ccy, (forward + forwardAdjustment) * dfPayment * cmsPeriod.Notional * cmsPeriod.YearFraction));
        }
コード例 #31
0
 } public OrderNotificationReportPromotion()
 {
     this.amountField = new CurrencyAmount();
 }
コード例 #32
0
        // create an FX Forward trade
        private static Trade createTrade2()
        {
            FxSingle fx = FxSingle.of(CurrencyAmount.of(USD, 15000), FxRate.of(GBP, USD, 1.62), LocalDate.of(2014, 9, 14));

            return(FxSingleTrade.builder().product(fx).info(TradeInfo.builder().id(StandardId.of("example", "2")).addAttribute(AttributeType.DESCRIPTION, "USD 15,000/GBP @ 1.62 fwd").counterparty(StandardId.of("example", "BigBankB")).settlementDate(LocalDate.of(2014, 9, 15)).build()).build());
        }
コード例 #33
0
 //-------------------------------------------------------------------------
 /// <summary>
 /// Returns the total of the sensitivity values.
 /// </summary>
 /// <returns> the total sensitivity values </returns>
 public CurrencyAmount total()
 {
     return(CurrencyAmount.of(currency, sensitivity.total()));
 }
コード例 #34
0
        // create a Bullet Payment trade
        private static Trade createTrade4()
        {
            BulletPayment bp = BulletPayment.builder().payReceive(PayReceive.PAY).value(CurrencyAmount.of(GBP, 20_000)).date(AdjustableDate.of(LocalDate.of(2014, 9, 16))).build();

            return(BulletPaymentTrade.builder().product(bp).info(TradeInfo.builder().id(StandardId.of("example", "4")).addAttribute(AttributeType.DESCRIPTION, "Bullet payment GBP 20,000").counterparty(StandardId.of("example", "BigBankC")).settlementDate(LocalDate.of(2014, 9, 16)).build()).build());
        }
コード例 #35
0
        //-------------------------------------------------------------------------
        public virtual void regression_pv()
        {
            CurrencyAmount pv = PRICER.presentValue(SWAPTION_PAY_LONG, RATE_PROVIDER, HW_PROVIDER);

            assertEquals(pv.Amount, 4213670.335092038, NOTIONAL * TOL);
        }
コード例 #36
0
 /// <summary>
 /// Method for printing in console when amount of transaction exceed 20000MKD
 /// </summary>
 /// <param name="account">acount</param>
 /// <param name="transactionType">transaction type</param>
 /// <param name="amount">amount</param>
 public static void LogTransaction(IAccount account, TransactionType transactionType, CurrencyAmount amount)
 {
     if (amount.Amount > 20000 && amount.Currency.Equals("MKD"))
     {
         string result = string.Format("*LOG* Account Number:{0} | Transaction Type:{1} | Amount:{2} | Currency:{3}", account.Number, transactionType, amount.Amount, amount.Currency);
         Console.WriteLine(result);
     }
 }
コード例 #37
0
        /// <summary>
        /// Parse XElement to header
        /// </summary>
        /// <param name="coreDriver"></param>
        /// <param name="management"></param>
        /// <param name="elem"></param>
        /// <returns></returns>
        /// <exception cref="TransactionDataFileFormatException"></exception>
        public static HeadEntity Parse(CoreDriver coreDriver,
                                       MasterDataManagement management, XElement elem)
        {
            HeadEntity head = new HeadEntity(coreDriver, management);

            head._isSaved = true;

            #region get document number
            XAttribute docNumStr = elem.Attribute(TransDataUtils.XML_DOC_NUM);
            if (docNumStr == null)
            {
                coreDriver.logDebugInfo(typeof(HeadEntity), 271, String.Format(
                                            "Field {0} is missing in.", TransDataUtils.XML_DOC_NUM),
                                        MessageType.ERRO);
                throw new TransactionDataFileFormatException("");
            }
            try
            {
                head._docNumber = new DocumentNumber(docNumStr.Value.ToCharArray());
            }
            catch (Exception)
            {
                coreDriver.logDebugInfo(typeof(HeadEntity), 271, String.Format(
                                            "Format of field {0} is error.", TransDataUtils.XML_DOC_NUM),
                                        MessageType.ERRO);
                throw new TransactionDataFileFormatException("");
            }
            #endregion

            #region fiscal year
            XAttribute yearStr = elem.Attribute(TransDataUtils.XML_YEAR);
            if (yearStr == null)
            {
                coreDriver.logDebugInfo(typeof(HeadEntity), 283, String.Format(
                                            "Field %s is missing in.", TransDataUtils.XML_YEAR),
                                        MessageType.ERRO);
                throw new TransactionDataFileFormatException("");
            }
            int year;
            if (!Int32.TryParse(yearStr.Value, out year))
            {
                coreDriver.logDebugInfo(typeof(HeadEntity), 271, String.Format(
                                            "Format of field {0} is error.", TransDataUtils.XML_YEAR),
                                        MessageType.ERRO);
                throw new TransactionDataFileFormatException("");
            }
            #endregion

            #region fiscal month
            XAttribute monthStr = elem.Attribute(TransDataUtils.XML_MONTH);
            if (monthStr == null)
            {
                coreDriver.logDebugInfo(typeof(HeadEntity), 295, String.Format(
                                            "Field %s is missing in.", TransDataUtils.XML_MONTH),
                                        MessageType.ERRO);
                throw new TransactionDataFileFormatException("");
            }
            int month;
            if (!Int32.TryParse(monthStr.Value, out month))
            {
                coreDriver.logDebugInfo(typeof(HeadEntity), 271, String.Format(
                                            "Format of field {0} is error.", TransDataUtils.XML_MONTH),
                                        MessageType.ERRO);
                throw new TransactionDataFileFormatException("");
            }
            #endregion
            try
            {
                head._monthId = new MonthIdentity(year, month);
            }
            catch (FiscalMonthRangeException)
            {
                coreDriver.logDebugInfo(typeof(HeadEntity), 271, String.Format(
                                            "Format of field {0} is error.", TransDataUtils.XML_MONTH),
                                        MessageType.ERRO);
                throw new TransactionDataFileFormatException("");
            }
            catch (FiscalYearRangeException)
            {
                coreDriver.logDebugInfo(typeof(HeadEntity), 271, String.Format(
                                            "Format of field {0} is error.", TransDataUtils.XML_YEAR),
                                        MessageType.ERRO);
                throw new TransactionDataFileFormatException("");
            }

            // posting date
            XAttribute dateStr = elem.Attribute(TransDataUtils.XML_DATE);
            if (dateStr == null)
            {
                coreDriver.logDebugInfo(typeof(HeadEntity), 307, String.Format(
                                            "Field %s is missing in.", TransDataUtils.XML_DATE),
                                        MessageType.ERRO);
                throw new TransactionDataFileFormatException("");
            }
            if (!DateTime.TryParse(dateStr.Value, out head._postingDate))
            {
                coreDriver.logDebugInfo(typeof(HeadEntity), 271, String.Format(
                                            "Format of field {0} is error.", TransDataUtils.XML_DATE),
                                        MessageType.ERRO);
                throw new TransactionDataFileFormatException("");
            }

            // text
            XAttribute text = elem.Attribute(TransDataUtils.XML_TEXT);
            if (text == null)
            {
                coreDriver.logDebugInfo(typeof(HeadEntity), 325, String.Format(
                                            "Field %s is missing in.", TransDataUtils.XML_TEXT),
                                        MessageType.ERRO);
                throw new TransactionDataFileFormatException("");
            }
            head._docText = text.Value;

            // document type
            XAttribute docTypeStr = elem.Attribute(TransDataUtils.XML_DOC_TYPE);
            if (docTypeStr == null)
            {
                coreDriver.logDebugInfo(typeof(HeadEntity), 325, String.Format(
                                            "Field %s is missing in.", TransDataUtils.XML_DOC_TYPE),
                                        MessageType.ERRO);
                throw new TransactionDataFileFormatException("");
            }
            if (docTypeStr.Value.Length != 1 ||
                (docTypeStr.Value[0] != (char)DocumentType.CUSTOMER_INVOICE &&
                 docTypeStr.Value[0] != (char)DocumentType.GL &&
                 docTypeStr.Value[0] != (char)DocumentType.VENDOR_INVOICE))
            {
                coreDriver.logDebugInfo(typeof(HeadEntity), 271, String.Format(
                                            "Format of field {0} is error.", TransDataUtils.XML_DOC_TYPE),
                                        MessageType.ERRO);
                throw new TransactionDataFileFormatException("");
            }
            head._type = (DocumentType)docTypeStr.Value[0];


            // is reversed
            XAttribute isReversedStr = elem
                                       .Attribute(TransDataUtils.XML_IS_REVERSED);
            if (isReversedStr == null)
            {
                coreDriver.logDebugInfo(typeof(HeadEntity), 338, String.Format(
                                            "Field %s is missing in.", TransDataUtils.XML_IS_REVERSED),
                                        MessageType.ERRO);
                throw new TransactionDataFileFormatException("");
            }
            if (!bool.TryParse(isReversedStr.Value, out head._isReversed))
            {
                coreDriver.logDebugInfo(typeof(HeadEntity), 271, String.Format(
                                            "Format of field {0} is error.", TransDataUtils.XML_IS_REVERSED),
                                        MessageType.ERRO);
                throw new TransactionDataFileFormatException("");
            }

            // parse item
            foreach (XElement itemElem in elem.Elements(TransDataUtils.XML_ITEM))
            {
                ItemEntity item = ItemEntity.Parse(coreDriver,
                                                   management, head, itemElem);
                item._isSaved = true;

                coreDriver
                .logDebugInfo(
                    typeof(HeadEntity),
                    377,
                    String.Format(
                        "Line Item %d appended during parsing document.",
                        item.LineNum),
                    MessageType.INFO);
                head._items.Add(item);
            }

            // addition attributes
            foreach (XAttribute attr in elem.Attributes())
            {
                head._fields.Add(attr.Name.LocalName, attr.Value);
            }

            // remove fields is not additional fields
            foreach (String str in TransDataUtils.HEAD_XML_TAGS)
            {
                head._fields.Remove(str);
            }

            // check balance
            CurrencyAmount sum = new CurrencyAmount();
            foreach (ItemEntity item in head._items)
            {
                if (item.CdIndicator == CreditDebitIndicator.DEBIT)
                {
                    sum.AddTo(item.Amount);
                }
                else
                {
                    sum.MinusTo(item.Amount);
                }
            }

            if (sum.IsZero() == false)
            {
                throw new TransactionDataFileFormatException("No Balance");
            }

            StringBuilder strBuilder = new StringBuilder(
                String.Format(
                    "Parse document %s with posting date %s, text %s, type %s, is_reversed %s",
                    head.DocIdentity, head.PstDate,
                    head.DocText, head.DocType,
                    head.IsReversed));
            coreDriver.logDebugInfo(typeof(HeadEntity), 377,
                                    strBuilder.ToString(), MessageType.INFO);
            return(head);
        }
コード例 #38
0
 /// <summary>
 /// add currency amount
 /// </summary>
 /// <param name="monthId"></param>
 /// <param name="amount"></param>
 internal void addAmount(MonthIdentity monthId, CurrencyAmount amount)
 {
     CurrencyAmount v1;
     if (_amountList.TryGetValue(monthId, out v1))
     {
         v1.AddTo(amount);
         return;
     }
     // put
     _amountList.Add(monthId, amount);
 }
コード例 #39
0
 /// <summary>
 /// Calculates the forecast value of the swap leg.
 /// <para>
 /// The forecast value of the leg is the value on the valuation date without present value discounting.
 /// The result is returned using the payment currency of the leg.
 ///
 /// </para>
 /// </summary>
 /// <param name="leg">  the leg </param>
 /// <param name="provider">  the rates provider </param>
 /// <returns> the forecast value of the swap leg </returns>
 public virtual CurrencyAmount forecastValue(ResolvedSwapLeg leg, RatesProvider provider)
 {
     return(CurrencyAmount.of(leg.Currency, forecastValueInternal(leg, provider)));
 }
コード例 #40
0
 public CostReportItem(MasterDataIdentity_GLAccount id
     , String name, CurrencyAmount amount, CostReportsAdapter parent)
     : base(id, name, parent)
 {
     _amount = amount;
 }
コード例 #41
0
        //-------------------------------------------------------------------------
        /// <summary>
        /// Calculates the present value of the swap leg, converted to the specified currency.
        /// <para>
        /// The present value of the leg is the value on the valuation date.
        /// This is the discounted forecast value.
        /// The result is converted to the specified currency.
        ///
        /// </para>
        /// </summary>
        /// <param name="leg">  the leg </param>
        /// <param name="currency">  the currency to convert to </param>
        /// <param name="provider">  the rates provider </param>
        /// <returns> the present value of the swap leg in the specified currency </returns>
        public virtual CurrencyAmount presentValue(ResolvedSwapLeg leg, Currency currency, RatesProvider provider)
        {
            double pv = presentValueInternal(leg, provider);

            return(CurrencyAmount.of(currency, (pv * provider.fxRate(leg.Currency, currency))));
        }
コード例 #42
0
        /// <summary>
        /// Parse master data from XML
        /// </summary>
        /// <param name="coreDriver"></param>
        /// <param name="elem"></param>
        /// <returns></returns>
        /// <exception cref="MasterDataFileFormatException">Master Data file exception</exception>
        /// <exception cref="ArgumentNullException">Argument is null</exception>
        /// <exception cref="SystemException">Bug</exception>
        public override MasterDataBase ParseMasterData(CoreDriver coreDriver, XElement elem)
        {
            XAttribute id = elem.Attribute(MasterDataUtils.XML_ID);
            XAttribute descp = elem.Attribute(MasterDataUtils.XML_DESCP);
            XAttribute bankAccStr = elem.Attribute(MasterDataUtils.XML_BANK_ACCOUNT);
            XAttribute initAmountAttr = elem.Attribute(MasterDataUtils.XML_INIT_AMOUNT);

            MasterDataIdentity_GLAccount identity;
            MasterDataIdentity bankAccId = null;
            try
            {
                identity = new MasterDataIdentity_GLAccount(
                        id.Value);

                // bank account
                if (bankAccStr != null)
                {
                    bankAccId = new MasterDataIdentity(
                            bankAccStr.Value);
                }

            }
            catch (Exception e)
            {
                _coreDriver.logDebugInfo(this.GetType(), 150, e.Message, MessageType.ERRO);
                throw new MasterDataFileFormatException(MasterDataType.GL_ACCOUNT);
            }

            CurrencyAmount initAmount = new CurrencyAmount();
            if (initAmountAttr != null)
            {
                try
                {
                    initAmount = CurrencyAmount.Parse(initAmountAttr.Value);
                }
                catch (CurrencyAmountFormatException e)
                {
                    _coreDriver.logDebugInfo(this.GetType(), 150, e.Message, MessageType.ERRO);
                    throw new MasterDataFileFormatException(MasterDataType.GL_ACCOUNT);
                }
            }
            try
            {
                GLAccountMasterData glAccount;
                if (bankAccId == null)
                {
                    glAccount = (GLAccountMasterData)this.CreateNewMasterDataBase(
                            identity, descp.Value);
                }
                else
                {
                    glAccount = (GLAccountMasterData)this.CreateNewMasterDataBase(
                                identity, descp.Value, bankAccId);
                }
                glAccount.setInitAmountInternal(initAmount);
                _coreDriver
                            .logDebugInfo(
                                    this.GetType(),
                                    167,
                                    String.Format("Parse G/L account ({0}).",
                                            glAccount.Identity.ToString()), MessageType.INFO);
                return glAccount;
            }
            catch (Exception e)
            {
                throw new SystemException(e);
            }

        }
コード例 #43
0
 public static Order CreateOrder(int ID, double dollarAmount, CurrencyAmount currencyAmount)
 {
     Order order = new Order();
     order.ID = ID;
     order.DollarAmount = dollarAmount;
     if ((currencyAmount == null))
     {
         throw new global::System.ArgumentNullException("currencyAmount");
     }
     order.CurrencyAmount = currencyAmount;
     return order;
 }
コード例 #44
0
 /// <summary>
 /// set init amount
 /// </summary>
 /// <param name="amount"></param>
 /// <returns></returns>
 public bool SetInitAmount(CurrencyAmount amount)
 {
     bool ret = setInitAmountInternal(amount);
     if(ret)
         this.SetDirtyData();
     return ret;
 }
コード例 #45
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="source"></param>
 /// <param name="glAccountId"></param>
 /// <param name="orgAmount"></param>
 /// <param name="newAmount"></param>
 public void GLAccountInitAmountChanged(Object source, MasterDataIdentity_GLAccount glAccountId,
     CurrencyAmount orgAmount, CurrencyAmount newAmount)
 {
     foreach (GLAccountInitAmountChanged d in 
         GLAccountInitAmountChangedHandler.GetInvocationList())
     {
         d(glAccountId, orgAmount, newAmount);
     }
 }
コード例 #46
0
        /// <summary>
        /// Set value
        /// </summary>
        /// <param name="fieldName"></param>
        /// <param name="value"></param>
        /// <exception cref="NoFieldNameException"></exception>
        /// <exception cref="NotInValueRangeException"></exception>
        public void SetValue(String fieldName, Object value)
        {
            if (_isSaved)
            {
                return;
            }

            if (value == null)
            {
                throw new NotInValueRangeException(fieldName, "");
            }

            if (fieldName.Equals(CUSTOMER))
            {
                MasterDataIdentity customer = value as MasterDataIdentity;
                if (customer == null)
                {
                    throw new NotInValueRangeException(fieldName, value);
                }
                setCustomer(customer);
            }
            else if (fieldName.Equals(GL_ACCOUNT))
            {
                MasterDataIdentity_GLAccount glAccount = value as MasterDataIdentity_GLAccount;
                if (glAccount == null)
                {
                    throw new NotInValueRangeException(fieldName, value);
                }
                setGLAccount(glAccount);
            }
            else if (fieldName.Equals(REC_ACC))
            {
                MasterDataIdentity_GLAccount recAcc = value as MasterDataIdentity_GLAccount;
                if (recAcc == null)
                {
                    throw new NotInValueRangeException(fieldName, value);
                }
                setRecAccount(recAcc);
            }
            else if (fieldName.Equals(EntryTemplate.POSTING_DATE))
            {
                if (!(value is DateTime))
                {
                    throw new NotInValueRangeException(fieldName, value);
                }
                DateTime date = (DateTime)value;
                _date = date;
            }
            else if (fieldName.Equals(EntryTemplate.AMOUNT))
            {
                try
                {
                    CurrencyAmount amount = CurrencyAmount.Parse(value.ToString());
                    if (amount.IsZero() || amount.IsNegative())
                    {
                        throw new NotInValueRangeException(fieldName, value);
                    }
                    _amount = amount;
                }
                catch (CurrencyAmountFormatException)
                {
                    throw new NotInValueRangeException(fieldName, value);
                }
            }
            else if (fieldName.Equals(EntryTemplate.TEXT))
            {
                _text = value.ToString();
            }
            else
            {
                throw new NoFieldNameException(fieldName);
            }

        }
コード例 #47
0
        //-------------------------------------------------------------------------
        public virtual void test_currentCash()
        {
            CurrencyAmount computed = LEG_PRICER.currentCash(COUPON_LEG, RATES_PROVIDER);

            assertEquals(computed, CurrencyAmount.zero(EUR));
        }
コード例 #48
0
        /// <summary>
        /// set value
        /// </summary>
        /// <param name="fieldName"></param>
        /// <param name="value"></param>
        /// <exception cref="NoFieldNameException">No such field name</exception>
        /// <exception cref="NotInValueRangeException">The value is not supported</exception>
        public void SetValue(String fieldName, Object value)
        {
            if (_isSaved)
            {
                return;
            }

            if (value == null)
            {
                throw new NotInValueRangeException(fieldName, "");
            }

            if (fieldName.Equals(VENDOR))
            {
                if (!(value is MasterDataIdentity))
                {
                    throw new NotInValueRangeException(fieldName, value);
                }
                MasterDataIdentity vendor = (MasterDataIdentity)value;
                setVendor(vendor);
            }
            else if (fieldName.Equals(GL_ACCOUNT))
            {
                if (!(value is MasterDataIdentity_GLAccount))
                {
                    throw new NotInValueRangeException(fieldName, value);
                }
                MasterDataIdentity_GLAccount glAccount = (MasterDataIdentity_GLAccount)value;
                setGLAccount(glAccount);
            }
            else if (fieldName.Equals(REC_ACC))
            {
                if (!(value is MasterDataIdentity_GLAccount))
                {
                    throw new NotInValueRangeException(fieldName, value);
                }
                MasterDataIdentity_GLAccount recAcc = (MasterDataIdentity_GLAccount)value;
                setRecAccount(recAcc);
            }
            else if (fieldName.Equals(EntryTemplate.POSTING_DATE))
            {
                if (!(value is DateTime))
                {
                    throw new NotInValueRangeException(fieldName, value);
                }
                DateTime date = (DateTime)value;
                _date = date;
            }
            else if (fieldName.Equals(EntryTemplate.AMOUNT))
            {
                try
                {
                    CurrencyAmount amount = CurrencyAmount.Parse(value.ToString());
                    if (amount.IsZero() || amount.IsNegative())
                    {
                        throw new NotInValueRangeException(fieldName, value);
                    }
                    _amount = amount;
                }
                catch (CurrencyAmountFormatException)
                {
                    throw new NotInValueRangeException(fieldName, value);
                }
            }
            else if (fieldName.Equals(EntryTemplate.TEXT))
            {
                _text = value.ToString();
            }
            else if (fieldName.Equals(BUSINESS_AREA))
            {
                if (!(value is MasterDataIdentity))
                {
                    throw new NotInValueRangeException(fieldName, value);
                }
                MasterDataIdentity businessArea = (MasterDataIdentity)value;
                setBusinessArea(businessArea);
            }
            else
            {
                throw new NoFieldNameException(fieldName);
            }
        }
コード例 #49
0
 /// <summary>
 /// Creates an {@code FxSingle} from two amounts and the value date.
 /// <para>
 /// The amounts must be of the correct type, one pay and one receive.
 /// The currencies of the payments must differ.
 /// </para>
 /// <para>
 /// This factory identifies the currency pair of the exchange and assigns the payments
 /// to match the base or counter currency of the standardized currency pair.
 /// For example, a EUR/USD exchange always has EUR as the base payment and USD as the counter payment.
 /// </para>
 /// <para>
 /// No payment date adjustments apply.
 ///
 /// </para>
 /// </summary>
 /// <param name="amount1">  the amount in the first currency </param>
 /// <param name="amount2">  the amount in the second currency </param>
 /// <param name="paymentDate">  the date that the FX settles </param>
 /// <returns> the FX </returns>
 public static FxSingle of(CurrencyAmount amount1, CurrencyAmount amount2, LocalDate paymentDate)
 {
     return(create(amount1, amount2, paymentDate, null));
 }
コード例 #50
0
        /// <summary>
        /// Calculates the present value of the foreign exchange vanilla option product.
        /// <para>
        /// The present value of the product is the value on the valuation date.
        /// It is expressed in the counter currency.
        ///
        /// </para>
        /// </summary>
        /// <param name="option">  the option product </param>
        /// <param name="ratesProvider">  the rates provider </param>
        /// <param name="volatilities">  the Black volatility provider </param>
        /// <returns> the present value of the product </returns>
        public virtual CurrencyAmount presentValue(ResolvedFxVanillaOption option, RatesProvider ratesProvider, BlackFxOptionSmileVolatilities volatilities)
        {
            double price = this.price(option, ratesProvider, volatilities);

            return(CurrencyAmount.of(option.CounterCurrency, signedNotional(option) * price));
        }
コード例 #51
0
        /// <summary>
        /// set balance data
        /// </summary>
        private void setBalanceData()
        {
            // int index = MonthSelection.SelectedIndex;
            MonthItem monthItem = MonthSelection.SelectedItem as MonthItem;
            if (monthItem == null)
            {
                return;
            }
            CoreDriver coreDriver = DataCore.GetInstance().BackendCoreDriver;
            if (coreDriver.IsInitialize == false)
            {
                return;
            }

            TransactionDataManagement transMgmt = coreDriver.TransMgmt;
            GLAccountBalanceCollection balCol = transMgmt.AccountBalanceCol;          

            #region revenue
            CurrencyAmount revenue = new CurrencyAmount();
            foreach (GLAccountGroupENUM group in GLAccountGroup.REVENUE_GROUP) {
            CurrencyAmount cur = balCol
                    .GetGroupBalance(group, monthItem.MonthId, monthItem.MonthId);
                cur.Negate();
                revenue.AddTo(cur);
            }
            // set value
            incomingAmount.Text = revenue.ToString();
            #endregion

            #region cost
            CurrencyAmount cost = new CurrencyAmount();
            foreach (GLAccountGroupENUM group in GLAccountGroup.COST_GROUP)
            {
                CurrencyAmount cur = balCol
                        .GetGroupBalance(group, monthItem.MonthId, monthItem.MonthId);
                cost.AddTo(cur);
            }
            // set value
            this.outgoingAmount.Text = cost.ToString();
            #endregion

            #region balance
            CurrencyAmount balance = new CurrencyAmount();
            foreach (GLAccountGroupENUM group in GLAccountGroup.BALANCE_GROUP)
            {
                CurrencyAmount cur = balCol
                        .GetGroupBalance(group);
                balance.AddTo(cur);
            }
            // set value
            this.balanceAmount.Text = balance.ToString();
            #endregion

            #region liquidity
            CurrencyAmount liquidity = new CurrencyAmount();
            foreach (GLAccountGroupENUM group in GLAccountGroup.Liquidity_GROUP)
            {
                CurrencyAmount cur = balCol
                        .GetGroupBalance(group);
                liquidity.AddTo(cur);
            }
            // set value
            this.liquidityAmount.Text = liquidity.ToString();
            #endregion
        }
コード例 #52
0
 public static CurrencyAmount CreateCurrencyAmount(decimal amount)
 {
     CurrencyAmount currencyAmount = new CurrencyAmount();
     currencyAmount.Amount = amount;
     return currencyAmount;
 }
コード例 #53
0
        public virtual void test_presentValue_ended()
        {
            CurrencyAmount computed = LEG_PRICER.presentValue(COUPON_LEG, RATES_PROVIDER_ENDED);

            assertEquals(computed, CurrencyAmount.zero(EUR));
        }
コード例 #54
0
 partial void OnCurrencyAmountChanging(CurrencyAmount value);
コード例 #55
0
        public void TestCurrencyAmount()
        {
            // test to string
            CurrencyAmount amount = new CurrencyAmount(123.45);
            Assert.AreEqual("123.45", amount.ToString());

            // test parse
            amount = CurrencyAmount.Parse("123.45");
            Assert.AreEqual("123.45", amount.ToString());

            // test add
            CurrencyAmount amount2 = new CurrencyAmount(543.21);
            amount = new CurrencyAmount(123.45);
            Assert.AreEqual("666.66", CurrencyAmount.Add(amount, amount2).ToString());

            amount.AddTo(amount2);
            Assert.AreEqual("666.66", amount.ToString());

            // test minus
            amount2 = new CurrencyAmount(543.21);
            amount = new CurrencyAmount(123.45);
            Assert.AreEqual("-419.76", CurrencyAmount.Minus(amount, amount2).ToString());
            Assert.AreEqual("419.76", CurrencyAmount.Minus(amount2, amount).ToString());
            Assert.AreEqual("0.00", CurrencyAmount.Minus(amount2, amount2).ToString());

            // is zero
            Assert.AreEqual(true, CurrencyAmount.Minus(amount2, amount2).IsZero());
        }