public void SaveState()
        {
            List <string[]> array_list = new List <string[]>();

            array_list.Add(new string[]
            {
                LastUpdateDateTime.ToString(),
                "",
                "",
                "",
                ""
            });

            foreach (TradingCalenderEvent trading_calender_event in event_list)
            {
                array_list.Add(new string[]
                {
                    trading_calender_event.EventTimeUTC.ToString(),
                    trading_calender_event.Symbol,
                    trading_calender_event.Description,
                    trading_calender_event.IsAllDay.ToString(),
                    ToolsString.DictionaryToString(trading_calender_event.Tags)
                });
            }


            ToolsIOCSV.WriteCSVFile(database_path, ToolsCollection.ConvertToArray2D(array_list));
        }
Ejemplo n.º 2
0
        public static void ComposeBinary(TradingSymbol trading_symbol)
        {
            string source_data_path = Path.Combine(source_data_root_path, trading_symbol.Broker, trading_symbol.Account, trading_symbol.Symbol);
            string target_data_path = Path.Combine(binary_data_root_path, trading_symbol.Broker, trading_symbol.Account, trading_symbol.Symbol);

            if (!Directory.Exists(source_data_path))
            {
                throw new Exception("No data for trading symbol: " + trading_symbol);
            }
            string[] files = Directory.GetFiles(source_data_path);
            if (files.Length == 0)
            {
                throw new Exception("No data for trading symbol: " + trading_symbol);
            }
            Array.Sort(files);

            List <Price> price_list = new List <Price>();

            foreach (string file in files)
            {
                AddFileToPriceList(price_list, file);
            }
            PriceSet    price_set       = new PriceSet(ToolsPrice.DefaultSymbolGBPUSD, price_list);
            DateTimeUTC date_time_first = price_set.OpenDateTime;
            DateTimeUTC date_time_last  = price_set.CloseDateTime;

            target_data_path = Path.Combine(target_data_path, date_time_first.ToString("yyyyMMddHHmmss") + "_" + date_time_last.ToString("yyyyMMddHHmmss") + ".blb");

            string target_data_path_dir = Path.GetDirectoryName(target_data_path);

            if (!Directory.Exists(target_data_path_dir))
            {
                Directory.CreateDirectory(target_data_path_dir);
            }

            using (BinaryWriter writer = new BinaryWriter(new FileStream(target_data_path, FileMode.Create)))
            {
                price_set.Write(writer);
            }
        }