public override ValueInvestingCompanyDBModel WebClientAPICall(ValueInvestingCompanyDBModel company)
        {
            string    Json   = "";
            WebClient client = new WebClient();

            Json = client.DownloadString($"https://financialmodelingprep.com/api/v3/financials/cash-flow-statement/{ company.STOCK_TICKER}");



            var OCJson = CashFlow_Top_Level.FromJson(Json);

            Console.WriteLine("Writting to Book Value DB");
            foreach (var item in OCJson.Financials)
            {
                Dividends_DB_Model dividends = new Dividends_DB_Model {
                    DATE = (item.Date), DIVIDENDS = (item.DividendPayments), STOCK_TICKER = company.STOCK_TICKER
                };
                SQL.WriteDividendsData(dividends);
            }



            Random rnd = new Random();

            company.DIVIDENDS = Convert.ToDouble(rnd.Next());

            return(company);
        }
예제 #2
0
        //making a webclient call syncly
        public override ValueInvestingCompanyDBModel WebClientAPICall(ValueInvestingCompanyDBModel company)
        {
            string    Json   = "";
            WebClient client = new WebClient();

            Json = client.DownloadString($"https://financialmodelingprep.com/api/v3/financials/cash-flow-statement/{ company.STOCK_TICKER}");

            //StockPriceModel Sp_json = JsonConvert.DeserializeObject<StockPriceModel>(Json);

            var OCJson = CashFlow_Top_Level.FromJson(Json);

            Console.WriteLine("Writting to Operating_Cash DB");
            foreach (var item in OCJson.Financials)
            {
                Operating_Cash_DB_Model OperatingCash = new Operating_Cash_DB_Model {
                    DATE = (item.Date), OPERATING_CASH_FLOW = (item.OperatingCashFlow), STOCK_TICKER = company.STOCK_TICKER
                };
                SQL.WriteOperatingCashData(OperatingCash);
            }



            //Operating_Cash_DB_Model OperatingCash = new Operating_Cash_DB_Model { DATE = (OCJson.Symbol[0]), OPERATING_CASH_FLOW = OCJson.  , STOCK_TICKER = company.STOCK_TICKER };

            //SQL.WriteCurrentFinancialsData(StockPrice);



            Random rnd = new Random();

            company.OPERATING_CASH = Convert.ToDouble(rnd.Next());

            return(company);
        }
예제 #3
0
        public override ValueInvestingCompanyDBModel WebClientAPICall(ValueInvestingCompanyDBModel company)
        {
            Random rnd = new Random();

            company.SALES = Convert.ToDouble(rnd.Next());

            return(company);
        }
예제 #4
0
        public override void WriteDate(ValueInvestingCompanyDBModel ViCoModel)
        {
            using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
            {
                cnn.Execute("insert into Value_Investing_Companies ( STOCK_TICKER , CO_NAME , STOCK_PRICE  , DIVIDENDS , OPERATING_CASH, SHAREHOLDER_EQUITY, SALES) values ( @STOCK_TICKER , @CO_NAME , @STOCK_PRICE  , @DIVIDENDS , @OPERATING_CASH, @SHAREHOLDER_EQUITY, @SALES)", ViCoModel);
            }


            Console.WriteLine("Writting to Value_Investing_Companies DB");
        }
예제 #5
0
        static async Task  Main(string[] args)
        {
            Console.WriteLine("What is the stock name (ticker) you are looking for?");
            string stockName = Console.ReadLine().ToUpper();

            Console.WriteLine("What is the the name of that company?");
            string companyName = Console.ReadLine().ToUpper();

            Console.WriteLine($"Starting Process for {stockName}");

            //used to connect to api
            ApiHelper.InitializeClient();
            //creates new object of the above inputs
            ValueInvestingCompanyDBModel newCo = new ValueInvestingCompanyDBModel {
                CO_NAME = companyName, STOCK_TICKER = stockName
            };


            ProcessFactory processorFactory = new ProcessFactory();

            Processor StockPrice     = processorFactory.CreateInstance("StockPriceProcessor");
            var       StockPriceTask = StockPrice.WebClientAPICallAsync(newCo);
            var       stockprice     = await StockPriceTask;



            Processor OperatingCash     = processorFactory.CreateInstance("OperatingCashProcessor");
            var       OperatingCashTask = OperatingCash.WebClientAPICallAsync(newCo);
            var       operatingcash     = await OperatingCashTask;


            Processor BookValue     = processorFactory.CreateInstance("BookValue__Plus_Dividends_Processor");
            var       BookValueTask = BookValue.WebClientAPICallAsync(newCo);
            var       bookvalue     = await BookValueTask;


            Processor NetIncome     = processorFactory.CreateInstance("NetIncomeProcessor");
            var       NetIncomeTask = NetIncome.WebClientAPICallAsync(newCo);
            var       netincome     = await NetIncomeTask;

            Processor Sales     = processorFactory.CreateInstance("SalesProcessor");
            var       SalesTask = Sales.WebClientAPICallAsync(newCo);
            var       salestask = await SalesTask;


            //switch this to using dependecny injection. per https://www.youtube.com/watch?v=qJmEI2LtXIY&t=2s
            Value_Investing_Mode_Repository valueInvestingModeRepository = new Value_Investing_Mode_Repository_Postgres();

            valueInvestingModeRepository.WriteDate(newCo);
            valueInvestingModeRepository.ReadData();
        }
