// Constructor public UserShortVerticalList() { // Initialize private variables. enableRefreshShowAll = c_EnableRefreshShowAll; noProfileImageFile = c_NoProfileImageFile; spDataSource = c_SPDataSource; spConnectionString = c_SPConnectionString; spSiteProfiles = c_SPSiteProfiles; showColumnPhoto = c_ShowColumnPhoto; showBigPhoto = c_ShowBigPhoto; showColumnLastName = c_ShowColumnLastName; showColumnFirstName = c_ShowColumnFirstName; showColumnMiddleName = c_ShowColumnMiddleName; showColumnOrganization = c_ShowColumnOrganization; showColumnSeparateDivision = c_ShowColumnSeparateDivision; showColumnSubDivision = c_ShowColumnSubDivision; showColumnPosition = c_ShowColumnPosition; showColumnWorkPhone = c_ShowColumnWorkPhone; showColumnHomePhone = c_ShowColumnHomePhone; showColumnEmail = c_ShowColumnEmail; showColumnBirthday = c_ShowColumnBirthday; showColumnBirthdayShort = c_ShowColumnBirthdayShort; showColumnMerit = c_ShowColumnMerit; numberOfRecords = c_NumberOfRecords; selectionType = c_SelectionType; showNewEmployeesOnly = c_ShowNewEmployeesOnly; showBestWorkersWeeklyOnly = c_ShowBestWorkersWeeklyOnly; showBestWorkersOnly = c_ShowBestWorkersOnly; newEmployeesDays = c_NewEmployeesDays; showWhosBirthdayOnly = c_ShowWhosBirthdayOnly; birthdayTimeframe = c_BirthdayTimeframe; }
private XElement GetTimeframeElement(Timeframe timeframe) { if (timeframe.EarliestDate == null && timeframe.LatestDate == null) { throw new AdfException("An ealiest date or latest date is required for timeframe."); } var timeframeElement = new XElement("timeframe"); if (!string.IsNullOrEmpty(timeframe.Description)) { timeframeElement.Add(new XElement("description", timeframe.Description)); } if (timeframe.EarliestDate != null) { timeframeElement.Add(new XElement("earliestdate", timeframe.EarliestDate)); } if (timeframe.LatestDate != null) { timeframeElement.Add(new XElement("latestdate", timeframe.LatestDate)); } return(timeframeElement); }
protected override IList <Candle> GetData(string ticker, Timeframe timeFrame) { var result = Producer.GetData(ticker, timeFrame); //Console.WriteLine($"##GetData Timestamp: {result.Last().Timestamp}, Volume: {result.Last().Volume}, Low: {result.Last().Low}, High: {result.Last().High}, Close: {result.Last().Close}"); return(result); }
public ActionResult DreamList(int id) { if (ibo != null) { List <Dream> dreams = IBOVirtualAPI.GetDreamsUserLevel(ibo.IBONum, id.ToString()); if ((dreams.Count > 0) || (id == 0)) { ViewBag.dreamLevel = id; ViewBag.nextLevel = id + 1; List <Dream> dreamsLevel = IBOVirtualAPI.GetDreamsUserLevel(ibo.IBONum, (id + 1).ToString()); Dictionary <Timeframe, Dream> timeframeDreams = new Dictionary <Timeframe, Dream>(); List <Timeframe> timeframes = IBOVirtualAPI.GetTimeFrames(id, ibo.languageId); Timeframe last = timeframes.Last(); if (dreamsLevel.Count < 1) { ViewBag.lastItem = last; } foreach (Timeframe time in timeframes) { Dream dream = (from d in dreams where d.timeframeId == time.timeframeId select d).FirstOrDefault(); timeframeDreams.Add(time, dream); } return(PartialView(timeframeDreams)); } } return(null); }
public static DateTime GetIdealBarTime(DateTime time, Timeframe period, int interval) { int val = 0; switch (period) { case Timeframe.Minute: val = time.Minute; val -= val % interval; return(new DateTime(time.Year, time.Month, time.Day, time.Hour, val, 0, time.Kind)); case Timeframe.Hour: val = time.Hour; val -= val % interval; return(new DateTime(time.Year, time.Month, time.Day, val, 0, 0, time.Kind)); case Timeframe.Day: return(time.Date); case Timeframe.Month: return(new DateTime(time.Year, time.Month, 1, 0, 0, 0, time.Kind)); default: throw new ArgumentException(period.ToString() + " periodicity is not supported", "period"); } }
public static string TimeframeToString(Timeframe timeframe) { switch (timeframe) { case Timeframe.NONE: return("NONE"); case Timeframe.min1: return("1 minute"); case Timeframe.min3: return("3 minutes"); case Timeframe.min5: return("5 minutes"); case Timeframe.min15: return("15 minutes"); case Timeframe.min30: return("30 minutes"); case Timeframe.h1: return("1 hour"); case Timeframe.h2: return("2 hours"); case Timeframe.h4: return("4 hours"); case Timeframe.h6: return("6 hours"); case Timeframe.h12: return("12 hours"); case Timeframe.d1: return("1 day"); case Timeframe.d3: return("3 days"); case Timeframe.w1: return("1 week"); } throw new ArgumentException(); }
private Candlestick[] ConvertCandles(Candlestick[] data, Timeframe fromTimeframe, Timeframe toTimeframe) { Candlestick[] ret = new Candlestick[(int)fromTimeframe / (int)toTimeframe * data.Length + 1]; for (int i = 0, retId = 0; i < data.Length; i += (int)toTimeframe / (int)fromTimeframe) { if (i + (int)toTimeframe / (int)fromTimeframe > data.Length) { break; } ret[retId].high = 0; ret[retId].low = float.MaxValue; int j = i; ret[retId].open = data[j].open; for (; j < (int)toTimeframe / (int)fromTimeframe; j++) { if (ret[retId].high < data[j].high) { ret[retId].high = data[j].high; } else if (ret[retId].low > data[j].low) { ret[retId].low = data[j].low; } } ret[retId].close = data[j].close; retId++; } return(ret); }
public List <Candle> GetCandles(string market, Timeframe timeframe) { var path = GetCandlesPath(market, timeframe); var data = Decompress(File.ReadAllBytes(path)); return(BrokersCandlesService.BytesToCandles(data).ToList()); }
private Candle?CreateCandle(IBinanceKline kline, string market, Timeframe timefame) { var c = new Candle { CloseTimeTicks = kline.CloseTime.Ticks, IsComplete = kline.CloseTime <= DateTime.UtcNow ? (byte)1 : (byte)0, CloseBid = (float)kline.CommonClose, HighBid = (float)kline.CommonHigh, LowBid = (float)kline.CommonLow, OpenTimeTicks = kline.OpenTime.Ticks, OpenBid = (float)kline.CommonOpen, Volume = (float)kline.CommonVolume, CloseAsk = (float)kline.CommonClose, HighAsk = (float)kline.CommonHigh, LowAsk = (float)kline.CommonLow, OpenAsk = (float)kline.CommonOpen }; var interval = (c.CloseTime() - c.OpenTime()).TotalSeconds; if ((int)timefame != Math.Round(interval)) { // throw new ApplicationException("Candle timeframe wrong"); // Some candles are wrong length (Seen some in 2018 date ranges) } if (c.OpenTimeTicks > c.CloseTimeTicks) { //throw new ApplicationException("Candle open time is later the close time"); Log.Warn($"Binance candle ignored {market} {c} {timefame}"); return(null); } return(c); }
/// <summary> /// Gets wait time in ms after each call it's less restictive than original ccxt raleLimit. /// </summary> //public Dictionary<string,int> RateLimits { get { return _rateLimits; } } public static string TimeframeToKey(Timeframe timeframe) { switch (timeframe) { case Timeframe.min1: return("1m"); case Timeframe.min5: return("5m"); case Timeframe.min15: return("15m"); case Timeframe.min30: return("30m"); case Timeframe.h1: return("1h"); case Timeframe.h2: return("2h"); case Timeframe.h4: return("4h"); case Timeframe.h6: return("6h"); case Timeframe.h8: return("8h"); case Timeframe.h12: return("12h"); case Timeframe.d1: return("1d"); case Timeframe.d3: return("3d"); case Timeframe.w1: return("1w"); case Timeframe.M1: return("1M"); } throw new ArgumentException(); }
public async Task <ProblemsDto> GetProblemsV2Async(IEnumerable <WithOrWithout <ProblemFields> > fields = null, string nextPageKey = null, int?pageSize = null, Timeframe from = null, Timeframe to = null, ProblemSelector problemSelector = null, EntitySelector entitySelector = null, IEnumerable <AscendingOrDescending <ProblemSorts> > sort = null, CancellationToken cancellationToken = default) { var queryParamValues = new Dictionary <string, object> { [nameof(fields)] = string.Join(",", (fields ?? Enumerable.Empty <WithOrWithout <ProblemFields> >()) .Distinct() .Select(x => $"+{x.ToString().ToCamelCase()}")), [nameof(nextPageKey)] = nextPageKey, [nameof(pageSize)] = pageSize, [nameof(from)] = from?.ToString(), [nameof(to)] = to?.ToString(), [nameof(problemSelector)] = problemSelector?.ToString(), [nameof(entitySelector)] = entitySelector?.ToString(), [nameof(sort)] = string.Join(",", sort ?? Enumerable.Empty <AscendingOrDescending <ProblemSorts> >()) .Distinct() .Select(x => x.ToString().ToCamelCase()) }; var response = await GetProblemsV2Url() .SetQueryParams(queryParamValues) .GetJsonWithErrorCheckingAsync <ProblemsDto>(cancellationToken) .ConfigureAwait(false); return(response); }
public ActionResult GoalsList(int id) { if (ibo != null) { List <Goal> goals = IBOVirtualAPI.GetIBOLevelGoals(ibo.IBONum, id.ToString()); if ((goals.Count > 0) || (id == 0)) { ViewBag.goalLevel = id; ViewBag.nextLevel = id + 1; List <Goal> goalsLevel = IBOVirtualAPI.GetIBOLevelGoals(ibo.IBONum, (id + 1).ToString()); Dictionary <Timeframe, Goal> timeframeGoals = new Dictionary <Timeframe, Goal>(); List <Timeframe> timeframes = IBOVirtualAPI.GetTimeFrames(id, ibo.languageId); Timeframe last = timeframes.Last(); if (goalsLevel.Count < 1) { ViewBag.lastItem = last; } foreach (Timeframe time in timeframes) { Goal dream = (from d in goals where d.timeframeId == time.timeframeId select d).FirstOrDefault(); timeframeGoals.Add(time, dream); } return(PartialView(timeframeGoals)); } } return(null); }
private void ApplyStopStrategy(Trade t, TimeframeLookup <List <CandleAndIndicators> > candlesLookup, DateTime currentTime) { StopUpdateStrategy?stopUpdate = null; Timeframe timeframe = Timeframe.D1; Indicator indicator = Indicator.EMA8; switch (_options.StopOption) { case StopOption.InitialStopThenTrail2HR8EMA: { stopUpdate = StopUpdateStrategy.StopTrailIndicator; timeframe = Timeframe.H2; indicator = Indicator.EMA8; break; } case StopOption.InitialStopThenTrail2HR25EMA: { stopUpdate = StopUpdateStrategy.StopTrailIndicator; timeframe = Timeframe.H2; indicator = Indicator.EMA25; break; } case StopOption.InitialStopThenTrail4HR8EMA: { stopUpdate = StopUpdateStrategy.StopTrailIndicator; timeframe = Timeframe.H4; indicator = Indicator.EMA8; break; } case StopOption.InitialStopThenTrail4HR25EMA: { stopUpdate = StopUpdateStrategy.StopTrailIndicator; timeframe = Timeframe.H4; indicator = Indicator.EMA25; break; } case StopOption.DynamicTrailingStop: { stopUpdate = StopUpdateStrategy.DynamicTrailingStop; break; } } if (stopUpdate != null) { if (stopUpdate == StopUpdateStrategy.StopTrailIndicator) { StopHelper.TrailIndicator(t, timeframe, indicator, candlesLookup, currentTime.Ticks); } else if (stopUpdate == StopUpdateStrategy.DynamicTrailingStop) { StopHelper.TrailDynamicStop(t, candlesLookup, currentTime.Ticks); } } }
public StockPriceSeries(TradedStock tradedStock, IEnumerable <StockPrice> prices, Timeframe timeframe) : base(prices) { this.Require(x => timeframe != null); TradedStock = tradedStock; Timeframe = timeframe; }
public YearTimeframe(int year) : base( new DateTime(year, 1, 1), new DateTime(year, 12, 31, 23, 59, 59)) { this.Year = year; Timeframe.Year(); }
public static List <Phone> Calculate(PhoneCollection collection, Timeframe timeframe = Timeframe.Quarterly) { for (int index = 0; index < collection.Phones.Count(); index++) { collection.Phones[index].Seasonality = Calculate(index, collection, timeframe); } return(collection.Phones); }
public static DateTime?GetFirstTimestamp(DbSet <Candle> dbSet, Timeframe timeFrame, string ticker) { return(dbSet .Where(c => c.Ticker == ticker) .Where(c => c.TimeFrame == timeFrame) .OrderBy(c => c.Timestamp) .Select(c => c.Timestamp) .FirstOrDefault()); }
public void Equals_returnFalse_forObjectOfOtherType() { //Act var baseObject = new Timeframe(DEFAULT_ID, DEFAULT_NAME, DEFAULT_UNIT_TYPE, DEFAULT_UNITS_COUNTER); var comparedObject = new { Id = 1, Value = 2 }; //Assert Assert.IsFalse(baseObject.Equals(comparedObject)); }
public void Equals_returnFalse_ifIdDifferent() { //Act var baseObject = new Timeframe(DEFAULT_ID, DEFAULT_NAME, DEFAULT_UNIT_TYPE, DEFAULT_UNITS_COUNTER); var comparedObject = new Timeframe(DEFAULT_ID + 1, DEFAULT_NAME, DEFAULT_UNIT_TYPE, DEFAULT_UNITS_COUNTER); //Assert Assert.IsFalse(baseObject.Equals(comparedObject)); }
private IEnumerable <IList <TickerData> > ReadAllDataFromTimeframeFolder(Timeframe frame) { var files = Directory.GetFiles($"./{frame}"); foreach (var f in files) { yield return(File.ReadLines(f).Where(a => !string.IsNullOrWhiteSpace(a)).Select(a => TickerData.FromString(a)).ToList()); } }
public List <Candle> CreateCandlesSeries(string pair, Timeframe timeframe, bool updateCandles, DateTime?minOpenTimeUtc = null, DateTime?maxCloseTimeUtc = null) { var candles = _candlesService.GetCandles(_broker, pair, timeframe, updateCandles, minOpenTimeUtc, maxCloseTimeUtc); if (candles != null && candles.Count > 0) { return(candles); } // Get first/second symbol from pair var firstSymbol = string.Empty; var secondSymbol = string.Empty; var allSymbols = _broker.GetSymbols(); for (var l = 5; l >= 3; l--) // Go backwards because e.g. LUNABTC - for some reason there already is a LUNBTC in the symbols { if (allSymbols.Contains($"{pair.Substring(0, l)}BTC") || allSymbols.Contains($"{pair.Substring(0, l)}BNB") || allSymbols.Contains($"{pair.Substring(0, l)}USDT")) { firstSymbol = pair.Substring(0, l); secondSymbol = pair.Substring(firstSymbol.Length, pair.Length - firstSymbol.Length); break; } } if (string.IsNullOrEmpty(firstSymbol)) { // Try reverse firstSymbol = string.Empty; secondSymbol = string.Empty; for (var l = 5; l >= 3; l--) // Go backwards because e.g. LUNABTC - for some reason there already is a LUNBTC in the symbols { if (allSymbols.Contains($"{pair.Substring(pair.Length - l, l)}BTC") || allSymbols.Contains($"{pair.Substring(pair.Length - l, l)}BNB") || allSymbols.Contains($"{pair.Substring(pair.Length - l, l)}USDT")) { firstSymbol = pair.Substring(0, pair.Length - l); secondSymbol = pair.Substring(firstSymbol.Length, pair.Length - firstSymbol.Length); break; } } } if (string.IsNullOrEmpty(firstSymbol)) { throw new ApplicationException($"Unable to find market {pair}"); } return(CreateCandlesSeries(firstSymbol, secondSymbol, timeframe, updateCandles, minOpenTimeUtc, maxCloseTimeUtc)); }
private static void RunAlgorithm(PhoneCollection collection, Timeframe timeframe) { collection.Phones = MovingAverage.Calculate(collection, timeframe); collection.Phones = CenteredMovingAverage.Calculate(collection, timeframe); collection.Phones = SeasonalIrregularity.Calculate(collection); collection.Phones = Seasonality.Calculate(collection, timeframe); collection.Phones = Deseasonalize.Calculate(collection); collection.Phones = Trend.Calculate(collection); collection.Phones = Forecast.Calculate(collection); }
// Prevents spamming notifications. protected void BaseTest(Timeframe timeframe = Timeframe.NONE, int minLength = -1, int maxLength = -1) { DateTime currentTime = DateTime.Now; if (_lastTriggered + new TimeSpan(0, 0, _notification.Interval) <= currentTime && !_isNotifying) { Notify(currentTime); Resubscribe(minLength, maxLength); } }
// creates alert data from line private void BaseFromLine(string data) { AlertData = new AlertData(ref data); _notification = new Notification(ref data); _lastTriggered = DateTime.Parse(Utility.GetSubstring(data, ';', 0)); timeframe = (Timeframe)int.Parse(Utility.GetSubstring(data, ';', 1)); data = Utility.GetSubstring(data, ';', 2, false); Init(data); }
public void Init(Timeline timeline, Func <int>[] inserts) { this._timeline = timeline; this._access = timeline.access; this._binding = timeline.binding; this._timeframe = timeline.timeframe; this._functions = inserts; this._access.AddRuntimeCallback(Runtime); this._access.AddRevertCallback(0, Revert); }
public void GetSymbol_ThrowsException_IfAssetIsNull() { //Arrange Asset asset = null; Timeframe timeframe = defaultTimeframe(); AssetTimeframe assetTimeframe = new AssetTimeframe(asset, timeframe); //Act string symbol = assetTimeframe.GetSymbol(); }
public Timeframe GetTimeframe(int id) { Timeframe timeframe = db.Timeframes.Find(id); if (timeframe == null) { throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound)); } return(timeframe); }
public void constructor_newInstanceHasCorrectProperties() { //Act var timeframe = new Timeframe(DEFAULT_ID, DEFAULT_NAME, DEFAULT_UNIT_TYPE, DEFAULT_UNITS_COUNTER); //Assert Assert.AreEqual(DEFAULT_ID, timeframe.GetId()); Assert.AreEqual(DEFAULT_NAME, timeframe.GetName()); Assert.AreEqual(DEFAULT_UNIT_TYPE, timeframe.GetUnitType()); Assert.AreEqual(DEFAULT_UNITS_COUNTER, timeframe.GetUnitsCounter()); }
public static List <Phone> Calculate(PhoneCollection collection, Timeframe timeframe = Timeframe.Quarterly) { for (int index = 0; index < collection.Phones.Count(); index++) { if (collection.Phones.ElementAtOrDefault(index).MovingAverage != null && collection.Phones.ElementAtOrDefault(index + 1).MovingAverage != null) { collection.Phones[index].CenteredMovingAverage = (collection.Phones[index].MovingAverage + collection.Phones[index + 1].MovingAverage) / 2; } } return(collection.Phones); }
public KidsClass(ClassType clType, Timeframe clSession, City clLocation, int clAge, double clPrice, string clAddress, int spotsTotal, string clName) { ClsType = clType; Session = clSession; Location = clLocation; Age = clAge; Price = clPrice; Address = clAddress; TotalSpots = spotsTotal; Name = clName; }
public static StockPriceSeries GetStockPrices( this MauiX.IQuery self, StockHandle stock, DateClause dateClause, Timeframe timeframe ) { var table = self.GetPriceData( stock, dateClause ); var q = from row in table.Rows select new StockPrice( (long)row[ "id" ], stock.TradedStock, row.GetDate( table.Schema ), row[ "open" ] != DBNull.Value ? (double?)row[ "open" ] : null, row[ "high" ] != DBNull.Value ? (double?)row[ "high" ] : null, row[ "low" ] != DBNull.Value ? (double?)row[ "low" ] : null, (double)row[ "close" ], ( row[ "volume" ] != DBNull.Value ? (int)(long)row[ "volume" ] : 0 ) ); return new StockPriceSeries( stock.TradedStock, q, timeframe ); }
/// <summary> /// Main method /// </summary> /// <param name="index"></param> public override void Calculate(int index) { if (!(_showPivots || _showLabels)) { ChartObjects.DrawText("msgShow", "Set \"Draw Labels\" or \"Draw Pivots\" to 1", StaticPosition.TopLeft, Colors.Red); return; } ChartObjects.RemoveObject("msgShow"); if (index <= 1) { _p[index] = 0; return; } if (GetTimeFrame(index) == Timeframe.na && _currentTimeFrame == Timeframe.na) { _p[index] = 0; return; } if (_currentTimeFrame == Timeframe.na) _currentTimeFrame = GetTimeFrame(index); bool daily = _currentTimeFrame < Timeframe.D1 && _dailyPivots; bool weekly = _currentTimeFrame < Timeframe.W1 && _weeklyPivots; if (!(daily || weekly)) { ChartObjects.DrawText("msg", "Incorrect Timeframe selection", StaticPosition.TopLeft, Colors.Red); return; } ChartObjects.RemoveObject("msg"); CalculatePivots(index, daily, weekly); if (ShowPivots == 1) DrawPivots(index); }
public override void Calculate(int index) { if (index <= 1) { Pivot[index] = 0; return; } if (_currentTimeFrame == Timeframe.na) _currentTimeFrame = GetTimeFrame(index); if (_currentTimeFrame == Timeframe.na) { Pivot[index] = 0; return; } bool daily = _currentTimeFrame < Timeframe.D1 && _showDailyPivots; bool weekly = _currentTimeFrame < Timeframe.W1 && _showWeeklyPivots; bool monthly = _currentTimeFrame < Timeframe.M1 && _showMonthlyPivots; if (!(daily || weekly || monthly)) { ChartObjects.DrawText("msg", "Incorrect Timeframe selection", StaticPosition.TopLeft, Colors.Red); return; } ChartObjects.RemoveAllObjects(); int currentDay = MarketSeries.OpenTime[index].Day; int previousDay = MarketSeries.OpenTime[index - 1].Day; DayOfWeek currentDayWk = MarketSeries.OpenTime[index].DayOfWeek; bool sameDay = currentDay == previousDay; bool calculateValues = Pivot[index - 1] == Pivot[index - 2] && !sameDay && (daily && currentDayWk != DayOfWeek.Saturday || weekly && currentDayWk == DayOfWeek.Monday || monthly && currentDay == 1); if (!calculateValues) { // Same values for the day Pivot[index] = Pivot[index - 1]; R1[index] = R1[index - 1]; S1[index] = S1[index - 1]; // Display additional pivots according to user input if (NoPiv >= 2) { R2[index] = R2[index - 1]; S2[index] = S2[index - 1]; } if (NoPiv >= 3) { R3[index] = R3[index - 1]; S3[index] = S3[index - 1]; } // Set high & low for next cycle if (MarketSeries.High[index] > _high) _high = MarketSeries.High[index]; if (MarketSeries.Low[index] < _low) _low = MarketSeries.Low[index]; } //if (calculateValues) else { _close = MarketSeries.Close[index - 1]; CalculatePivots(index); // reset high & low _high = double.MinValue; _low = double.MaxValue; } }