public static List <Rate> GetRateFromDBBackward(string pair, DateTime endDate, int barsCount, int minutesPerPriod) { return(GlobalStorage.UseForexContext(context => { IQueryable <t_Bar> bars = context.t_Bar .Where(b => b.Pair == pair && b.Period == minutesPerPriod && b.StartDate <= endDate) .OrderByDescending(b => b.StartDate).Take(barsCount); return GetRatesFromDBBars(bars); })); }
public static List <Rate> GetRateFromDB(string pair, DateTime startDate, int barsCount, int minutesPerBar) { return(GlobalStorage.UseForexContext(c => { var q = c.t_Bar .Where(b => b.Pair == pair && b.Period == minutesPerBar && b.StartDate >= startDate) .OrderBy(b => b.StartDate).Take(barsCount); return GetRatesFromDBBars(q); })); }
static List <TBar> GetRateFromDBForwardsInternal <TBar>(string pair, DateTimeOffset startDate, int barsCount, int minutesPerPriod) where TBar : BarBase, new() { return(GlobalStorage.UseForexContext(context => { var bars = context.t_Bar .Where(b => b.Pair == pair && b.Period == minutesPerPriod && b.StartDate >= startDate) .OrderBy(b => b.StartDate) .ThenBy(b => b.Row) .Take(barsCount); return GetRatesFromDbBars <TBar>(bars.ToList()); })); }
static List <TBar> GetRateFromDBBackwardsInternal <TBar>(string pair, DateTime endDate, int barsCount, int minutesPerPriod) where TBar : BarBase, new() { try { return(GlobalStorage.UseForexContext(context => { var bars = context.t_Bar .Where(b => b.Pair == pair && b.Period == minutesPerPriod && b.StartDate <= endDate) .OrderByDescending(b => b.StartDate) .Take(barsCount) .ToList() .OrderBy(b => b.StartDate) .ThenBy(b => b.Row); return GetRatesFromDbBars <TBar>(bars.ToList()); })); } catch (Exception exc) { throw new Exception(new { pair, endDate, barsCount, minutesPerPriod } +"", exc); } }
public static TradingMacro[] ReadTradingMacros(string tradingacroName, List <Exception> errors) { var searchPath = GlobalStorage.ActiveSettingsPath(TradingMacrosPath(tradingacroName.IfEmpty("*"), "*", "*", "*")); var paths = Directory.GetFiles(Path.GetDirectoryName(searchPath), Path.GetFileName(searchPath)); return((from path in paths select new { tm = GlobalStorage.LoadJson <TradingMacro>(path, errors), path } ) .Do(x => { x.tm.IsLoaded = true; if (x.tm == null) { errors.Add(new Exception(x + "")); } }) .Select(x => x.tm) //.Where(tm => tm != null) .ToArray()); }
public void SaveTradingMacros(string tradingMacroName) => GlobalStorage.SaveTradingMacros(TradingMacros, tradingMacroName);