def get(self, tickers, fields) -> List: ref_data_service = self._session.getService(REF_DATA_SERVICE_URI) request = ref_data_service.createRequest("ReferenceDataRequest") set_tickers(request, tickers) set_fields(request, fields) self._session.sendRequest(request) return self._receive_reference_response(fields)
def get(self, tickers: Sequence[BloombergTicker], fields): ref_data_service = self._session.getService(REF_DATA_SERVICE_URI) request = ref_data_service.createRequest("ReferenceDataRequest") tickers_str = [t.as_string() for t in tickers] set_tickers(request, tickers_str) set_fields(request, fields) self._session.sendRequest(request) return self._receive_reference_response(tickers, fields)
def _create_and_send_request(self, tickers): ref_data_service = self._session.getService(REF_DATA_SERVICE_URI) request = ref_data_service.createRequest("ReferenceDataRequest") set_tickers(request, tickers, ) set_fields(request, ["FUT_CHAIN"]) # Set the parameters to include all the future contracts, that already expired override_names = ("CHAIN_DATE", "INCLUDE_EXPIRED_CONTRACTS") override_values = (convert_to_bloomberg_date(datetime.now()), "Y") override_fields = ("fieldId", "value") self._set_overrides(request, override_fields, override_names, override_values) self._session.sendRequest(request)
def get(self, tickers, fields, override_names, override_values) -> List: ref_data_service = self._session.getService(REF_DATA_SERVICE_URI) request = ref_data_service.createRequest("ReferenceDataRequest") set_tickers(request, tickers) set_fields(request, fields) if override_names is not None: overrides = request.getElement("overrides") for override_name, override_value in zip(override_names, override_values): override = overrides.appendElement() override.setElement("fieldId", override_name) override.setElement("value", override_value) self._session.sendRequest(request) return self._receive_reference_response(fields)
def _get_historical_data(self, ref_data_service, tickers, fields, start_date, end_date, frequency, currency, override_name, override_value): request = ref_data_service.createRequest("HistoricalDataRequest") self._set_time_period(request, start_date, end_date, frequency) set_tickers(request, tickers) set_fields(request, fields) self._set_currency(currency, request) if override_name is not None: self._set_override(request, override_name, override_value) self._session.sendRequest(request) return self._receive_historical_response(tickers, fields)
def _get_historical_data(self, ref_data_service, tickers: Sequence[BloombergTicker], fields: Sequence[str], start_date: datetime, end_date: datetime, frequency: Frequency, currency: str, override_name: str, override_value: Any): request = ref_data_service.createRequest("HistoricalDataRequest") ticker_strings = [t.as_string() for t in tickers] set_tickers(request, ticker_strings) set_fields(request, fields) self._set_time_period(request, start_date, end_date, frequency) self._set_currency(currency, request) if override_name is not None: self._set_override(request, override_name, override_value) self._session.sendRequest(request) return self._receive_historical_response(tickers, fields)
def get(self, tickers: Sequence[str], fields: Sequence[str], start_date: datetime, end_date: datetime, frequency: Frequency, currency: str, override_name: str, override_value: Any) -> QFDataArray: """ Gets historical data from Bloomberg. """ ref_data_service = self._session.getService(REF_DATA_SERVICE_URI) request = ref_data_service.createRequest("HistoricalDataRequest") set_tickers(request, tickers) set_fields(request, fields) self._set_time_period(request, start_date, end_date, frequency) self._set_currency(currency, request) if override_name is not None: self._set_override(request, override_name, override_value) self._session.sendRequest(request) qf_data_array = self._receive_historical_response(tickers, fields) return qf_data_array