Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _getIndexRangeByDate(self, market, code, query):
"""
【重载接口】(必须)按日期获取指定的K线数据
:param str market: 市场标识
:param str code: 证券代码
:param KQuery query: 日期查询条件(QueryByDate)
"""
print("getIndexRangeByDate")
if query.queryType != Query.DATE:
return (0, 0)
start_datetime = query.startDatetime
end_datetime = query.endDatetime
if start_datetime >= end_datetime or start_datetime > Datetime.max():
return (0, 0)
data = self._get_bars(market, code, query.kType)
total = len(data)
if total == 0:
return (0, 0)
mid, low = 0, 0
high = total-1
while low <= high:
tmp_datetime = Datetime(data[high].get('datetime'))
if start_datetime > tmp_datetime:
mid = high + 1
break
tmp_datetime = Datetime(data[low].get('datetime'))
def _getIndexRangeByDate(self, market, code, query):
"""
【重载接口】(必须)按日期获取指定的K线数据
:param str market: 市场标识
:param str code: 证券代码
:param KQuery query: 日期查询条件(QueryByDate)
"""
print("getIndexRangeByDate")
if query.queryType != Query.DATE:
return (0, 0)
start_datetime = query.startDatetime
end_datetime = query.endDatetime
if start_datetime >= end_datetime or start_datetime > Datetime.max():
return (0, 0)
data = self._get_bars(market, code, query.kType)
total = len(data)
if total == 0:
return (0, 0)
mid, low = 0, 0
high = total-1
while low <= high:
tmp_datetime = Datetime(data.index[high])
if start_datetime > tmp_datetime:
mid = high + 1
break
tmp_datetime = Datetime(data.index[low])
def _getIndexRangeByDate(self, market, code, query):
"""
【重载接口】(必须)按日期获取指定的K线数据
:param str market: 市场标识
:param str code: 证券代码
:param KQuery query: 日期查询条件(QueryByDate)
"""
print("getIndexRangeByDate")
if query.queryType != Query.DATE:
return (0, 0)
start_datetime = query.startDatetime
end_datetime = query.endDatetime
if start_datetime >= end_datetime or start_datetime > Datetime.max():
return (0, 0)
data = self._get_bars(market, code, query.kType)
total = len(data)
if total == 0:
return (0, 0)
mid, low = 0, 0
high = total-1
while low <= high:
tmp_datetime = Datetime(data[high].get('datetime'))
if start_datetime > tmp_datetime:
mid = high + 1
break
tmp_datetime = Datetime(data[low].get('datetime'))