public void if_timeframe_is_null_isValid_returns_false() { Asset asset = new Asset(1, "x"); AssetTimeframe atf = new AssetTimeframe(asset, null); Assert.IsFalse(atf.isValid()); }
public void if_asset_is_null_isValid_returns_false() { Timeframe timeframe = Timeframe.GetTimeframe(TimeframeSymbol.M30); AssetTimeframe atf = new AssetTimeframe(null, timeframe); Assert.IsFalse(atf.isValid()); }
public static Mock<IAnalyzer> generateMockAnalyzer(AssetTimeframe atf, AnalysisType type, DateTime? firstRequiredDate) { Mock<IAnalyzer> mock = new Mock<IAnalyzer>(); mock.Setup(q => q.getFirstRequiredDate()).Returns(firstRequiredDate); mock.Setup(q => q.getAssetTimeframe()).Returns(atf); mock.Setup(q => q.getAnalysisType()).Returns(type); return mock; }
public void runFull(IAnalyzer analyzer, DataItem item, AssetTimeframe atf) { this.atf = atf; if (item == null) return; if (item.Quotation == null) return; runLeftSide(analyzer, item, atf); }
public void function_returns_proper_symbol() { Asset asset = new Asset(1, "ABC") { ShortName = "ABC" }; Timeframe timeframe = Timeframe.GetTimeframe(TimeframeSymbol.M30); AssetTimeframe atf = new AssetTimeframe(asset, timeframe); Assert.AreEqual("ABC_M30", atf.Symbol()); }
public void if_both_asset_and_timeframe_are_set_isValid_returns_true() { Asset asset = new Asset(1, "x"); Timeframe timeframe = Timeframe.GetTimeframe(TimeframeSymbol.M30); AssetTimeframe atf = new AssetTimeframe(asset, timeframe); Assert.IsTrue(atf.isValid()); }
public Dictionary<AnalysisType, IAnalyzer> getAnalyzers(AssetTimeframe atf, IEnumerable<AnalysisType> types) { var dict = new Dictionary<AnalysisType, IAnalyzer>(); foreach (var type in types) { IAnalyzer analyzer = getAnalyzer(type, atf); dict.Add(type, analyzer); } return dict; }
public IAnalyzer getAnalyzer(AnalysisType type, AssetTimeframe atf) { switch (type) { case AnalysisType.Price: return new PriceAnalyzer(atf); case AnalysisType.MACD: return new MacdAnalyzer(atf); case AnalysisType.ADX: return new AdxAnalyzer(atf); case AnalysisType.Candlestick: return new CandlestickAnalyzer(atf); case AnalysisType.Trendline: return new TrendlineAnalyzer(atf); case AnalysisType.Unknown: return null; default: return null; } }
public IProcessService GetProcessService(AssetTimeframe atf) { string symbol = atf.Symbol(); IProcessService service = null; try { services.TryGetValue(symbol, out service); return service; } catch (Exception) { service = new ProcessService(atf); return service; } }
public void runRightSide(IAnalyzer analyzer, DataItem item, AssetTimeframe atf) { this.atf = atf; if (item == null) return; if (item.Quotation == null) return; //Calculate new values for peaks and troughs and apply them to the current item price. //If any of this is changed, this price will have flag [IsChange] set to @true. //This is the only thing that can be changed for items being only updated. CheckForExtremum(item, ExtremumType.PeakByClose, false); CheckForExtremum(item, ExtremumType.PeakByHigh, false); CheckForExtremum(item, ExtremumType.TroughByClose, false); CheckForExtremum(item, ExtremumType.TroughByLow, false); CheckPriceGap(item); }
public void runRightSide(IAnalyzer analyzer, int index, AssetTimeframe atf) { DataItem item = analyzer.getDataItem(index); runRightSide(analyzer, item, atf); }
public DateTime? getLastCalculationDate(AssetTimeframe atf, AnalysisType analysisType) { if (LastAnalyzed > 2) return Data[LastAnalyzed - 2].Date; return null; }
private void runLeftSide(IAnalyzer analyzer, DataItem item, AssetTimeframe atf) { //Check if quotation is missing (but only in the middle of not-missing quotations, //because missing quotations at the end of array was excluded one line above). //If it is copy data from the previous quotation. if (!item.Quotation.IsComplete()) { var previousQuotation = (item.Index > 0 ? analyzer.getDataItem(item.Index - 1).Quotation : null); if (previousQuotation != null) { item.Quotation.CompleteMissing(previousQuotation); //_dataService.UpdateQuotation(item.Quotation, Symbol); } } //Ensure that [Price] object is appended to this [DataItem]. item.Price = new Price(); item.Price.Date = item.Date; if (item.Index > 0) item.Price.CloseDelta = CalculateDeltaClosePrice(item.Quotation.Close, item.Index); item.Price.Direction2D = CalculateDirection2D(item.Index); item.Price.Direction3D = CalculateDirection3D(item.Index); //Calculate new values for peaks and troughs and apply them to the current item price. //If any of this is changed, this price will have flag [IsChange] set to @true. //This is the only thing that can be changed for items being only updated. CheckForExtremum(item, ExtremumType.PeakByClose, true); CheckForExtremum(item, ExtremumType.PeakByHigh, true); CheckForExtremum(item, ExtremumType.TroughByClose, true); CheckForExtremum(item, ExtremumType.TroughByLow, true); CheckPriceGap(item); }
public void runFull(IAnalyzer analyzer, int index, AssetTimeframe atf) { }
public void runRightSide(IAnalyzer analyzer, int index, AssetTimeframe atf) { }
public ProcessService(Asset asset, Timeframe timeframe) { this.assetTimeframe = new AssetTimeframe(asset, timeframe); }
public Analyzer(AssetTimeframe atf, IQuotationService quotationService) { this.quotationService = quotationService; initialize(atf); }
public ProcessService(AssetTimeframe atf) { this.assetTimeframe = atf; }
public void if_atf_is_not_valid_function_throws_exception() { Timeframe timeframe = Timeframe.GetTimeframe(TimeframeSymbol.M30); AssetTimeframe atf = new AssetTimeframe(null, timeframe); string symbol = atf.Symbol(); }
public DateTime? getLastCalculationDate(AssetTimeframe atf, AnalysisType analysisType) { return service.GetAnalysisLastCalculation(atf.Symbol(), analysisType.toString()); }
private Mock<IQuotationService> mockedQuotationService(AssetTimeframe atf, DateTime lastAnalysisDate, AnalysisType type) { Mock<IQuotationService> obj = new Mock<IQuotationService>(); obj.Setup(mqs => mqs.getLastCalculationDate(atf, type)).Returns(lastAnalysisDate); return obj; }
public bool Start(AssetTimeframe atf, AnalysisType[] types) { this.Symbol = atf.Symbol(); this.types = types; try { Data = _dataService.GetFxQuotations(this.Symbol, true).ToArray(); Data.AppendIndexNumbers(); Debug.WriteLine(string.Format("+;SimulationService.Start - Data loaded (Items: {0})", Data.Length)); if (types.Contains(AnalysisType.Price)){ _priceAnalyzer = new PriceAnalyzer(atf); ((Analyzer)_priceAnalyzer).injectQuotationService(quotationService); } if (types.Contains(AnalysisType.Trendline)) { _trendAnalyzer = new TrendlineAnalyzer(atf); ((Analyzer)_trendAnalyzer).injectQuotationService(quotationService); } return true; } catch (Exception) { return false; } }
public CandlestickAnalyzer(AssetTimeframe atf) : base(atf) { }
/* CONSTRUCTORS */ public PriceAnalyzer(AssetTimeframe atf) : base(atf) { }
public CandlestickAnalyzer(IAnalysisDataService dataService, AssetTimeframe atf) : base(atf) { this._dataService = dataService; }
public AdxAnalyzer(AssetTimeframe atf) : base(atf) { initialize_specific(); }
public void runFull(IAnalyzer analyzer, DataItem item, AssetTimeframe atf) { }
public AdxAnalyzer(IAnalysisDataService dataService, AssetTimeframe atf) : base(atf) { initialize_specific(); this._dataService = dataService; }
public void runRightSide(IAnalyzer analyzer, DataItem item, AssetTimeframe atf) { }
public AssetTimeframe GetAssetTimeframe(Timeframe timeframe) { var assetTimeframe = AssetTimeframes.SingleOrDefault(a => a.timeframe == timeframe); if (assetTimeframe == null) { assetTimeframe = new AssetTimeframe(this, timeframe); AssetTimeframes = AssetTimeframes.Concat(new[] { assetTimeframe }); } return assetTimeframe; }