gjdatac-api 0.2.7__tar.gz → 0.2.8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gjdatac_api
3
- Version: 0.2.7
3
+ Version: 0.2.8
4
4
  Summary: 数据接口打包
5
5
  Author: yin
6
6
  Author-email: 2018209921@qq.com
@@ -10,7 +10,7 @@ import chinese_calendar as calendar
10
10
  import pandas as pd
11
11
  import dolphindb as ddb
12
12
 
13
- from .dict_data import (get_price_frequency_dict, get_price_data_type_dict, get_instruments_type_dict,
13
+ from dict_data import (get_price_frequency_dict, get_price_data_type_dict, get_instruments_type_dict,
14
14
  future_delivery_fee_return_fields, future_delivery_fee_return_fields_rename,
15
15
  future_margin_ratio_return_fields, future_margin_ratio_return_fields_rename,
16
16
  future_limit_position_return_fields, future_limit_position_return_fields_rename,
@@ -18,13 +18,13 @@ from .dict_data import (get_price_frequency_dict, get_price_data_type_dict, get_
18
18
  tick_main_contract_return_fields, tick_main_contract_return_fields_rename,
19
19
  gtja_mink_main_contract_return_fields, gtja_mink_main_contract_return_fields_rename
20
20
  )
21
- from .dolphindb_info import *
22
- from .instrument_class import Instrument
21
+ from dolphindb_info import *
22
+ from instrument_class import Instrument
23
23
 
24
24
 
25
25
  class GJDataC:
26
26
 
27
- def __init__(self, host, port, user_id, password, dolphindb_service):
27
+ def __init__(self, host, port, user_id, password, dolphindb_service=None):
28
28
  """
29
29
  用于定义一些不同接口所需的变量以及一些初始化操作
30
30
  :param host: 数据库地址
@@ -1135,7 +1135,7 @@ class GJDataC:
1135
1135
  return self.get_trading_dates_by_date_n(date, n)
1136
1136
  elif start_date and end_date: # 根据start_date和end_date获取交易日历
1137
1137
  return self.get_trading_dates_by_start_end(start_date, end_date, is_include_start, is_include_end)
1138
- elif trade_time and date_count and date_type: # 查询前/后 N个交易日/时间数据
1138
+ elif trade_time and date_count is not None and date_type: # 查询前/后 N个交易日/时间数据
1139
1139
  return self.get_trading_date(trade_time, date_count, date_type)
1140
1140
  else:
1141
1141
  raise ValueError("parameter error: please pass date、n or start_date、end_date")
@@ -3869,7 +3869,7 @@ class GJDataC:
3869
3869
 
3870
3870
  # 将结果转换为指定格式的字符串列表
3871
3871
  fina_result = sorted(result.dt.strftime('%Y.%m.%d').tolist())
3872
- return fina_result[0] if len(fina_result) <= 1 else fina_result
3872
+ return fina_result if len(fina_result) <= 1 else fina_result
3873
3873
 
3874
3874
  @staticmethod
3875
3875
  def get_trading_minutes(trading_dates, trade_time, date_count):
@@ -3886,10 +3886,13 @@ class GJDataC:
3886
3886
  # 筛选 trade_flag 列等于 T 的数据(是交易日的数据)
3887
3887
  trading_dates = trading_dates[trading_dates['trade_flag'] == 'T']
3888
3888
 
3889
+ # 转换字符串为 datetime
3890
+ trade_time = datetime.datetime.strptime(trade_time, '%Y.%m.%d %H:%M:%S')
3891
+
3889
3892
  # 生成时间点列表
3890
3893
  time_points = pd.date_range(start=trade_time - datetime.timedelta(minutes=abs(date_count)),
3891
3894
  end=trade_time + datetime.timedelta(minutes=abs(date_count)),
3892
- freq='T') # 'T' 表示分钟频率
3895
+ freq='min') # 'T' 表示分钟频率
3893
3896
 
3894
3897
  # 将时间点转换为指定格式的字符串
3895
3898
  time_points_str = time_points.strftime('%Y.%m.%d %H:%M:%S')
@@ -3909,7 +3912,8 @@ class GJDataC:
3909
3912
  # 向后查询
3910
3913
  result = [p for p in valid_time_points if pd.to_datetime(p) > trade_time][:date_count]
3911
3914
 
3912
- return sorted(result) if len(result) > 1 else result[0]
3915
+ # return sorted(result) if len(result) > 1 else result[0]
3916
+ return sorted(result) if len(result) > 1 else result
3913
3917
 
3914
3918
  """ 交易日判断 """
3915
3919
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gjdatac-api
3
- Version: 0.2.7
3
+ Version: 0.2.8
4
4
  Summary: 数据接口打包
5
5
  Author: yin
6
6
  Author-email: 2018209921@qq.com
@@ -5,7 +5,7 @@ with open('description_info.md', 'r', encoding='utf-8') as f:
5
5
 
6
6
  setup(
7
7
  name='gjdatac_api', # 你的包名
8
- version='0.2.7', # 版本号
8
+ version='0.2.8', # 版本号
9
9
  description='数据接口打包', # 包的简要描述
10
10
  long_description=long_description, # 包的详细描述
11
11
  long_description_content_type='text/markdown', # 描述文件的类型
File without changes