libfinance 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.

Potentially problematic release.


This version of libfinance might be problematic. Click here for more details.

Files changed (27) hide show
  1. {libfinance-0.0.1 → libfinance-0.0.2}/PKG-INFO +2 -2
  2. libfinance-0.0.2/README.md +63 -0
  3. libfinance-0.0.2/libfinance/__init__.py +20 -0
  4. {libfinance-0.0.1 → libfinance-0.0.2}/libfinance/api/calendar.py +3 -3
  5. libfinance-0.0.2/libfinance/api/concept.py +87 -0
  6. {libfinance-0.0.1 → libfinance-0.0.2}/libfinance/api/get_price.py +85 -6
  7. libfinance-0.0.2/libfinance/api/index_components.py +74 -0
  8. {libfinance-0.0.1 → libfinance-0.0.2}/libfinance/client.py +3 -2
  9. {libfinance-0.0.1 → libfinance-0.0.2}/libfinance/utils/decorators.py +2 -1
  10. {libfinance-0.0.1 → libfinance-0.0.2}/libfinance.egg-info/PKG-INFO +2 -2
  11. {libfinance-0.0.1 → libfinance-0.0.2}/libfinance.egg-info/SOURCES.txt +1 -1
  12. {libfinance-0.0.1 → libfinance-0.0.2}/libfinance.egg-info/requires.txt +1 -1
  13. {libfinance-0.0.1 → libfinance-0.0.2}/setup.py +2 -2
  14. libfinance-0.0.1/README.md +0 -59
  15. libfinance-0.0.1/libfinance/__init__.py +0 -6
  16. libfinance-0.0.1/libfinance/api/index_components.py +0 -20
  17. libfinance-0.0.1/libfinance/version.py +0 -3
  18. {libfinance-0.0.1 → libfinance-0.0.2}/libfinance/api/__init__.py +0 -0
  19. {libfinance-0.0.1 → libfinance-0.0.2}/libfinance/libfinance.thrift +0 -0
  20. {libfinance-0.0.1 → libfinance-0.0.2}/libfinance/utils/__init__.py +0 -0
  21. {libfinance-0.0.1 → libfinance-0.0.2}/libfinance/utils/datetime_func.py +0 -0
  22. {libfinance-0.0.1 → libfinance-0.0.2}/libfinance/utils/loader.py +0 -0
  23. {libfinance-0.0.1 → libfinance-0.0.2}/libfinance/utils/serialize.py +0 -0
  24. {libfinance-0.0.1 → libfinance-0.0.2}/libfinance.egg-info/dependency_links.txt +0 -0
  25. {libfinance-0.0.1 → libfinance-0.0.2}/libfinance.egg-info/not-zip-safe +0 -0
  26. {libfinance-0.0.1 → libfinance-0.0.2}/libfinance.egg-info/top_level.txt +0 -0
  27. {libfinance-0.0.1 → libfinance-0.0.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: libfinance
3
- Version: 0.0.1
3
+ Version: 0.0.2
4
4
  Summary: libfinance
5
5
  Home-page:
6
6
  Author:
@@ -13,4 +13,4 @@ Classifier: Programming Language :: Python :: 3.7
13
13
  Classifier: Programming Language :: Python :: 3.8
14
14
  Requires-Dist: dill>=0.3.8
15
15
  Requires-Dist: thriftpy2>=0.3.9
16
- Requires-Dist: pandas>=0.16.2
16
+ Requires-Dist: pandas==1.3.4
@@ -0,0 +1,63 @@
1
+ # libfinance
2
+
3
+ `libfinance` is python library for accessing financial data easily. The goal of `libfinance` is to provide HIGH quality financial data for scholars, researchers and developers in research and production environment.
4
+
5
+
6
+ # install
7
+
8
+ Method1: Install `libfinance` by `pip`
9
+
10
+ ``` {.sourceCode .bash}
11
+ $ pip install libfinance
12
+ ```
13
+
14
+ Method2: Install from source with a develop mode
15
+ ~~~
16
+ git clone https://github.com/StateOfTheArt-quant/libfinance.git
17
+ cd libfinance
18
+ pip install -e .
19
+ ~~~
20
+
21
+ # quick-start
22
+
23
+ ~~~
24
+ from libfinance import get_trading_dates, get_price
25
+
26
+ trading_dates = get_trading_dates(start_date="2023-12-25", end_date="2024-01-11")
27
+ print(trading_dates)
28
+
29
+
30
+ DatetimeIndex(['2023-12-25', '2023-12-26', '2023-12-27', '2023-12-28',
31
+ '2023-12-29', '2024-01-02', '2024-01-03', '2024-01-04',
32
+ '2024-01-05', '2024-01-08', '2024-01-09', '2024-01-10',
33
+ '2024-01-11'],
34
+ dtype='datetime64[ns]', freq=None)
35
+
36
+
37
+
38
+
39
+ data = get_price(order_book_ids=["000001.XSHE","600000.XSHG"], start_date="2024-03-01", end_date="2024-03-11")
40
+ print(data)
41
+
42
+ open high low close volume
43
+ order_book_id datetime
44
+ 000001.XSHE 2024-03-01 10.59 10.60 10.43 10.49 182810290.0
45
+ 2024-03-04 10.45 10.50 10.32 10.33 165592954.0
46
+ 2024-03-05 10.30 10.47 10.26 10.43 181731907.0
47
+ 2024-03-06 10.40 10.45 10.33 10.33 134564016.0
48
+ 2024-03-07 10.33 10.64 10.33 10.38 201616589.0
49
+ 2024-03-08 10.35 10.44 10.30 10.38 111397428.0
50
+ 2024-03-11 10.38 10.47 10.34 10.47 121067298.0
51
+ 600000.XSHG 2024-03-01 7.13 7.16 7.10 7.11 29431801.0
52
+ 2024-03-04 7.12 7.12 7.05 7.07 27855963.0
53
+ 2024-03-05 7.05 7.18 7.04 7.16 41756232.0
54
+ 2024-03-06 7.17 7.22 7.12 7.12 25918749.0
55
+ 2024-03-07 7.12 7.20 7.11 7.14 24690348.0
56
+ 2024-03-08 7.12 7.17 7.11 7.12 19861794.0
57
+ 2024-03-11 7.13 7.17 7.06 7.11 26195498.0
58
+ ~~~
59
+
60
+ # Documentation
61
+
62
+ More info for [Documentation](https://libfinance.readthedocs.io/zh/latest/)
63
+
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+ __all__ = ["__version__"]
5
+
6
+ __version__ = "0.0.1"
7
+ #from libfinance.api import *
8
+ def __go():
9
+ import sys
10
+ import importlib
11
+ import pkgutil
12
+
13
+ # 3.4 引入 asyncio,3.5 引入 async/await 语法,3.6 引入 async generator
14
+ async_syntax_supported = sys.version_info[:2] >= (3, 6)
15
+
16
+ for loader, module_name, is_pkg in pkgutil.walk_packages(__path__, "libfinance."):
17
+ if module_name.startswith("libfinance.api") and not is_pkg:
18
+ importlib.import_module(module_name)
19
+
20
+ __go()
@@ -29,7 +29,7 @@ def get_trading_dates(start_date, end_date):
29
29
 
30
30
  .. code-block:: python3
31
31
 
32
- from libfinance.api import get_trading_dates
32
+ from libfinance import get_trading_dates
33
33
 
34
34
 
35
35
  >>> trading_dates = get_trading_dates(start_date = "2020-05-11", end_date="2020-05-20")
@@ -59,7 +59,7 @@ def get_previous_trading_date(date, n=1):
59
59
 
60
60
  .. code-block:: python3
61
61
 
62
- from libfinance.api import get_previous_trading_date
62
+ from libfinance import get_previous_trading_date
63
63
 
64
64
  >>> get_previous_trading_date(date='2020-05-18', n=3)
65
65
  Timestamp('2020-05-13 00:00:00')
@@ -83,7 +83,7 @@ def get_next_trading_date(date, n=1):
83
83
 
84
84
  .. code-block:: python3
85
85
 
86
- from simonsc.api import get_next_trading_date
86
+ from libfinance import get_next_trading_date
87
87
 
88
88
  >>> get_next_trading_date(date='2020-05-13', n=3)
89
89
  Timestamp('2020-05-18 00:00:00')
@@ -0,0 +1,87 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ import datetime
4
+ from typing import Any, Union, Optional, Iterable, Dict, List, Sequence, Iterable
5
+
6
+ import pandas as pd
7
+ from libfinance.client import get_client
8
+ from libfinance.utils.decorators import export_as_api, ttl_cache, compatible_with_parm
9
+
10
+ @export_as_api
11
+ def get_concept_meta(source:str="THS") -> pd.DataFrame:
12
+ """
13
+ 获取某个数据源的概念分类的元信息
14
+
15
+ :param source: 来源(当前仅支持的同花顺(THS)这一来源的概念分类)
16
+
17
+ :example:
18
+
19
+ .. code-block:: python3
20
+
21
+ from libfinance import get_concept_meta
22
+
23
+ >>> concept_meta = get_concept_meta(source="THS")
24
+ >>> print(>>>)
25
+
26
+ datetime concept_name component_number concept_id source
27
+ 0 2024-03-25 AI语料 25.0 309126 THS
28
+ 1 2024-03-20 铜缆高速连接 24.0 309125 THS
29
+ 2 2024-03-12 高股息精选 327.0 309124 THS
30
+ 3 2024-03-04 AI PC 13.0 309121 THS
31
+ 4 2024-03-04 AI手机 19.0 309120 THS
32
+ .. ... ... ... ... ...
33
+ 402 2000-01-01 京津冀一体化 NaN 300061 THS
34
+ 403 2000-01-01 流感 NaN 300038 THS
35
+ 404 2000-01-01 苹果概念 NaN 300309 THS
36
+ 405 2000-01-01 PM2.5 NaN 300134 THS
37
+ 406 2000-01-01 石墨烯 NaN 300337 THS
38
+ """
39
+ return get_client().get_concept_meta(source=source)
40
+
41
+ @export_as_api
42
+ def get_concept_weights(concept_ids:list, source:str="THS") -> pd.DataFrame:
43
+ """
44
+ 获取某一个概念的成分股及其权重数据
45
+ :param concept_ids: 概念id的列表
46
+ :param source: 来源(当前仅支持的同花顺(THS)这一来源的概念分类)
47
+
48
+ :example:
49
+
50
+ .. code-block:: python
51
+
52
+ from libfinance import get_concept_weights
53
+
54
+ >>> concept_weight = get_concept_weights(concept_ids=["309126"], source="THS")
55
+ >>> print(concept_weight)
56
+
57
+ order_book_id instrument_name weight ... source update_date concept_name
58
+ 0 002908.XSHE 德生科技 0.04 ... THS 2024-04-01 AI语料
59
+ 1 300133.XSHE 华策影视 0.04 ... THS 2024-04-01 AI语料
60
+ 2 002226.XSHE 江南化工 0.04 ... THS 2024-04-01 AI语料
61
+ 3 300766.XSHE 每日互动 0.04 ... THS 2024-04-01 AI语料
62
+ 4 002649.XSHE 博彦科技 0.04 ... THS 2024-04-01 AI语料
63
+ 5 600728.XSHG 佳都科技 0.04 ... THS 2024-04-01 AI语料
64
+ 6 600100.XSHG 同方股份 0.04 ... THS 2024-04-01 AI语料
65
+ 7 000710.XSHE 贝瑞基因 0.04 ... THS 2024-04-01 AI语料
66
+ 8 688590.XSHG 新致软件 0.04 ... THS 2024-04-01 AI语料
67
+ 9 603000.XSHG 人民网 0.04 ... THS 2024-04-01 AI语料
68
+ 10 300033.XSHE 同花顺 0.04 ... THS 2024-04-01 AI语料
69
+ 11 002362.XSHE 汉王科技 0.04 ... THS 2024-04-01 AI语料
70
+ 12 000681.XSHE 视觉中国 0.04 ... THS 2024-04-01 AI语料
71
+ 13 300166.XSHE 东方国信 0.04 ... THS 2024-04-01 AI语料
72
+ 14 002230.XSHE 科大讯飞 0.04 ... THS 2024-04-01 AI语料
73
+ 15 300182.XSHE 捷成股份 0.04 ... THS 2024-04-01 AI语料
74
+ 16 300418.XSHE 昆仑万维 0.04 ... THS 2024-04-01 AI语料
75
+ 17 688787.XSHG 海天瑞声 0.04 ... THS 2024-04-01 AI语料
76
+ 18 300229.XSHE 拓尔思 0.04 ... THS 2024-04-01 AI语料
77
+ 19 601858.XSHG 中国科传 0.04 ... THS 2024-04-01 AI语料
78
+ 20 300785.XSHE 值得买 0.04 ... THS 2024-04-01 AI语料
79
+ 21 300654.XSHE 世纪天鸿 0.04 ... THS 2024-04-01 AI语料
80
+ 22 300364.XSHE 中文在线 0.04 ... THS 2024-04-01 AI语料
81
+ 23 603721.XSHG 中广天择 0.04 ... THS 2024-04-01 AI语料
82
+ 24 603533.XSHG 掌阅科技 0.04 ... THS 2024-04-01 AI语料
83
+
84
+ [25 rows x 7 columns]
85
+ """
86
+ return get_client().get_concept_weights(concept_ids=concept_ids, source = source)
87
+
@@ -13,8 +13,8 @@ from libfinance.utils.datetime_func import convert_dateteime_to_timestamp
13
13
  def history_bars(
14
14
  order_book_ids: list,
15
15
  bar_count: int,
16
- frequency: str,
17
16
  datetime: str,
17
+ frequency: str="1d",
18
18
  fields: List[str]=None,
19
19
  skip_suspended: bool=True,
20
20
  include_now: bool=True,
@@ -53,12 +53,11 @@ def history_bars(
53
53
  .. code-block:: python3
54
54
 
55
55
  import pandas as pd
56
- from simons.api import history_bars
56
+ from libfinance import history_bars
57
57
 
58
58
  #
59
- >>> dt = pd.Timestamp("2020-04-20")
60
- >>> fields=["datetime","open","high","low","close","volume"]
61
- >>> data = history_bars(order_book_ids=["000001.XSHE", "000002.XSHE"], datatime=dt, bar_count=10, frequency="1d", fields=fields)
59
+ >>> dt = "2020-04-20"
60
+ >>> data = history_bars(order_book_ids=["000001.XSHE", "000002.XSHE"], datetime=dt, bar_count=10)
62
61
  >>> print(data)
63
62
 
64
63
  open high low close volume
@@ -86,7 +85,7 @@ def history_bars(
86
85
 
87
86
  """
88
87
  dt = convert_dateteime_to_timestamp(datetime)
89
- return get_client().multi_history_bars(order_book_ids=order_book_ids,
88
+ return get_client().history_bars(order_book_ids=order_book_ids,
90
89
  bar_count=bar_count,
91
90
  frequency=frequency,
92
91
  fields=fields,
@@ -94,4 +93,84 @@ def history_bars(
94
93
  skip_suspended=skip_suspended,
95
94
  include_now=include_now,
96
95
  adjust_type=adjust_type,
96
+ adjust_orig=adjust_orig)
97
+
98
+ @export_as_api
99
+ def get_price(
100
+ order_book_ids: list,
101
+ start_date: str,
102
+ end_date: str,
103
+ frequency: str="1d",
104
+ fields: List[str]=None,
105
+ skip_suspended: bool=True,
106
+ include_now: bool=True,
107
+ adjust_type: str="none",
108
+ adjust_orig:datetime.datetime = None) -> pd.DataFrame:
109
+ """获取指定合约的历史 k 线行情,支持任意日频率xd(1d,5d)和任意分钟频率xm(1m,3m,5m,15m)的历史数据。
110
+
111
+ :param order_book_ids: 多个标的合约代码, 必填项
112
+ :param start_date: 开始日期,必填项
113
+ :param end_date: 结束日期,必填项
114
+ :param frequency: 获取数据什么样的频率进行。'1d'或'1m'分别表示每日和每分钟
115
+ :param fields: 返回数据字段
116
+ :param skip_suspended: 是否跳过停牌数据
117
+ :param include_now: 是否包含当前数据
118
+ :param adjust_type: 复权类型,默认为前复权 pre;可选 pre, none, post
119
+
120
+ ========================= ===================================================
121
+ fields 字段名
122
+ ========================= ===================================================
123
+ datetime 时间戳
124
+ open 开盘价
125
+ high 最高价
126
+ low 最低价
127
+ close 收盘价
128
+ volume 成交量
129
+ total_turnover 成交额
130
+ open_interest 持仓量(期货专用)
131
+ basis_spread 期现差(股指期货专用)
132
+ settlement 结算价(期货日线专用)
133
+ prev_settlement 结算价(期货日线专用)
134
+ ========================= ===================================================
135
+
136
+ Example1::
137
+
138
+ 获取中国平安和浦发银行 2024-03-01至2024-03-11之间的交易数据
139
+
140
+ .. code-block:: python3
141
+
142
+ import pandas as pd
143
+ from libfinance import get_price
144
+
145
+ >>> data = get_price(order_book_ids=["000001.XSHE","600000.XSHG"], start_date="2024-03-01", end_date="2024-03-11")
146
+ >>> print(data)
147
+
148
+ open high low close volume
149
+ order_book_id datetime
150
+ 000001.XSHE 2024-03-01 10.59 10.60 10.43 10.49 182810290.0
151
+ 2024-03-04 10.45 10.50 10.32 10.33 165592954.0
152
+ 2024-03-05 10.30 10.47 10.26 10.43 181731907.0
153
+ 2024-03-06 10.40 10.45 10.33 10.33 134564016.0
154
+ 2024-03-07 10.33 10.64 10.33 10.38 201616589.0
155
+ 2024-03-08 10.35 10.44 10.30 10.38 111397428.0
156
+ 2024-03-11 10.38 10.47 10.34 10.47 121067298.0
157
+ 600000.XSHG 2024-03-01 7.13 7.16 7.10 7.11 29431801.0
158
+ 2024-03-04 7.12 7.12 7.05 7.07 27855963.0
159
+ 2024-03-05 7.05 7.18 7.04 7.16 41756232.0
160
+ 2024-03-06 7.17 7.22 7.12 7.12 25918749.0
161
+ 2024-03-07 7.12 7.20 7.11 7.14 24690348.0
162
+ 2024-03-08 7.12 7.17 7.11 7.12 19861794.0
163
+ 2024-03-11 7.13 7.17 7.06 7.11 26195498.0
164
+
165
+ """
166
+ start_date = convert_dateteime_to_timestamp(start_date)
167
+ end_date = convert_dateteime_to_timestamp(end_date)
168
+ return get_client().get_price(order_book_ids=order_book_ids,
169
+ start_date=start_date,
170
+ end_date=end_date,
171
+ frequency=frequency,
172
+ fields=fields,
173
+ skip_suspended=skip_suspended,
174
+ include_now=include_now,
175
+ adjust_type=adjust_type,
97
176
  adjust_orig=adjust_orig)
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+ import datetime
5
+ from typing import Any, Union, Optional, Iterable, Dict, List, Sequence, Iterable
6
+
7
+ import pandas as pd
8
+ from libfinance.client import get_client
9
+ from libfinance.utils.decorators import export_as_api, ttl_cache, compatible_with_parm
10
+
11
+ @export_as_api
12
+ def get_instrument_industry(order_book_ids: list, date: Union[str, datetime.datetime], source: str = "010303") -> pd.DataFrame:
13
+ """
14
+ 获取股票合约的所属行业信息
15
+
16
+ :param order_book_ids: 股票合约的id列表
17
+ :param date: 日期
18
+ :param source: 来源(010303-申万行业分类, 010314-中证行业分类(2016版),010321-申万行业分类(2021版), 010317-中信行业分类)
19
+
20
+ :example:
21
+
22
+ .. code-block:: python3
23
+
24
+ from libfinance import get_instrument_industry
25
+
26
+ >>> order_book_ids = ["000001.XSHE","600000.XSHG"]
27
+ >>> instrument_industry = get_instrument_industry(order_book_ids=order_book_ids, date="2022-09-20")
28
+ >>> print(instrument_industry)
29
+
30
+ industry industryID1 industryName1 industryID2 industryName2
31
+ order_book_id
32
+ 000001.XSHE 申万行业分类 1030321 银行 103032101 银行
33
+ 600000.XSHG 申万行业分类 1030321 银行 103032101 银行
34
+
35
+ """
36
+ return get_client().get_instrument_industry(order_book_ids=order_book_ids, date=date, source=source)
37
+
38
+ @export_as_api
39
+ def get_index_weights(index_id: str = "000300.XSHG", date: Union[str, datetime.datetime] = None) -> pd.DataFrame:
40
+ """
41
+ 获取特定日期,指数成分股及其权重数据
42
+
43
+ :param index_id: 指数的id
44
+ :param date: 日期(当前仅支持的同花顺(THS)这一来源的概念分类)
45
+
46
+ :example:
47
+
48
+ .. code-block:: python3
49
+
50
+ from libfinance import get_index_weights
51
+
52
+ >>> index_weight = get_index_weights(index_id="000300.XSHG", date="2022-07-20")
53
+ >>> print(index_weight)
54
+
55
+ index_order_book_id index_name ... order_book_name weight
56
+ datetime ...
57
+ 2022-07-20 000300.XSHG 沪深300 ... 歌尔股份 0.003813
58
+ 2022-07-20 000300.XSHG 沪深300 ... 新城控股 0.000934
59
+ 2022-07-20 000300.XSHG 沪深300 ... 凯莱英 0.001957
60
+ 2022-07-20 000300.XSHG 沪深300 ... 华侨城A 0.001139
61
+ 2022-07-20 000300.XSHG 沪深300 ... 特变电工 0.005060
62
+ ... ... ... ... ...
63
+ 2022-07-20 000300.XSHG 沪深300 ... 晶盛机电 0.002218
64
+ 2022-07-20 000300.XSHG 沪深300 ... 华能国际 0.001589
65
+ 2022-07-20 000300.XSHG 沪深300 ... 京东方A 0.007253
66
+ 2022-07-20 000300.XSHG 沪深300 ... 海尔智家 0.004762
67
+ 2022-07-20 000300.XSHG 沪深300 ... 澜起科技 0.001217
68
+
69
+ [300 rows x 5 columns]
70
+
71
+ """
72
+ return get_client().get_index_weights(index_id=index_id, date = date)
73
+
74
+
@@ -33,8 +33,8 @@ class LibFinanceClient(object):
33
33
 
34
34
  _threading_local = threading.local()
35
35
  _auth_params = {}
36
-
37
- _default_host = "127.0.0.1"
36
+ #_default_host = "0.0.0.0"
37
+ _default_host = "libfinance.tech"#"101.201.30.6"
38
38
  _default_port = 9090
39
39
 
40
40
  request_timeout = 300
@@ -111,6 +111,7 @@ class LibFinanceClient(object):
111
111
  #pdb.set_trace()
112
112
  #self.ensure_auth()
113
113
  response = self.client.query(request)
114
+ #print(response)
114
115
  #pdb.set_trace()
115
116
  if response.status is False:
116
117
  # error occur
@@ -41,7 +41,8 @@ def export_as_api(f=None, name=None, namespace=None, priority=0):
41
41
  else:
42
42
  namespace = libfinance
43
43
  libfinance.__all__.append(name)
44
-
44
+ #print(libfinance.__all__)
45
+
45
46
  old_f = getattr(namespace, name, None)
46
47
  if old_f is not None:
47
48
  if old_f.__priority > priority:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: libfinance
3
- Version: 0.0.1
3
+ Version: 0.0.2
4
4
  Summary: libfinance
5
5
  Home-page:
6
6
  Author:
@@ -13,4 +13,4 @@ Classifier: Programming Language :: Python :: 3.7
13
13
  Classifier: Programming Language :: Python :: 3.8
14
14
  Requires-Dist: dill>=0.3.8
15
15
  Requires-Dist: thriftpy2>=0.3.9
16
- Requires-Dist: pandas>=0.16.2
16
+ Requires-Dist: pandas==1.3.4
@@ -3,7 +3,6 @@ setup.py
3
3
  libfinance/__init__.py
4
4
  libfinance/client.py
5
5
  libfinance/libfinance.thrift
6
- libfinance/version.py
7
6
  libfinance.egg-info/PKG-INFO
8
7
  libfinance.egg-info/SOURCES.txt
9
8
  libfinance.egg-info/dependency_links.txt
@@ -12,6 +11,7 @@ libfinance.egg-info/requires.txt
12
11
  libfinance.egg-info/top_level.txt
13
12
  libfinance/api/__init__.py
14
13
  libfinance/api/calendar.py
14
+ libfinance/api/concept.py
15
15
  libfinance/api/get_price.py
16
16
  libfinance/api/index_components.py
17
17
  libfinance/utils/__init__.py
@@ -1,3 +1,3 @@
1
1
  dill>=0.3.8
2
2
  thriftpy2>=0.3.9
3
- pandas>=0.16.2
3
+ pandas==1.3.4
@@ -4,7 +4,7 @@ from os.path import dirname, join
4
4
 
5
5
  from setuptools import find_packages, setup
6
6
 
7
- from libfinance.version import __version__
7
+ __version__= "0.0.2"
8
8
 
9
9
  def read_file(file):
10
10
  with open(file, "rt") as f:
@@ -21,7 +21,7 @@ setup(
21
21
  license='Apache License v2',
22
22
  package_data={'': ['*.*']},
23
23
  url='',
24
- install_requires=["dill>=0.3.8", "thriftpy2>=0.3.9","pandas>=0.16.2"],
24
+ install_requires=["dill>=0.3.8", "thriftpy2>=0.3.9","pandas==1.3.4"],
25
25
  zip_safe=False,
26
26
  classifiers=[
27
27
  'Programming Language :: Python',
@@ -1,59 +0,0 @@
1
- # libfinance
2
-
3
- `libfinance` is python library for accessing financial data easily. The goal of `libfinance` is to provide HIGH quality financial data for scholars, researchers and developers in research and production environment.
4
-
5
-
6
- # install
7
-
8
- Install `libfinance` by `pip`
9
-
10
- ``` {.sourceCode .bash}
11
- $ pip install libfinance
12
- ```
13
-
14
- Install with a develop mode
15
- ~~~
16
- git clone https://github.com/StateOfTheArt-quant/libfinance.git
17
- cd libfinance
18
- python setup.py develop
19
- ~~~
20
-
21
- # quick-start
22
-
23
- ~~~
24
- from libfinance import get_trading_dates, history_bars
25
-
26
- trading_dates = get_trading_dates(start_date="2023-12-25", end_date="2024-01-11")
27
- print(trading_dates)
28
-
29
-
30
- DatetimeIndex(['2023-12-25', '2023-12-26', '2023-12-27', '2023-12-28',
31
- '2023-12-29', '2024-01-02', '2024-01-03', '2024-01-04',
32
- '2024-01-05', '2024-01-08', '2024-01-09', '2024-01-10',
33
- '2024-01-11'],
34
- dtype='datetime64[ns]', freq=None)
35
-
36
-
37
-
38
-
39
- trading_data = history_bars(order_book_ids=["000001.XSHE","600000.XSHG"], bar_count=6, frequency="1d", datetime="2024-01-11")
40
- print(trading_data)
41
-
42
-
43
- open close ... volume total_turnover
44
- order_book_id datetime ...
45
- 000001.XSHE 2024-01-04 9.19 9.11 ... 86419399.0 7.874701e+08
46
- 2024-01-05 9.10 9.27 ... 199162216.0 1.852660e+09
47
- 2024-01-08 9.23 9.15 ... 112115619.0 1.029007e+09
48
- 2024-01-09 9.16 9.18 ... 76619388.0 7.003757e+08
49
- 2024-01-10 9.16 9.09 ... 85862091.0 7.837712e+08
50
- 2024-01-11 9.08 9.17 ... 93468637.0 8.538902e+08
51
- 600000.XSHG 2024-01-04 6.64 6.62 ... 28885978.0 1.905806e+08
52
- 2024-01-05 6.60 6.68 ... 44421387.0 2.969769e+08
53
- 2024-01-08 6.68 6.59 ... 37520337.0 2.479778e+08
54
- 2024-01-09 6.60 6.61 ... 30741897.0 2.026476e+08
55
- 2024-01-10 6.61 6.57 ... 22240946.0 1.466959e+08
56
- 2024-01-11 6.56 6.53 ... 35914708.0 2.353121e+08
57
- ~~~
58
-
59
- # Documentation
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env python3
2
- # -*- coding: utf-8 -*-
3
-
4
- __all__ = []
5
-
6
- from .version import __version__
@@ -1,20 +0,0 @@
1
- #!/usr/bin/env python3
2
- # -*- coding: utf-8 -*-
3
-
4
- import datetime
5
- from typing import Any, Union, Optional, Iterable, Dict, List, Sequence, Iterable
6
-
7
- import pandas as pd
8
- from libfinance.client import get_client
9
- from libfinance.utils.decorators import export_as_api, ttl_cache, compatible_with_parm
10
-
11
- @export_as_api
12
- def get_instrument_industry(order_book_ids: list, date: Union[str, datetime.datetime], source: str = "010303") -> pd.DataFrame():
13
-
14
- return get_client().get_instrument_industry(order_book_ids=order_book_ids, date=date, source=source)
15
-
16
- @export_as_api
17
- def get_index_weights(index_id: str = "000300.XSHG", date: Union[str, datetime.datetime] = None) -> pd.DataFrame:
18
- return get_client().get_index_weights(index_id=index_id, date = date)
19
-
20
-
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env python3
2
- # -*- coding: utf-8 -*-
3
- __version__ = "0.0.1"
File without changes