Ejemplo n.º 1
0
 public void ModifyCcy(FXMarket mkt, AssetMarket aMkt, string v, ICcyAsset valueCcy, bool isLastRow)
 {
     if (isLastRow)
     {
         _Ccy = valueCcy.Ccy;
     }
 }
Ejemplo n.º 2
0
 public void Set(ICcyAsset iCcyAsset, double amount)
 {
     if (amount != 0)
     {
         Data[(ICcyAsset)iCcyAsset.Clone()] = amount;
     }
 }
Ejemplo n.º 3
0
        private double Aux_GetQuote(ICcyAsset ccy, ICcyAsset ccy2, List <ICcyAsset> excludedCcies)
        {
            var connectedCcies = GetAllConnectedCcy(ccy, excludedCcies);

            if (connectedCcies.Count() == 0)
            {
                return(0);
            }
            else if (connectedCcies.Contains(ccy2))
            {
                return(GetQuote(new CurrencyPair(ccy, ccy2)));
            }
            else
            {
                foreach (var ccy_k in connectedCcies)
                {
                    List <ICcyAsset> exL_k = excludedCcies.Select(x => (ICcyAsset)x.Ccy.Clone()).ToList();
                    exL_k.Add(ccy);
                    double value = GetQuote(new CurrencyPair(ccy, ccy_k));
                    value *= Aux_GetQuote(ccy_k.Ccy, ccy2, exL_k);
                    if (value != 0)
                    {
                        return(value);
                    }
                }
            }
            throw new Exception("Error in Aux_GetQuote()");
        }
 public DataGridViewComboBoxCellAccounting(ICcyAsset ccy, IEnumerable <string> ccies) : base()
 {
     foreach (string item in ccies)
     {
         Items.Add(item);
     }
     Value     = ccy.ToString();
     FlatStyle = FlatStyle.Flat;
 }
Ejemplo n.º 5
0
        public Account AddAccount(string name, ICcyAsset currency = null, double amount = 0)
        {
            if (currency == null)
            {
                currency = Ccy;
            }
            Account account = new Account(name, currency, amount);

            _Accounts.Add(account);
            return(account);
        }
Ejemplo n.º 6
0
 public string CcyToString(ICcyAsset ccy, double value)
 {
     if (ccy.IsCcy())
     {
         return(_CcyDB.CcyToString(ccy.Ccy, value));
     }
     else
     {
         return(Convert.ToString(value));
     }
 }
Ejemplo n.º 7
0
 public string GetAmountToString(ICcyAsset ICcyAsset, double amount)
 {
     if (ICcyAsset.IsCcy())
     {
         return(_CcyDB.GetCcyStatics(ICcyAsset.Ccy).ValueToString(amount));
     }
     else
     {
         return(Convert.ToString(amount));
     }
 }
Ejemplo n.º 8
0
 public double GetQuote(ICcyAsset item, Currency ccy)
 {
     if (item.IsCcy())
     {
         return(FXMarket.GetQuote(new CurrencyPair(item.Ccy, ccy)));
     }
     else
     {
         return(AssetMarket.GetQuote(new AssetCcyPair(item.Asset, Ccy)));
     }
 }
Ejemplo n.º 9
0
 public Account(string name, ICcyAsset ccy, double amount = 0, bool isCalculatedAccount = false, double?lastAmount = null)
 {
     _AccountName         = name;
     _Ccy                 = ccy;
     _TotalCcy            = ccy.Ccy;
     _ConvertedCcy        = ccy.Ccy;
     _IsCalculatedAccount = isCalculatedAccount;
     _Amount              = amount;
     _LastAmount          = lastAmount;
     _ConvertedAmount     = amount;
 }
Ejemplo n.º 10
0
 public CurrencyPair(ICcyAsset ccy1, ICcyAsset ccy2)
 {
     if (ccy1.IsCcy() && ccy2.IsCcy())
     {
         _Ccy1 = ccy1.Ccy;
         _Ccy2 = ccy2.Ccy;
     }
     else
     {
         throw new Exception($"CurrencyPair needs 2 currencies {ccy1.ToString()} {ccy2.ToString()}!");
     }
 }
Ejemplo n.º 11
0
        public void ModifyCcy(FXMarket mkt, AssetMarket aMkt, string v, ICcyAsset valueCcy, bool isLastRow)
        {
            _Ccy = valueCcy;
            IMarket iMkt = mkt;

            if (!_Ccy.IsCcy())
            {
                iMkt = aMkt;
            }
            _ConvertedAmount = _Amount * iMkt.GetQuote(_Ccy.CreateMarketInput(_ConvertedCcy));
            _TotalAmount     = _Amount * iMkt.GetQuote(_Ccy.CreateMarketInput(_TotalCcy));
        }
Ejemplo n.º 12
0
 public IAccount GetTotalAccount(FXMarket mkt, AssetMarket aMkt, ICcyAsset convCcy, string name, double?lastAmount)
 {
     _LastAmount = lastAmount;
     if (Ccy.IsCcy())
     {
         RecalculateAmount(mkt, convCcy.Ccy);
     }
     else
     {
         RecalculateAmount(aMkt, convCcy.Ccy);
     }
     return(this);
 }
