Beispiel #1
0
        private void LoadCalendar()
        {
            try {
                var file = GetCalendarDataFile();
                if (File.Exists(file))
                {
                    var list      = JToken.Parse(QBHelper.ReadOnlyAllText(file));
                    var firstDate = ParseDateTime(list.First);
                    var days      = new TradingDayList(firstDate.AddDays(-firstDate.DayOfYear + 1), CalendarEnd);
                    var current   = list.First;
                    while (current != null)
                    {
                        var date = ParseDateTime(current);
                        days[date] = true;
                        current    = current.Next;
                    }
                    days.SetHoliday();
                    DayList = days;
                }
            }
            catch (Exception e) {
                Logger.Warn($@"LoadCalendar [{e}]");
            }

            DateTime ParseDateTime(JToken current)
            {
                return(DateTime.ParseExact((string)current, "yyyyMMdd", null));
            }
        }
        private static List <T> LoadItems <T>(string path, string name)
        {
            var file = Path.Combine(Path.GetDirectoryName(path), $"{Path.GetFileNameWithoutExtension(path)}.{name}.json");

            if (File.Exists(file))
            {
                return(JsonConvert.DeserializeObject <List <T> >(QBHelper.ReadOnlyAllText(file)));
            }
            return(new List <T>());
        }
        public static OrderAgentInfo Load()
        {
            var settingsFile = GetSettingsFile();

            if (File.Exists(settingsFile))
            {
                return(JsonConvert.DeserializeObject <OrderAgentInfo>(QBHelper.ReadOnlyAllText(settingsFile)));
            }
            return(new OrderAgentInfo());
        }
 public static XProviderSettings Load(string path)
 {
     if (File.Exists(path))
     {
         var settings = JsonConvert.DeserializeObject <XProviderSettings>(QBHelper.ReadOnlyAllText(path));
         settings.Users        = LoadItems <UserInfo>(path, nameof(Users));
         settings.Servers      = LoadItems <ServerInfo>(path, nameof(Servers));
         settings.Connections  = LoadItems <ConnectionInfo>(path, nameof(Connections));
         settings.SessionTimes = LoadItems <TimeRange>(path, nameof(SessionTimes));
         return(settings);
     }
     return(null);
 }
Beispiel #5
0
 private void LoadTimeRange()
 {
     try {
         var file = GetTimeRangeDataFile();
         if (File.Exists(file))
         {
             var manager = new TradingTimeManager();
             manager.Load(JsonConvert.DeserializeObject <string[][]>(QBHelper.ReadOnlyAllText(file)));
             TimeManager = manager;
         }
     }
     catch (Exception e) {
         Logger.Warn($@"LoadTimeRange [{e}]");
     }
 }
        private void LoadTimeRange(string file = null)
        {
            file = file ?? GetTimeRangeDataFile();
            if (!File.Exists(file))
            {
                return;
            }
            var content = QBHelper.ReadOnlyAllText(file);

            try {
                var manager = new TradingTimeManager();
                manager.Load(JsonConvert.DeserializeObject <string[][]>(content));
                TimeManager = manager;
            }
            catch (Exception e) {
                Logger.Warn($"LoadTimeRange [{e.Message}]");
            }
        }