public IBHistoricalDataRequest( IBAdapter adapter, IHistoryDataConsumer consumer, Contract contract, DateTime begin, DateTime end, HistoryProviderSpan span, string whatToShow, int useRth, int formatDate) { this.adapter = adapter; Consumer = consumer; this.contract = contract; this.begin = begin; this.end = end; this.span = span; this.whatToShow = whatToShow; this.useRth = useRth; this.formatDate = formatDate; TimeSpan?minDuration, maxDuration; IBHistoryDataLimits.GetHistoryDataLimits(span, out minDuration, out maxDuration); var durationTimespan = end - begin; switch (span) { case HistoryProviderSpan.Minute: case HistoryProviderSpan.Minute5: case HistoryProviderSpan.Minute10: case HistoryProviderSpan.Minute15: case HistoryProviderSpan.Minute30: if (durationTimespan >= maxDuration || durationTimespan > IBHistoryDataLimits.MaxBarsPerRequest) { duration = (int)Math.Ceiling(durationTimespan.TotalDays); durationSuffix = " D"; } else { duration = (int)Math.Ceiling(durationTimespan.TotalSeconds); durationSuffix = " S"; } break; case HistoryProviderSpan.Hour: case HistoryProviderSpan.Hour4: case HistoryProviderSpan.Day: case HistoryProviderSpan.Week: case HistoryProviderSpan.Month: duration = (int)Math.Ceiling(durationTimespan.TotalDays); durationSuffix = " D"; break; default: throw new ArgumentOutOfRangeException(nameof(span), span, null); } }
public IBConnector(IBParameters settings) { this.settings = settings; IBFeed = new IBFeed(this); IBOrderRouter = new IBOrderRouter(this, settings.SessionUid, settings.RouterMode); Adapter = new IBAdapter(this, settings.InstrumentConverter); ContractContainer = new ContractContainer(Adapter, settings.InstrumentConverter); ConnectionStatusProviders = new IConnectionStatusProvider[] { this }; }
public IBHistoryDataSubscription( IBAdapter adapter, IHistoryDataConsumer consumer, Instrument instrument, Contract contract, HistoryProviderSpan span ) { this.adapter = adapter; this.consumer = consumer; this.contract = contract; this.span = span; historyData = new HistoryData(instrument, DateTime.Today, DateTime.Today, span); }
/// <summary> /// Конструктор /// </summary> public ContractContainer(IBAdapter adapter, InstrumentConverter <IBInstrumentData> instrumentConverter) { this.adapter = adapter; this.instrumentConverter = instrumentConverter; }