gjdatac-api 0.0.1__tar.gz → 0.0.2__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.0.1
3
+ Version: 0.0.2
4
4
  Summary: 主动管理项目第一版(部分接口)
5
5
  Home-page: UNKNOWN
6
6
  Author: yin
@@ -0,0 +1,9 @@
1
+ from .data_api_class import GJDataC
2
+ from .initializer import init # 导入你的初始化函数
3
+
4
+ __all__ = ['GJDataC']
5
+
6
+
7
+ def __init__(ip_address, port, user_id, password):
8
+ init(ip_address, port, user_id, password) # 执行初始化验证
9
+ return GJDataC() # 验证成功后返回你的类实例
@@ -581,47 +581,36 @@ class GJDataC:
581
581
  def __get_price_data_get_data(self, order_book_ids, asset_type, frequency):
582
582
  """
583
583
  根据参数获取数据库和表名,调用接口获取数据
584
-
584
+
585
585
  :param order_book_ids: 合约代码列表
586
586
  :param asset_type: 合约类型
587
587
  :param frequency: 频率
588
588
  :return: None
589
589
  """
590
590
 
591
- ''' 期货行情数据 '''
592
- if asset_type == "future":
593
- if frequency == "tick_l1": # 期货l1级别tick行情数据
594
- self.get_price_data = self._get_price_get_data(order_book_ids, history_future_tick_db_table_name,
595
- history_future_tick_db_path)
596
- elif frequency == "1d": # 期货日bar行情数据
597
- self.get_price_data = self._get_price_get_data(order_book_ids, history_future_day_db_table_name,
598
- history_future_day_db_path)
599
- elif frequency == "1min": # 期货分钟bar行情数据
600
- self.get_price_data = self._get_price_get_data(order_book_ids, history_future_min_db_table_name,
601
- history_future_min_db_path)
602
- # 数据库暂无数据
603
- # elif frequency == "1min_gtja": # 公司合成的分钟bar行情数据
604
- # self.get_price_data = self._get_price_get_data(order_book_ids, history_future_min_gtja_db_table_name,
605
- # history_future_min_gtja_db_path)
606
- # elif frequency == "tick_l2": # 期货l2级别tick行情数据
607
- # self.get_price_data = self._get_price_get_data(order_book_ids, history_future_tick_l2_db_table_name,
608
- # history_future_tick_l2_db_path)
609
- # else:
610
- # raise Exception("frequency is not valid for future contract")
611
- elif asset_type == "option":
612
- if frequency == "1d": # 期权日bar行情数据
613
- self.get_price_data = self._get_price_get_data(order_book_ids, history_option_day_db_table_name,
614
- history_option_day_db_path)
615
- elif frequency == "1min": # 期权分钟bar行情数据
616
- self.get_price_data = self._get_price_get_data(order_book_ids, history_option_min_db_table_name,
617
- history_option_min_db_path)
618
- elif frequency == "tick": # 期权tick行情数据
619
- self.get_price_data = self._get_price_get_data(order_book_ids, history_option_tick_db_table_name,
620
- history_option_tick_db_path)
591
+ def get_db_table_name(asset_type, frequency):
592
+ if asset_type == "future":
593
+ return {
594
+ "tick_l1": (history_future_tick_db_table_name, history_future_tick_db_path),
595
+ "1d": (history_future_day_db_table_name, history_future_day_db_path),
596
+ "1min": (history_future_min_db_table_name, history_future_min_db_path),
597
+ # "1min_gtja": (history_future_min_gtja_db_table_name, history_future_min_gtja_db_path),
598
+ # "tick_l2": (history_future_tick_l2_db_table_name, history_future_tick_l2_db_path),
599
+ }.get(frequency)
600
+ elif asset_type == "option":
601
+ return {
602
+ "1d": (history_option_day_db_table_name, history_option_day_db_path),
603
+ "1min": (history_option_min_db_table_name, history_option_min_db_path),
604
+ "tick": (history_option_tick_db_table_name, history_option_tick_db_path),
605
+ }.get(frequency)
621
606
  else:
622
- raise Exception("frequency is not valid for option contract")
623
- else:
624
- raise Exception("asset_type is not valid")
607
+ raise Exception("asset_type is not valid")
608
+
609
+ db_table_name = get_db_table_name(asset_type, frequency)
610
+ if db_table_name is None:
611
+ raise Exception("frequency is not valid for this asset_type")
612
+
613
+ self.get_price_data = self._get_price_get_data(order_book_ids, *db_table_name)
625
614
 
626
615
  """ get_instruments(合约基础信息) """
627
616
 
@@ -0,0 +1,10 @@
1
+ import dolphindb as ddb
2
+
3
+
4
+ def init(ip_address, port, user_id, password):
5
+ # 在这里实现 IP 地址和端口号的验证逻辑
6
+ try:
7
+ db_session = ddb.session()
8
+ db_session.connect(ip_address, port, user_id, password)
9
+ except Exception as e:
10
+ raise Exception("please check your ip_address, port, user_id, password")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gjdatac-api
3
- Version: 0.0.1
3
+ Version: 0.0.2
4
4
  Summary: 主动管理项目第一版(部分接口)
5
5
  Home-page: UNKNOWN
6
6
  Author: yin
@@ -3,6 +3,7 @@ gjdatac_api/__init__.py
3
3
  gjdatac_api/data_api_class.py
4
4
  gjdatac_api/dict_data.py
5
5
  gjdatac_api/dolphin_db_info.py
6
+ gjdatac_api/initializer.py
6
7
  gjdatac_api.egg-info/PKG-INFO
7
8
  gjdatac_api.egg-info/SOURCES.txt
8
9
  gjdatac_api.egg-info/dependency_links.txt
@@ -5,12 +5,12 @@ with open('description_info.md', 'r', encoding='utf-8') as f:
5
5
 
6
6
  setup(
7
7
  name='gjdatac_api', # 你的包名
8
- version='0.0.1', # 版本号
8
+ version='0.0.2', # 版本号
9
9
  description='主动管理项目第一版(部分接口)', # 包的简要描述
10
10
  long_description=long_description, # 包的详细描述
11
11
  long_description_content_type='text/markdown', # 描述文件的类型
12
12
  include_package_data=True, # 包含包数据
13
- package_data={'gjdatac_api': ['*.py', 'dict_data.py', 'dolphin_db_info.py']}, # 指定数据文件
13
+ package_data={'gjdatac_api': ['*.py', 'dict_data.py', 'dolphin_db_info.py', 'initializer.py']}, # 指定数据文件
14
14
  author='yin', # 作者姓名
15
15
  author_email='2018209921@qq.com', # 作者邮箱
16
16
  packages=find_packages(), # 自动查找包目录
@@ -1,3 +0,0 @@
1
- from .data_api_class import GJDataC
2
-
3
- __all__ = ['GJDataC']
File without changes