예제 #6
0
        //making a webclient call syncly
        public override ValueInvestingCompanyDBModel WebClientAPICall(ValueInvestingCompanyDBModel company)
        {
            string    Json   = "";
            WebClient client = new WebClient();

            Json = client.DownloadString($"https://financialmodelingprep.com/api/v3/stock/real-time-price/{ company.STOCK_TICKER}");

            StockPriceModel Sp_json = JsonConvert.DeserializeObject <StockPriceModel>(Json);


            //writting to stock price db
            Current_StockPrice_DB_Model StockPrice = new Current_StockPrice_DB_Model {
                STOCK_PRICE = (Convert.ToDouble(Sp_json.Price)), STOCK_TICKER = company.STOCK_TICKER
            };

            SQL.WriteCurrentStockPriceData(StockPrice);

            //assigning stock price to company object
            company.STOCK_PRICE = StockPrice.STOCK_PRICE;

            return(company);
        }
예제 #7
0
 public virtual void WriteDate(ValueInvestingCompanyDBModel company)
 {
 }
예제 #8
0
        public override async Task <ValueInvestingCompanyDBModel> WebClientAPICallAsync(ValueInvestingCompanyDBModel company)
        {
            string salesUrl = $"https://financialmodelingprep.com/api/v3/financials/income-statement/{ company.STOCK_TICKER}";

            Console.WriteLine("Processing SalesProcessor.WebClientAPICallAsync");

            using (HttpResponseMessage response = await ApiHelper.ApiClient.GetAsync(salesUrl))
            {
                if (response.IsSuccessStatusCode)
                {
                    Income_Statement_Rootobject ISresult = await response.Content.ReadAsAsync <Income_Statement_Rootobject>();

                    //foreach (var item in ISresult.financials)
                    //{
                    //    Console.WriteLine("Total Net Income: " + item.NetIncome);
                    //}

                    List <double> growth = new List <double>();

                    for (int i = 0; i < ISresult.financials.Length; i++)
                    {
                        if (i == 0)
                        {
                        }
                        else
                        {
                            double change = CalculateChange(ISresult.financials[i - 1].Revenue, ISresult.financials[i].Revenue);
                            growth.Add(change);
                        }
                    }

                    double CalculateChange(double previous, double current)
                    {
                        if (previous == 0)
                        {
                            throw new InvalidOperationException();
                        }

                        var change = current - previous;

                        return((double)change / previous);
                    }

                    Console.WriteLine("Sales growth for " + ISresult.financials.Length.ToString() + " years  is : " + growth.Average());


                    company.SALES = growth.Average();


                    return(company);
                }
                else
                {
                    throw new Exception(response.ReasonPhrase);
                }
            }
        }
        //making a call async
        public override async Task <ValueInvestingCompanyDBModel> WebClientAPICallAsync(ValueInvestingCompanyDBModel company)
        {
            string url = $"https://financialmodelingprep.com/api/v3/financials/cash-flow-statement/{ company.STOCK_TICKER}";


            using (HttpResponseMessage response = await ApiHelper.ApiClient.GetAsync(url))
            {
                if (response.IsSuccessStatusCode)
                {
                    Console.WriteLine("Processing Dividends for BookValue__Plus_Dividends_Processor.WebClientAPICallAsync");
                    CashFlow_Top_Level result = await response.Content.ReadAsAsync <CashFlow_Top_Level>();

                    //foreach (var item in result.Financials)
                    //{
                    //    Console.WriteLine(item.DividendPayments);
                    //}
                    List <double> growth = new List <double>();

                    for (int i = 0; i < result.Financials.Length; i++)
                    {
                        if (i == 0)
                        {
                        }
                        else
                        {
                            double change = CalculateChange(result.Financials[i - 1].DividendPayments, result.Financials[i].DividendPayments);
                            growth.Add(change);
                            Console.WriteLine("dividend growth for " + i);
                            Console.WriteLine(change);
                        }
                    }

                    double CalculateChange(double previous, double current)
                    {
                        if (previous == 0)
                        {
                            previous = .001;
                        }

                        var change = current - previous;

                        return((double)change / previous);
                    }

                    Console.WriteLine("Dividends growth for " + result.Financials.Length.ToString() + " years  is : " + growth.Average());


                    company.DIVIDENDS = growth.Average();
                }
                else
                {
                    Console.WriteLine("Somethign went wrong");
                    throw new Exception(response.ReasonPhrase);
                }
            }

            string shareholderequityURL = $"https://financialmodelingprep.com/api/v3/financials/balance-sheet-statement/{ company.STOCK_TICKER}";


            using (HttpResponseMessage response = await ApiHelper.ApiClient.GetAsync(shareholderequityURL))
            {
                if (response.IsSuccessStatusCode)
                {
                    Console.WriteLine("Processing Total Share holders Equity for BookValue__Plus_Dividends_Processor.WebClientAPICallAsync");
                    Balance_Sheet_Rootobject BSresult = await response.Content.ReadAsAsync <Balance_Sheet_Rootobject>();

                    //foreach (var item in BSresult.financials)
                    //{
                    //    Console.WriteLine("Total Share holders Equity: " + item.Totalshareholdersequity);
                    //}
                    List <double> shegrowth = new List <double>();

                    for (int i = 0; i < BSresult.financials.Length; i++)
                    {
                        if (i == 0)
                        {
                        }
                        else
                        {
                            double change = CalculateChange(BSresult.financials[i - 1].Totalshareholdersequity, BSresult.financials[i].Totalshareholdersequity);
                            shegrowth.Add(change);
                        }
                    }

                    double CalculateChange(double previous, double current)
                    {
                        if (previous == 0)
                        {
                            previous = .001;
                        }

                        var change = current - previous;

                        return((double)change / previous);
                    }

                    Console.WriteLine("Shareholder Equity growth for " + BSresult.financials.Length.ToString() + " years  is : " + shegrowth.Average());


                    company.SHAREHOLDER_EQUITY = shegrowth.Average();



                    return(company);
                }
                else
                {
                    throw new Exception(response.ReasonPhrase);
                }
            }
        }
