示例#1
0
        public void ProfitCorrectlyCalculatedAfterReversing()
        {
            var pos = new CurrencyPosition(_currency);

            decimal fxRate   = 1.35m;
            int     quantity = 1000;

            var transaction1 = new FXTransaction
            {
                Quantity   = quantity,
                Proceeds   = fxRate * quantity,
                Cost       = -fxRate * quantity,
                FXCurrency = _currency
            };

            pos.AddFXTransaction(transaction1);

            decimal newFxRate    = 1.36m;
            int     newQuantity  = -2000;
            var     transaction2 = new FXTransaction
            {
                Quantity   = newQuantity,
                Proceeds   = newFxRate * newQuantity,
                Cost       = -newFxRate * newQuantity,
                FXCurrency = _currency
            };

            pos.AddFXTransaction(transaction2);

            Assert.AreEqual(quantity * (newFxRate - fxRate), pos.RealizedPnL);

            pos.Update(newFxRate);

            Assert.AreEqual(quantity * (newFxRate - fxRate), pos.TotalPnL);
        }
示例#2
0
 public KashFlow.CompanyDetails ToData()
 {
     return(new KashFlow.CompanyDetails()
     {
         Address1 = Address1,
         Address2 = Address2,
         Address3 = Address3,
         Address4 = Address4,
         BusinessType = BusinessType,
         BusinessType1 = BusinessType1,
         BusinessType1Name = BusinessName1,
         BusinessType2 = BusinessType2,
         BusinessType2Name = BusinessName2,
         BusinessType3 = BusinessType3,
         BusinessType3Name = BusinessName3,
         CompanyName = CompanyName,
         CurrencyId = CurrencyID,
         CurrencyName = CurrencyName,
         CurrencyPosition = CurrencyPosition.ToString(),
         CurrencySymbol = CurrencySymbol,
         Mobile = Mobile,
         PaymentTerms = PaymentTerms,
         PaymentTermsType = PaymentTermsType.ToString(),
         Postcode = Postcode,
         PrimaryContact = PrimaryContact,
         PrimaryEmail = PrimaryEmail,
         Telephone = Telephone,
         UsDate = IsUsingAmericanDate ? "Yes" : "No",
         VatRegistered = IsVATRegistered ? "Yes" : "No",
         VatRegistrationNumber = VATRegistrationNumber
     });
 }
 public CountryCurrency(DateTime datefrom, DateTime dateto, string currencysymbol,CurrencyPosition position,  double rate)
 {
     this.DateFrom = datefrom;
     this.DateTo = dateto;
     this.CurrencySymbol = currencysymbol;
     this.Rate = rate;
     this.Position = position;
 }
 public CountryCurrency(
     DateTime datefrom,
     DateTime dateto,
     string currencysymbol,
     CurrencyPosition position,
     double rate)
 {
     DateFrom = datefrom;
     DateTo = dateto;
     CurrencySymbol = currencysymbol;
     Rate = rate;
     Position = position;
 }
示例#5
0
        public void QuantityAndPriceReflectAddedTransactions()
        {
            var pos = new CurrencyPosition(_currency);

            decimal fxRate   = 1.35m;
            int     quantity = 1000;

            var transaction1 = new FXTransaction
            {
                Quantity   = quantity,
                Proceeds   = fxRate * quantity,
                Cost       = -fxRate * quantity,
                FXCurrency = _currency
            };

            pos.AddFXTransaction(transaction1);

            Assert.AreEqual(quantity, pos.Quantity);
            Assert.AreEqual(fxRate, pos.CostBasis);
            Assert.AreEqual(fxRate, pos.PriorPeriodCostBasis);
        }
示例#6
0
        public void RealizedProfitsWithUpdateBetweenTradesCalculatedCorrectly()
        {
            var pos = new CurrencyPosition(_currency);

            decimal fxRate   = 1.35m;
            int     quantity = 1000;

            var transaction1 = new FXTransaction
            {
                Quantity   = quantity,
                Proceeds   = fxRate * quantity,
                Cost       = -fxRate * quantity,
                FXCurrency = _currency
            };

            pos.AddFXTransaction(transaction1);

            decimal newFxRate = 1.36m;

            pos.Update(newFxRate);

            Assert.AreEqual(quantity * (newFxRate - fxRate), pos.TotalPnL);


            int     newQuantity = -1000;
            decimal newFxRate2  = 1.37m;

            var transaction2 = new FXTransaction
            {
                Quantity   = newQuantity,
                Proceeds   = newFxRate2 * newQuantity,
                Cost       = -newFxRate2 * newQuantity,
                FXCurrency = _currency
            };

            pos.AddFXTransaction(transaction2);

            Assert.AreEqual(-newQuantity * (newFxRate2 - fxRate), pos.RealizedPnL);
        }
示例#7
0
 public CountryCurrency(DateTime datefrom, DateTime dateto, string currencysymbol, CurrencyPosition position, double rate)
 {
     this.DateFrom       = datefrom;
     this.DateTo         = dateto;
     this.CurrencySymbol = currencysymbol;
     this.Rate           = rate;
     this.Position       = position;
 }