Esempio n. 1
0
        public override int GetHashCode()
        {
            var hashCode = -904650435;

            hashCode = hashCode * -1521134295 + Portafoglio.GetHashCode();
            return(hashCode);
        }
Esempio n. 2
0
 public EthereumEtherscan(String indirizzo, ValutaFactory factory)
 {
     if (indirizzo == null || indirizzo == "")
     {
         throw new ArgumentException("Indirizzo non valido");
     }
     Portafoglio = new Portafoglio(indirizzo);
     _factory    = factory ?? throw new ArgumentException("factory non può essere null!");
 }
Esempio n. 3
0
 public BitcoinBlockexplorer(String indirizzo, ValutaFactory factory)
 {
     if (indirizzo == null || indirizzo == "")
     {
         throw new ArgumentException("Indirizzo non valido");
     }
     Portafoglio = new Portafoglio(indirizzo);
     _factory    = factory ?? throw new ArgumentException("factory non può essere null");
 }
Esempio n. 4
0
        public void ScaricaPortafoglio_IndirizzoStabile_Valore()
        {
            String            indirizzoStabile = "0x901476A5a3C504398967C745F236124201298016";
            Valuta            ethereum         = factory.OttieniValuta("ETH");
            Fondo             fondo            = new Fondo(ethereum, (decimal)3.129570488777777777);
            Portafoglio       atteso           = new Portafoglio(indirizzoStabile, fondo);
            EthereumEtherscan blockexplorer    = new EthereumEtherscan(indirizzoStabile, factory);
            Portafoglio       ris = blockexplorer.ScaricaPortafoglio().Result;

            Assert.AreEqual <Portafoglio>(ris, atteso);
        }
Esempio n. 5
0
        public void ScaricaPortafoglio_IndirizzoStabile_Valore()
        {
            String               indirizzoStabile = "1JaPNwMXt2AuVkWmkUHbsw78MbGorTfmm2";
            Valuta               bitcoin          = factory.OttieniValuta("BTC");
            Fondo                fondo            = new Fondo(bitcoin, (decimal)2194.51101);
            Portafoglio          atteso           = new Portafoglio(indirizzoStabile, fondo);
            BitcoinBlockexplorer blockexplorer    = new BitcoinBlockexplorer(indirizzoStabile, factory);
            Portafoglio          ris = blockexplorer.ScaricaPortafoglio().Result;

            Assert.AreEqual <Portafoglio>(ris, atteso);
        }
Esempio n. 6
0
        public PortafoglioViewModel(Portafoglio portafoglio)
        {
            Items = portafoglio.Items.Select(i => new PortafoglioItemViewModel
            {
                Ticker               = i.Ticker,
                Isin                 = i.Etf.Isin,
                Url                  = i.Etf.Url,
                Nome                 = i.Nome,
                Data                 = i.Data.ToString("d"),
                Quantita             = i.Quantita.ToString("N0"),
                PrezzoAcquisto       = i.Prezzo.ToString("N4"),
                ImportoAcquisto      = i.Importo.ToString("N2"),
                PrezzoCorrente       = i.PrezzoCorrente.ToString("N4"),
                ImportoCorrenteNetto = i.ImportoCorrenteNetto.ToString("N2"),
                Guadagno             = (i.ImportoCorrenteNetto - i.Importo).ToString("N2"),
                GuadagnoPercentuale  = ((i.ImportoCorrenteNetto - i.Importo) / i.Importo).ToString("P2"),
                Variazione           = i.Variazione,
                Dividendi            = i.Dividendi.HasValue ? i.Dividendi.Value.ToString("N2") : string.Empty,
                DataVendita          = DateTime.Now.ToString("dd/MM/yyyy"),
                PrezzoVendita        = i.PrezzoCorrente.ToString("N4")
            }).OrderByDescending(i => decimal.Parse(i.Guadagno)).ToList();

            var totaleAcquisto = portafoglio.Items.Sum(i => i.Importo);
            var totaleCorrente = portafoglio.Items.Sum(i => i.ImportoCorrenteNetto);

            TotaleAcquisto      = totaleAcquisto.ToString("N2");
            TotaleCorrente      = totaleCorrente.ToString("N2");
            Guadagno            = (totaleCorrente - totaleAcquisto).ToString("N2");
            GuadagnoPercentuale = ((totaleCorrente - totaleAcquisto) / totaleAcquisto).ToString("P2");
            var guadagnoTotale = totaleCorrente + portafoglio.Bilancio.Cash - portafoglio.Bilancio.Invested;

            GuadagnoTotale            = guadagnoTotale.ToString("N2");
            GuadagnoTotalePercentuale = (guadagnoTotale / (portafoglio.Bilancio.Invested)).ToString("P2");
            TotaleComplessivo         = (portafoglio.Bilancio.Cash + totaleCorrente).ToString("N2");
            TotaleInvestito           = portafoglio.Bilancio.Invested.ToString("N2");
            Cash         = portafoglio.Bilancio.Cash.ToString("N2");
            Minusvalenze = portafoglio.Bilancio.Minusvalenze.ToString("N2");
            DataBilancio = DateTime.Now.ToString("dd/MM/yyyy");

            var variazioni = portafoglio.Items.Select(i => decimal.Parse(i.Variazione.Replace("%", "")));

            Variazione = variazioni.Any() ? $"{variazioni.Average().ToString("N2")}%" : "";
        }
Esempio n. 7
0
 public TestBlockchain()
 {
     Nome         = "TestBlockchain";
     _portafoglio = new Portafoglio("TestIndirizzo");
 }
Esempio n. 8
0
 public void ScaricaPortafoglio_IndirizzoErrato_Eccezione()
 {
     EthereumEtherscan blockexplorer = new EthereumEtherscan("blabla", factory);
     Portafoglio       ris           = blockexplorer.ScaricaPortafoglio().Result;
 }
Esempio n. 9
0
 public void ScaricaPortafoglio_IndirizzoErrato_Eccezione()
 {
     BitcoinBlockexplorer blockexplorer = new BitcoinBlockexplorer("blabla", factory);
     Portafoglio          ris           = blockexplorer.ScaricaPortafoglio().Result;
 }