Example #1
0
 public static void AddFileToPriceList(List <Price> price_list, string file)
 {
     string[,] table = ToolsIOCSV.ReadCSVFile(file);
     for (int index_0 = 0; index_0 < table.GetLength(0); index_0++)
     {
         //TODO duplicate date_times can exist both on the server and on the client
         DateTimeUTC date_time = ToolsTime.UnixTimeStampToDateTimeUTC(int.Parse(table[index_0, 1]));
         double      bid       = double.Parse(table[index_0, 2], CultureInfo.InvariantCulture);
         double      ask       = double.Parse(table[index_0, 3], CultureInfo.InvariantCulture);
         price_list.Add(new Price(date_time, bid, ask));
     }
 }
Example #2
0
        private PriceSet ImportSecondData(string file_path)
        {
            string        symbol         = Path.GetFileName(file_path).Substring(0, 6);
            TradingSymbol trading_symbol = new TradingSymbol("TradersWay", "MT4.VAR.DEMO", symbol, "The one we mine on the VM");
            List <Price>  price_list     = new List <Price>();

            string[,] table = ToolsIOCSV.ReadCSVFile(file_path);
            for (int index_0 = 0; index_0 < table.GetLength(0); index_0++)
            {
                //TODO duplicate date_times can exist both on the server and on the client
                DateTimeUTC date_time = ToolsTime.UnixTimeStampToDateTimeUTC(int.Parse(table[index_0, 0]));
                double      bid       = double.Parse(table[index_0, 2], CultureInfo.InvariantCulture);
                double      ask       = double.Parse(table[index_0, 3], CultureInfo.InvariantCulture);
                price_list.Add(new Price(date_time, bid, ask));
            }

            return(new PriceSet(trading_symbol, price_list));
        }
Example #3
0
        private static List <PriceCandle> ReadHST400(BinaryReader reader, long file_size, TimeScale time_scale, double spread)
        {
            // bars array(single-byte justification) . . . total 44 bytes
            long line_count         = (file_size - 148) / 44;
            List <PriceCandle> data = new List <PriceCandle>();

            for (int i = 0; i < line_count; i++)
            {
                reader.ReadBytes(4);
                DateTimeUTC open_date_time = ToolsTime.UnixTimeStampToDateTimeUTC(reader.ReadInt32());
                double      open           = reader.ReadDouble(); // open price	8 bytes
                double      low            = reader.ReadDouble(); // lowest price	8 bytes
                double      high           = reader.ReadDouble(); // highest price	8 bytes
                double      close          = reader.ReadDouble(); // close price	8 bytes
                double      volume         = reader.ReadDouble(); // tick count	8 bytes
                data.Add(new PriceCandle(open_date_time, time_scale, open, high, low, close, volume, spread));
            }
            return(data);
        }
Example #4
0
        private static List <PriceCandle> ReadHST401(BinaryReader reader, long file_size, TimeScale time_scale)
        {
            //then the bars array(single-byte justification) . . . total 60 bytes
            long line_count         = (file_size - 148) / 60;
            List <PriceCandle> data = new List <PriceCandle>();

            for (int i = 0; i < line_count; i++)
            {
                DateTimeUTC open_date_time = ToolsTime.UnixTimeStampToDateTimeUTC(reader.ReadInt64()); // bar start time	8 bytes
                double      open           = reader.ReadDouble();                                      // open price	8 bytes
                double      high           = reader.ReadDouble();                                      // highest price	8 bytes
                double      low            = reader.ReadDouble();                                      // lowest price	8 bytes
                double      close          = reader.ReadDouble();                                      // close price	8 bytes
                long        volume         = reader.ReadInt64();                                       // tick count	8 bytes
                int         spread         = reader.ReadInt32();;                                      // spread	4 bytes
                long        real_volume    = reader.ReadInt64();                                       // real volume	8 bytes
                data.Add(new PriceCandle(open_date_time, time_scale, open, high, low, close, volume, spread, real_volume));
            }

            return(data);
        }