예제 #10
0
 public virtual ValueInvestingCompanyDBModel WebClientAPICall(ValueInvestingCompanyDBModel company)
 {
     return(company);
 }
예제 #11
0
 public virtual async Task <ValueInvestingCompanyDBModel> WebClientAPICallAsync(ValueInvestingCompanyDBModel company)
 {
     return(company);
 }
예제 #12
0
        //making a call async
        public override async Task <ValueInvestingCompanyDBModel> WebClientAPICallAsync(ValueInvestingCompanyDBModel company)
        {
            string url = $"https://financialmodelingprep.com/api/v3/stock/real-time-price/{ company.STOCK_TICKER}";

            using (HttpResponseMessage response = await ApiHelper.ApiClient.GetAsync(url))
            {
                if (response.IsSuccessStatusCode)
                {
                    StockPriceModel result = await response.Content.ReadAsAsync <StockPriceModel>();

                    company.STOCK_PRICE = result.Price;

                    Console.WriteLine("Processing StockPriceProcessor.WebClientAPICallAsync");
                    return(company);
                }
                else
                {
                    throw new Exception(response.ReasonPhrase);
                }
            }
        }
예제 #13
0
        //making a call async
        public override async Task <ValueInvestingCompanyDBModel> WebClientAPICallAsync(ValueInvestingCompanyDBModel company)
        {
            string url = $"https://financialmodelingprep.com/api/v3/financials/cash-flow-statement/{ company.STOCK_TICKER}";

            using (HttpResponseMessage response = await ApiHelper.ApiClient.GetAsync(url))
            {
                if (response.IsSuccessStatusCode)
                {
                    Console.WriteLine("Processing OperatingCash.WebClientAPICallAsync");
                    CashFlow_Top_Level result = await response.Content.ReadAsAsync <CashFlow_Top_Level>();

                    //foreach (var item in result.Financials)
                    //{
                    //    Console.WriteLine("Operating cash : " + item.OperatingCashFlow);
                    //}

                    List <double> growth = new List <double>();

                    for (int i = 0; i < result.Financials.Length; i++)
                    {
                        if (i == 0)
                        {
                            //growth.Add(OCJson.Financials[i].OperatingCashFlow);
                        }
                        else
                        {
                            double change = CalculateChange(result.Financials[i - 1].OperatingCashFlow, result.Financials[i].OperatingCashFlow);
                            growth.Add(change);
                            //Console.WriteLine("growth for " + i);
                            //Console.WriteLine(change);
                        }
                    }

                    double CalculateChange(double previous, double current)
                    {
                        if (previous == 0)
                        {
                            throw new InvalidOperationException();
                        }

                        var change = current - previous;

                        return((double)change / previous);
                    }

                    Console.WriteLine("Operating Cash growth for " + result.Financials.Length.ToString() + " years  is : " + growth.Average());


                    company.OPERATING_CASH = growth.Average();


                    return(company);
                }
                else
                {
                    throw new Exception(response.ReasonPhrase);
                }
            }
        }