Ejemplo n.º 1
0
        static async Task <List <CLASS_Ticker_DataBase> > LIST_Get_Database_Of_Ticker(string Ticker, double DaysToGoBack = 60)
        {
            List <CLASS_Ticker_DataBase> LIST_DATABase = new List <CLASS_Ticker_DataBase>();

            Yahoo.IgnoreEmptyRows = true;

            if (DaysToGoBack < 0)
            {
                DaysToGoBack = -1 * DaysToGoBack;
            }

            IReadOnlyList <Candle> Data = await Yahoo.GetHistoricalAsync(Ticker, DateTime.Today.AddDays(-1 * DaysToGoBack), DateTime.Today, Period.Daily);

            CLASS_Ticker_DataBase OBJECT_DataBase_Day = new CLASS_Ticker_DataBase();

            foreach (Candle Date in Data)
            {
                OBJECT_DataBase_Day       = new CLASS_Ticker_DataBase();
                OBJECT_DataBase_Day.Date  = Date.DateTime;
                OBJECT_DataBase_Day.Open  = Decimal.ToDouble(Date.Open);
                OBJECT_DataBase_Day.Close = Decimal.ToDouble(Date.Close);
                OBJECT_DataBase_Day.High  = Decimal.ToDouble(Date.High);
                OBJECT_DataBase_Day.Low   = Decimal.ToDouble(Date.Low);
                LIST_DATABase.Add(OBJECT_DataBase_Day);
            }

            return(LIST_DATABase);
        }
Ejemplo n.º 2
0
        // ---------------------------------------------------------------------------------------------------------------
        // FUNCTIONS

        static List <CLASS_Ticker_DataBase> Sample_Data_List(List <CLASS_Ticker_DataBase> Database, System.DateTime Date, int Sample_Ammount, int Days_To_Skip = 0)
        {
            List <CLASS_Ticker_DataBase> Sampled_Database = new List <CLASS_Ticker_DataBase>();
            CLASS_Ticker_DataBase        Sampled          = new CLASS_Ticker_DataBase();

            int New_End = 0;

            for (int i = 0; i <= Database.Count - 1; i++)
            {
                if (Database[i].Date == Date)
                {
                    New_End = i - Days_To_Skip; break;
                }
            }

            int New_Start = New_End - Sample_Ammount + 1; if (New_Start < 0)

            {
                New_Start = 0;
            }

            for (int i = New_Start; i <= New_End - Days_To_Skip; i++)
            {
                Sampled = new CLASS_Ticker_DataBase();
                Sampled = Database[i];
                Sampled_Database.Add(Sampled);
            }

            return(Sampled_Database);
        }