Ejemplo n.º 13
0
        public Account(SerializationInfo info, StreamingContext context)
        {
            _AccountName = (string)info.GetValue("Name", typeof(string));
            Currency ccy = (Currency)info.GetValue("Currency", typeof(Currency));

            if (!(ccy == null))
            {
                _Ccy = (ICcyAsset)ccy;
            }
            else
            {
                _Ccy = (ICcyAsset)info.GetValue("Asset", typeof(Asset));
            }
            _Amount = (double)info.GetValue("Amount", typeof(double));
        }
Ejemplo n.º 14
0
 public void ModifyCcy(FXMarket mkt, AssetMarket aMkt, string accountName, ICcyAsset value, bool IsLastRow)
 {
     if (IsLastRow)
     {
         Ccy = value.Ccy;
         foreach (Account item in Accounts)
         {
             item.RecalculateConvertedAmount(Ccy, mkt, aMkt);
         }
     }
     else
     {
         Account acc = GetAccount(accountName);
         acc.ModifyCcy(mkt, aMkt, "", value, false);
     }
 }
Ejemplo n.º 15
0
        private void AddRow(IAccountingElement item, ICcyAsset convCcy, bool isTotal = false, double?lastTotal = null)
        {
            IAccount sum = item.GetTotalAccount(FXMarketUsed, AssetMarketUsed, convCcy, item.GetName(), lastTotal: lastTotal);

            AddRow(sum, isTotal);
        }
Ejemplo n.º 16
0
 private IEnumerable <ICcyAsset> GetAllConnectedCcy(ICcyAsset ccy, List <ICcyAsset> excludedCcies)
 {
     return(_Data.Where(x => x.Key.Contains(ccy) && !excludedCcies.Contains(x.Key.OtherAsset(ccy)))
            .Select(x => x.Key.OtherAsset(ccy)));
 }
Ejemplo n.º 17
0
 public IAccount GetTotalAccount(FXMarket mkt, AssetMarket aMkt, ICcyAsset convCcy)
 {
     return(GetTotalAccount(mkt, aMkt, convCcy, null, null));
 }
Ejemplo n.º 18
0
        public DataGridViewRowAccounting(DataGridViewAccounting table,
                                         IAccount account,
                                         bool isTotalRow  = false,
                                         bool isTotalView = false)
        {
            CreateCells(table);
            string amount     = table.CcyToString(account.Ccy, account.Amount);
            string convAmount = table.CcyToString(account.ConvertedCcy, account.ConvertedAmount);
            double?lastAmount;

            lastAmount = account.LastAmount;

            if (isTotalRow)
            {
                convAmount = amount;
                if (!(isTotalView && lastAmount.HasValue))
                {
                    amount = "";
                }
                else
                {
                    double ret = account.Amount / lastAmount.Value - 1;
                    amount  = (ret > 0) ? "+" : "-";
                    amount += System.Math.Round(System.Math.Abs(ret) * 100, 1).ToString() + " %";
                }
            }

            double?changeAmount = null;
            string changeData   = "";

            if (lastAmount.HasValue)
            {
                changeAmount = account.ConvertedAmount - lastAmount.Value; //Watch out is Asset Account: BNP Shares
                ICcyAsset iCcy = account.Ccy.IsCcy() ? account.Ccy : account.ConvertedCcy;
                changeData = table.CcyToString(iCcy, changeAmount.Value);
            }

            var titles = new object[] {
                account.AccountName, account.Ccy, amount, convAmount, changeData
            };

            SetValues(titles);
            if (!account.IsCalculatedAccount || isTotalRow)
            {
                Cells[DataGridViewAccountingStatics.Column_Currency] =
                    new DataGridViewComboBoxCellAccounting(account.Ccy,
                                                           isTotalRow ? table.Ccies : table.CciesAndAssets);
            }
            if (account.IsCalculatedAccount)
            {
                Cells[DataGridViewAccountingStatics.Column_Amount].ReadOnly = true;
            }
            Cells[DataGridViewAccountingStatics.Column_ConvertedAmount].ReadOnly = true;

            if (isTotalRow)
            {
                for (int i = 0; i < Cells.Count; i++)
                {
                    Cells[i].Style.BackColor = Color.LightGray;
                    if (i != DataGridViewAccountingStatics.Column_Currency)
                    {
                        Cells[i].ReadOnly = true;
                    }
                }
            }

            if (account.Amount < 0)
            {
                for (int i = 2; i < 4; i++)
                {
                    Cells[i].Style.ForeColor = Color.Red;
                }
            }

            if (lastAmount.HasValue)
            {
                if (isTotalRow)
                {
                    Cells[DataGridViewAccountingStatics.Column_Amount].Style.ForeColor = (changeAmount.Value < 0) ? Color.Red : Color.Green;
                }
                Cells[DataGridViewAccountingStatics.Column_Change].Style.ForeColor = (changeAmount.Value < 0) ? Color.Red : Color.Green;
            }
        }
Ejemplo n.º 19
0
 public SummaryReport(ICcyAsset iCcyAsset = null, double amount = 0)
 {
     Data = new Dictionary <ICcyAsset, double> {
     };
     Set(iCcyAsset, amount);
 }
Ejemplo n.º 20
0
 public double Get(ICcyAsset iCcyAsset)
 {
     return(Ccies.Contains(iCcyAsset) ? Data[iCcyAsset] : 0);
 }
Ejemplo n.º 21
0
 public IAccount GetTotalAccount(FXMarket mkt, AssetMarket aMkt, ICcyAsset convCcy, string name, double?lastAmount)
 {
     return(TotalAccount(mkt, aMkt, convCcy.Ccy, name, lastAmount));
 }