Beispiel #1
0
        public static void Main()
        {
            Configuration.Default.AddApiKey("api_key", "YOUR_API_KEY");

            var securityApi = new SecurityApi();
            var identifier  = "AAPL";       // string | A Security identifier (Ticker, FIGI, ISIN, CUSIP, Intrinio ID)
            var startDate   = "2019-01-01"; // DateTime? | Return prices on or after the date (optional)
            var endDate     = "2019-02-01"; // DateTime? | Return prices on or before the date (optional)
            var frequency   = "daily";      // string | Return stock prices in the given frequency (optional)  (default to daily)
            var pageSize    = 100;          // decimal? | The number of results to return (optional)  (default to 100)
            var nextPage    = "";           // string | Gets the next page of data from a previous API call (optional)

            try
            {
                ApiResponseSecurityStockPrices result = securityApi.GetSecurityStockPrices(identifier, DateTime.Parse(startDate), DateTime.Parse(endDate), frequency, pageSize, nextPage);

                result.StockPrices.ForEach((StockPriceSummary stockPriceSummary) => Console.WriteLine(stockPriceSummary));
            }
            catch (Exception e)
            {
                Debug.Print("Exception when calling SecurityApi.GetSecurityStockPrices: " + e.Message);
            }
        }
Beispiel #2
0
        //public List<StockPriceSummary> Savior { get; } {

        //    //move the stock List / array / whatever to here so we can access it on the website


        //}

        public static void DoThis(string identifier = "AAPL", int pageSize = 3, string startDate = "2019-01-01", string freq = "daily")
        {
            Configuration.Default.AddApiKey("api_key", "OjEzNDI0MDg2ZGU4NGI2Yjc2N2ZjYWIzNDYwM2E0MDk3");

            var securityApi = new SecurityApi();
            var endDate     = DateTime.Now.ToString(); // should just leave this as a DateTime and not ToString and Parse - but what if we enter it as a dropdown later?
            //var freq = "daily";
            var nextPage = "";                         // boolean?
            List <StockPriceSummary> save = new List <StockPriceSummary>();

            try
            {
                ApiResponseSecurityStockPrices result = securityApi.GetSecurityStockPrices(identifier, DateTime.Parse(startDate), DateTime.Parse(endDate), freq, pageSize, nextPage);

                result.StockPrices.ForEach((StockPriceSummary stockPriceSummary) => Console.WriteLine(stockPriceSummary)); //save.Add(stockPriceSummary);
            }


            catch (Exception e)
            {
                Debug.Print("Exception when calling SecurityApi.GetSecurityStockPrices: " + e.Message);
            }
        }
Beispiel #3
0
        public static List <StockPriceData> ProcessData()
        {
            List <StockPriceData> resultData = new List <StockPriceData>();

            string[] stocks = { "EQTCS", "EQSBIN", "EQRELIANCE", "EQMARUTI", "EQKOTAKBANK", "EQICICIBANK", "EQAXISBANK" };

            Configuration.Default.AddApiKey("api_key", "OmY2ODg5ZmFjMWZiNWMxMzM3YTE4OTYyMWMxNzMxMDJh");
            var identifier = "EQTCS";

            // taking current date
            var endDate   = DateTime.Parse(DateTime.Today.ToString("yyyy-MM-dd"));
            var startDate = DateTime.Parse(DateTime.Today.AddDays(-20).ToString("yyyy-MM-dd"));

            // pass dates for back testing
            //var startDate = DateTime.Parse("2020-05-01");
            //var endDate = DateTime.Parse("2020-05-09");

            var frequency = "daily";
            var pageSize  = 100;
            var nextPage  = "";

            try
            {
                foreach (var item in stocks)
                {
                    identifier = item;
                    ApiResponseSecurityStockPrices result = securityApi.GetSecurityStockPrices(identifier, startDate, endDate, frequency, pageSize, nextPage);
                    var tee = result.StockPrices.Take(10).ToList();
                    ApiResponseSecurityStockPrices result1 = new ApiResponseSecurityStockPrices()
                    {
                        StockPrices = tee
                    };

                    var json = JObject.Parse(result1.ToJson());

                    // get low
                    var properties = json.DescendantsAndSelf()
                                     .OfType <JProperty>()
                                     .Where(p => p.Name == "low");

                    var lowProperty = properties
                                      .Aggregate((p1, p2) => p1.Value.Value <double>() < p2.Value.Value <double>() ? p1 : p2);

                    var highProperty = (lowProperty?.Parent as JObject)?.Property("high");

                    // get high
                    var propertiesHigh = json.DescendantsAndSelf()
                                         .OfType <JProperty>()
                                         .Where(p => p.Name == "high");

                    var lowPropertyHigh = propertiesHigh
                                          .Aggregate((p1, p2) => p1.Value.Value <double>() > p2.Value.Value <double>() ? p1 : p2);

                    var highPropertyHigh = (lowPropertyHigh?.Parent as JObject)?.Property("low");

                    resultData.Add(new StockPriceData()
                    {
                        buyprice = highProperty.Value.ToString(), lowstoploss = lowProperty.Value.ToString(), shortprice = highPropertyHigh.Value.ToString(), highstoploss = lowPropertyHigh.Value.ToString(), stock = identifier
                    });
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception when calling SecurityApi.GetSecurityStockPrices: " + ex.Message);
            }
            return(resultData);
        }