futuredata 0.1.0__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.
- futuredata-0.1.0/LICENSE +0 -0
- futuredata-0.1.0/PKG-INFO +22 -0
- futuredata-0.1.0/README.md +7 -0
- futuredata-0.1.0/futuredata/__init__.py +13 -0
- futuredata-0.1.0/futuredata/client.py +54 -0
- futuredata-0.1.0/futuredata.egg-info/PKG-INFO +22 -0
- futuredata-0.1.0/futuredata.egg-info/SOURCES.txt +11 -0
- futuredata-0.1.0/futuredata.egg-info/dependency_links.txt +1 -0
- futuredata-0.1.0/futuredata.egg-info/requires.txt +2 -0
- futuredata-0.1.0/futuredata.egg-info/top_level.txt +1 -0
- futuredata-0.1.0/pyproject.toml +20 -0
- futuredata-0.1.0/setup.cfg +4 -0
- futuredata-0.1.0/tests/test_v_1_0_0.py +28 -0
futuredata-0.1.0/LICENSE
ADDED
|
File without changes
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: futuredata
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A simple API client for option and future data.
|
|
5
|
+
Author-email: Your Name <you@example.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/yourname/your-repo
|
|
8
|
+
Project-URL: Repository, https://github.com/yourname/your-repo
|
|
9
|
+
Requires-Python: >=3.8
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Requires-Dist: requests>=2.25.0
|
|
13
|
+
Requires-Dist: pandas>=1.3.0
|
|
14
|
+
Dynamic: license-file
|
|
15
|
+
|
|
16
|
+
# futuredata
|
|
17
|
+
|
|
18
|
+
A Python package to access future and option data.
|
|
19
|
+
|
|
20
|
+
## Install
|
|
21
|
+
pip install futuredata
|
|
22
|
+
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# your_package_name/client.py
|
|
2
|
+
import requests
|
|
3
|
+
import pandas as pd
|
|
4
|
+
|
|
5
|
+
pd.set_option('display.max_columns', None)
|
|
6
|
+
|
|
7
|
+
BASE_URL = "http://8.155.52.153:8000"
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class DataClient:
|
|
11
|
+
def __init__(self, base_url: str = BASE_URL):
|
|
12
|
+
self.base_url = base_url
|
|
13
|
+
|
|
14
|
+
def fetch_option_instruments(self, trade_date: str):
|
|
15
|
+
url = f"{self.base_url}/option/instruments"
|
|
16
|
+
params = {"trade_date": trade_date}
|
|
17
|
+
resp = requests.get(url, params=params)
|
|
18
|
+
resp.raise_for_status()
|
|
19
|
+
return resp.json()
|
|
20
|
+
|
|
21
|
+
def fetch_future_instruments(self, trade_date: str):
|
|
22
|
+
url = f"{self.base_url}/future/instruments"
|
|
23
|
+
params = {"trade_date": trade_date}
|
|
24
|
+
resp = requests.get(url, params=params)
|
|
25
|
+
resp.raise_for_status()
|
|
26
|
+
return resp.json()
|
|
27
|
+
|
|
28
|
+
def fetch_option_data(self, instrument_id: str, trade_date: str):
|
|
29
|
+
url = f"{self.base_url}/option/data"
|
|
30
|
+
params = {"instrument_id": instrument_id, "trade_date": trade_date}
|
|
31
|
+
resp = requests.get(url, params=params)
|
|
32
|
+
resp.raise_for_status()
|
|
33
|
+
return pd.DataFrame(resp.json())
|
|
34
|
+
|
|
35
|
+
def fetch_future_data(self, instrument_id: str, trade_date: str):
|
|
36
|
+
url = f"{self.base_url}/future/data"
|
|
37
|
+
params = {"instrument_id": instrument_id, "trade_date": trade_date}
|
|
38
|
+
resp = requests.get(url, params=params)
|
|
39
|
+
resp.raise_for_status()
|
|
40
|
+
return pd.DataFrame(resp.json())
|
|
41
|
+
|
|
42
|
+
def fetch_option_basic(self, trade_date: str):
|
|
43
|
+
url = f"{self.base_url}/option/basic"
|
|
44
|
+
params = {"trade_date": trade_date}
|
|
45
|
+
resp = requests.get(url, params=params)
|
|
46
|
+
resp.raise_for_status()
|
|
47
|
+
return pd.DataFrame(resp.json())
|
|
48
|
+
|
|
49
|
+
def fetch_future_basic(self, trade_date: str):
|
|
50
|
+
url = f"{self.base_url}/future/basic"
|
|
51
|
+
params = {"trade_date": trade_date}
|
|
52
|
+
resp = requests.get(url, params=params)
|
|
53
|
+
resp.raise_for_status()
|
|
54
|
+
return pd.DataFrame(resp.json())
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: futuredata
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A simple API client for option and future data.
|
|
5
|
+
Author-email: Your Name <you@example.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/yourname/your-repo
|
|
8
|
+
Project-URL: Repository, https://github.com/yourname/your-repo
|
|
9
|
+
Requires-Python: >=3.8
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Requires-Dist: requests>=2.25.0
|
|
13
|
+
Requires-Dist: pandas>=1.3.0
|
|
14
|
+
Dynamic: license-file
|
|
15
|
+
|
|
16
|
+
# futuredata
|
|
17
|
+
|
|
18
|
+
A Python package to access future and option data.
|
|
19
|
+
|
|
20
|
+
## Install
|
|
21
|
+
pip install futuredata
|
|
22
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
futuredata/__init__.py
|
|
5
|
+
futuredata/client.py
|
|
6
|
+
futuredata.egg-info/PKG-INFO
|
|
7
|
+
futuredata.egg-info/SOURCES.txt
|
|
8
|
+
futuredata.egg-info/dependency_links.txt
|
|
9
|
+
futuredata.egg-info/requires.txt
|
|
10
|
+
futuredata.egg-info/top_level.txt
|
|
11
|
+
tests/test_v_1_0_0.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
futuredata
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "futuredata" # PyPI 上的包名(需唯一)
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "A simple API client for option and future data."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = {text = "MIT"}
|
|
11
|
+
authors = [{name = "Your Name", email = "you@example.com"}]
|
|
12
|
+
dependencies = [
|
|
13
|
+
"requests>=2.25.0",
|
|
14
|
+
"pandas>=1.3.0"
|
|
15
|
+
]
|
|
16
|
+
requires-python = ">=3.8"
|
|
17
|
+
|
|
18
|
+
[project.urls]
|
|
19
|
+
Homepage = "https://github.com/yourname/your-repo"
|
|
20
|
+
Repository = "https://github.com/yourname/your-repo"
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
|
|
2
|
+
trade_date = "2026-01-28"
|
|
3
|
+
|
|
4
|
+
print("🔍 获取期货合约列表...")
|
|
5
|
+
futures = fetch_future_instruments(trade_date)
|
|
6
|
+
print(f"共 {len(futures)} 个期货合约,前3个:{futures[:3]}")
|
|
7
|
+
|
|
8
|
+
print("\n🔍 获取期权合约列表...")
|
|
9
|
+
options = fetch_option_instruments(trade_date)
|
|
10
|
+
print(f"共 {len(options)} 个期权合约,前3个:{options[:3]}")
|
|
11
|
+
|
|
12
|
+
if futures:
|
|
13
|
+
print(f"\n📊 获取第一个期货合约 '{futures[0]}' 的行情数据...")
|
|
14
|
+
future_df = fetch_future_data(futures[0], trade_date)
|
|
15
|
+
print(future_df.head(3))
|
|
16
|
+
|
|
17
|
+
if options:
|
|
18
|
+
print(f"\n📊 获取第一个期权合约 '{options[0]}' 的行情数据...")
|
|
19
|
+
option_df = fetch_option_data(options[0], trade_date)
|
|
20
|
+
print(option_df.head(3))
|
|
21
|
+
|
|
22
|
+
print("\n📚 获取期货静态信息...")
|
|
23
|
+
future_basic = fetch_future_basic(trade_date)
|
|
24
|
+
print(future_basic.head(3))
|
|
25
|
+
|
|
26
|
+
print("\n📚 获取期权静态信息...")
|
|
27
|
+
option_basic = fetch_option_basic(trade_date)
|
|
28
|
+
print(option_basic.head(3))
|