本文整理汇总了Python中pythalesians.util.loggermanager.LoggerManager.infro方法的典型用法代码示例。如果您正苦于以下问题:Python LoggerManager.infro方法的具体用法?Python LoggerManager.infro怎么用?Python LoggerManager.infro使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pythalesians.util.loggermanager.LoggerManager
的用法示例。
在下文中一共展示了LoggerManager.infro方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: LoaderBBG
# 需要导入模块: from pythalesians.util.loggermanager import LoggerManager [as 别名]
# 或者: from pythalesians.util.loggermanager.LoggerManager import infro [as 别名]
class LoaderBBG(LoaderTemplate):
def __init__(self):
super(LoaderBBG, self).__init__()
self.logger = LoggerManager().getLogger(__name__)
# implement method in abstract superclass
def load_ticker(self, time_series_request):
"""
load_ticker - Retrieves market data from external data source (in this case Bloomberg)
Parameters
----------
time_series_request : TimeSeriesRequest
contains all the various parameters detailing time series start and finish, tickers etc
Returns
-------
DataFrame
"""
time_series_request_vendor = self.construct_vendor_time_series_request(time_series_request)
data_frame = None
self.logger.info("Request Bloomberg data")
# do we need daily or intraday data?
if time_series_request.freq in ["daily", "weekly", "monthly", "quarterly", "yearly"]:
# for events times/dates separately needs ReferenceDataRequest (when specified)
if "release-date-time-full" in time_series_request.fields:
# experimental
datetime_data_frame = self.get_reference_data(time_series_request_vendor, time_series_request)
# remove fields 'release-date-time-full' from our request (and the associated field in the vendor)
index = time_series_request.fields.index("release-date-time-full")
time_series_request_vendor.fields.pop(index)
time_series_request.fields.pop(index)
# download all the other event fields (uses HistoricalDataRequest to Bloomberg)
# concatenate with date time fields
if len(time_series_request_vendor.fields) > 0:
events_data_frame = self.get_daily_data(time_series_request, time_series_request_vendor)
col = events_data_frame.index.name
events_data_frame = events_data_frame.reset_index(drop=False)
data_frame = pandas.concat([events_data_frame, datetime_data_frame], axis=1)
temp = data_frame[col]
del data_frame[col]
data_frame.index = temp
else:
data_frame = datetime_data_frame
# for all other daily/monthly/quarter data, we can use HistoricalDataRequest to Bloomberg
else:
data_frame = self.get_daily_data(time_series_request, time_series_request_vendor)
# assume one ticker only
# for intraday data we use IntradayDataRequest to Bloomberg
if time_series_request.freq in ["intraday", "minute", "hourly"]:
time_series_request_vendor.tickers = time_series_request_vendor.tickers[0]
data_frame = self.download_intraday(time_series_request_vendor)
cols = data_frame.columns.values
data_frame.tz_localize("UTC")
cols = time_series_request.tickers[0] + "." + cols
data_frame.columns = cols
self.logger.info("Completed request from Bloomberg.")
return data_frame
def get_daily_data(self, time_series_request, time_series_request_vendor):
data_frame = self.download_daily(time_series_request_vendor)
# convert from vendor to Thalesians tickers/fields
if data_frame is not None:
if data_frame.empty:
self.logger.infro("No tickers returned")
return None
returned_fields = data_frame.columns.get_level_values(0)
returned_tickers = data_frame.columns.get_level_values(1)
# TODO if empty try downloading again a year later
fields = self.translate_from_vendor_field(returned_fields, time_series_request)
tickers = self.translate_from_vendor_ticker(returned_tickers, time_series_request)
ticker_combined = []
for i in range(0, len(fields)):
ticker_combined.append(tickers[i] + "." + fields[i])
data_frame.columns = ticker_combined
data_frame.index.name = "Date"
return data_frame
#.........这里部分代码省略.........