Ejemplo n.º 1
0
 /// <summary>
 /// Checks that the factor file exists on disk, and if it does, loads it into memory
 /// </summary>
 private FactorFile GetFactorFile(Symbol symbol, string permtick, string market)
 {
     if (FactorFile.HasScalingFactors(permtick, market))
     {
         var factorFile = FactorFile.Read(permtick, market);
         _cache.AddOrUpdate(symbol, factorFile, (s, c) => factorFile);
         return(factorFile);
     }
     // return null if not found
     return(null);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Checks that the factor file exists on disk, and if it does, loads it into memory
        /// </summary>
        private FactorFile GetFactorFile(Symbol symbol, string permtick, string market)
        {
            FactorFile factorFile = null;

            if (FactorFile.HasScalingFactors(permtick, market))
            {
                factorFile = FactorFile.Read(permtick, market);
                _cache.AddOrUpdate(symbol, factorFile, (s, c) => factorFile);
            }
            else
            {
                // add null value to the cache, we don't want to check the disk multiple times
                // but keep existing value if it exists, just in case
                _cache.AddOrUpdate(symbol, factorFile, (s, oldValue) => oldValue);
            }
            return(factorFile);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Checks that the factor file exists on disk, and if it does, loads it into memory
        /// </summary>
        private FactorFile GetFactorFile(Symbol symbol, string permtick, string market)
        {
            FactorFile factorFile = null;

            var path = Path.Combine(Globals.CacheDataFolder, "equity", market, "factor_files", permtick.ToLowerInvariant() + ".csv");

            var factorFileStream = _dataProvider.Fetch(path);

            if (factorFileStream != null)
            {
                factorFile = FactorFile.Read(permtick, factorFileStream);
                factorFileStream.DisposeSafely();
                _cache.AddOrUpdate(symbol, factorFile, (s, c) => factorFile);
            }
            else
            {
                // add null value to the cache, we don't want to check the disk multiple times
                // but keep existing value if it exists, just in case
                _cache.AddOrUpdate(symbol, factorFile, (s, oldValue) => oldValue);
            }
            return(factorFile);
        }
Ejemplo n.º 4
0
 private static FactorFile GetTestFactorFile(string symbol, DateTime reference)
 {
     var file = new FactorFile(symbol, new List<FactorFileRow>
     {
         new FactorFileRow(reference, 1, 1),
         new FactorFileRow(reference.AddDays(-7), .9m, 1),       // dividend
         new FactorFileRow(reference.AddDays(-14), .8m, 1),      // dividend
         new FactorFileRow(reference.AddDays(-21), .8m, .5m),    // split
         new FactorFileRow(reference.AddDays(-90), .8m, .25m),   // split
         new FactorFileRow(reference.AddDays(-365), .7m, .125m) // split+dividend
     });
     return file;
 }