Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="symbol"></param>
        /// <param name="timeseries"></param>
        /// <param name="interval"></param>
        /// <param name="outputsize"></param>
        /// <param name="apikey"></param>
        /// <returns></returns>
        public static MarketData Stock(string symbol, AVTimeSeries timeseries, AVInterval interval, AVOutputSize outputsize, string apikey)
        {
            MarketData dataTmp = new MarketData(symbol);

            List <APIParameter> parameters = new List <APIParameter>()
            {
                new APIParameter("function", timeseries.GetValue()),
                new APIParameter("symbol", symbol),
                new APIParameter("interval", interval.GetValue()),
                new APIParameter("outputsize", outputsize.GetValue()),
                new APIParameter("apikey", apikey),
                new APIParameter("datatype", "csv")
            };

            int[]  dataMap = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
            string url     = AlphaVantageHelper.CreateURL(parameters);
            string rawData = AlphaVantageHelper.RequestRawData(url);

            if (!string.IsNullOrEmpty(rawData))
            {
                string[] result = Regex.Split(rawData, "\r\n|\r|\n");
                AlphaVantageHelper.ProcessRawData(result, ref dataTmp.Bars, dataMap);
            }

            return(dataTmp);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="symbol"></param>
        /// <param name="market"></param>
        /// <param name="timeseries"></param>
        /// <param name="apikey"></param>
        /// <returns></returns>
        public static MarketData Digital_Currency(string symbol, string market, AVTimeSeries timeseries, string apikey)
        {
            MarketData dataTmp = new MarketData(symbol, market);

            List <APIParameter> parameters = new List <APIParameter>()
            {
                new APIParameter("function", timeseries.GetValue()),
                new APIParameter("symbol", symbol),
                new APIParameter("market", market),
                new APIParameter("apikey", apikey),
                new APIParameter("datatype", "csv")
            };

            int[] dataMap = new int[] { 0, 1, 2, 3, 4, 9 };

            AlphaVantageHelper.ProcessRawData(AlphaVantageHelper.RequestRawData(AlphaVantageHelper.CreateURL(parameters)).Split(Environment.NewLine), ref dataTmp.Bars, dataMap);

            return(dataTmp);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="symbol"></param>
        /// <param name="timeseries"></param>
        /// <param name="outputsize"></param>
        /// <param name="apikey"></param>
        /// <returns></returns>
        public static MarketData Stock(string symbol, AVTimeSeries timeseries, AVOutputSize outputsize, string apikey)
        {
            MarketData dataTmp = new MarketData(symbol);

            List <APIParameter> parameters = new List <APIParameter>()
            {
                new APIParameter("function", timeseries.GetValue()),
                new APIParameter("symbol", symbol),
                new APIParameter("outputsize", outputsize.GetValue()),
                new APIParameter("apikey", apikey),
                new APIParameter("datatype", "csv")
            };

            int[] dataMap = new int[] { 0, 1, 2, 3, 4, 5 };

            AlphaVantageHelper.ProcessRawData(AlphaVantageHelper.RequestRawData(AlphaVantageHelper.CreateURL(parameters)).Split(Environment.NewLine), ref dataTmp.Bars, dataMap);

            return(dataTmp);
        }