public RequestResponse MarketDataSnapshotRequest(MarketDataSnapshotRequest request) { this.Validator.Validate(request); var timeframeId = request.Timeframe == Timeframe.Custom ? request.CustomTimeframeId : Converters.GetTimeframeId(request.Timeframe); var fxReq = this.FxRequestFactory.createMarketDataSnapshotRequestInstrument(request.Instrument, this.FxRequestFactory.Timeframes[timeframeId], request.MaxBars); this.FxRequestFactory.fillMarketDataSnapshotRequestTime(fxReq, request.TimeFrom, request.TimeTo, request.IncludeWeekends); this.CleanupMarketDataRequests(); var mdr = new MarketDataRequestItem() { Instrument = request.Instrument, RequestID = fxReq.RequestID, Time = DateTime.Now, }; this.AddMakrtedDataRequestItem(mdr); this.FxSession.sendRequest(fxReq); return(Helpers.GetRequestResponse(fxReq)); }
public void Validate(MarketDataSnapshotRequest request) { if (request == null) { throw new ArgumentNullException("request"); } if (string.IsNullOrEmpty(request.Instrument)) { throw new ArgumentNullException("Instrument"); } if (request.MaxBars < 0) { throw new ArgumentOutOfRangeException("MaxBars", "MaxBars should not be negative."); } if (request.Timeframe == Timeframe.Custom && string.IsNullOrEmpty(request.CustomTimeframeId)) { throw new ArgumentNullException("CustomTimeframe", "CustomTimeframe has to be specified."); } }
public void ValidateMarketDataSnapshotRequest() { // Null. { var v = new RequestProviderValidator(); MarketDataSnapshotRequest r = null; AssertEx.Throws <ArgumentNullException>(() => { v.Validate(r); }); } // Instrument null. { var v = new RequestProviderValidator(); MarketDataSnapshotRequest r = new MarketDataSnapshotRequest(); r.Instrument = null; AssertEx.Throws <ArgumentNullException>(() => { v.Validate(r); }); } // Instrument empty. { var v = new RequestProviderValidator(); MarketDataSnapshotRequest r = new MarketDataSnapshotRequest(); r.Instrument = ""; AssertEx.Throws <ArgumentNullException>(() => { v.Validate(r); }); } // Negative MaxBars. { var v = new RequestProviderValidator(); MarketDataSnapshotRequest r = new MarketDataSnapshotRequest(); r.Instrument = "Test"; r.MaxBars = -5; AssertEx.Throws <ArgumentOutOfRangeException>(() => { v.Validate(r); }); } // Valid without CustomTimeframeId. { var v = new RequestProviderValidator(); MarketDataSnapshotRequest r = new MarketDataSnapshotRequest(); r.Instrument = "Test"; r.MaxBars = 7; r.Timeframe = Timeframe.Hours2; v.Validate(r); } // CustomTimeframeId null. { var v = new RequestProviderValidator(); MarketDataSnapshotRequest r = new MarketDataSnapshotRequest(); r.Instrument = "Test"; r.Timeframe = Timeframe.Custom; r.CustomTimeframeId = null; AssertEx.Throws <ArgumentNullException>(() => { v.Validate(r); }); } // CustomTimeframeId empty. { var v = new RequestProviderValidator(); MarketDataSnapshotRequest r = new MarketDataSnapshotRequest(); r.Instrument = "Test"; r.Timeframe = Timeframe.Custom; r.CustomTimeframeId = ""; AssertEx.Throws <ArgumentNullException>(() => { v.Validate(r); }); } // valid with CustomTimeframeId. { var v = new RequestProviderValidator(); MarketDataSnapshotRequest r = new MarketDataSnapshotRequest(); r.Instrument = "Test"; r.Timeframe = Timeframe.Custom; r.CustomTimeframeId = "Y1"; v.Validate(r); } }
public RequestResponse MarketDataSnapshotRequest(MarketDataSnapshotRequest request) { throw new NotImplementedException(); }