General purpose Python wrapper utilities
Project description
grass-wrapper
grass-wrapper は Python 3.10+ で動作する汎用ユーティリティ集です。
時系列 API からのデータ取得/加工、ローカル(DuckDB) および Google BigQuery への高速ロードをシンプルな API で提供します。
Features
| Module | What you get |
|---|---|
grass_wrapper.CoinGlass |
REST クライアント生成とエンドポイントラッパー 例: get_fr_ohlc_history() で funding-rate OHLC を取得 |
grass_wrapper.Bybit |
Bybit V5 API クライアント • get_tickers() — 最新ティッカー取得• get_kline() — 任意足のローソク足取得• get_positions() / get_orders() — ポジション・注文情報取得 |
grass_wrapper.BigQuery |
軽量ラッパークラス BigQuery• upload_rows() — list[dict] をロード• upload_rows_if_absent() — 一意キー重複チェック付きロード(初回に PARTITION BY / CLUSTER BY を自動設定) |
grass_wrapper.DuckDB |
ローカル高速ストレージ DuckDBClient• .insert_dataframe() — pandas.DataFrame を保存• .query() — SQLで即時クエリ(バックテスト・長期保存に最適) |
Installation
pip install grass-wrapper
開発者向け:
git clone https://github.com/grass-labs/grass-wrapper.git
cd grass-wrapper
pip install -e .[dev] # includes pytest, ruff, black
Quick Start
from grass_wrapper.CoinGlass.client import CoinGlass
from grass_wrapper.BigQuery.client import BigQuery
from grass_wrapper.Bybit.client import Bybit
from grass_wrapper.DuckDB.client import DuckDBClient
# API クライアント
cg = CoinGlass() # CG_API_KEY は環境変数から読む
byb = Bybit(api_key="...", api_secret="...") # Bybit V5 REST
# ストレージ
bq = BigQuery(project_id="my-gcp-project") # 認証は ADC 前提
duck = DuckDBClient("data/grass.duckdb") # ローカル DuckDB ファイルに保存
# 例: Bybit ティッカーを取得して DuckDB に保存
tickers = byb.get_tickers(category="linear")
import pandas as pd
df = pd.DataFrame(tickers)
duck.insert_dataframe("bybit_tickers", df)
# 例: DuckDB からクエリ
res = duck.query("SELECT * FROM bybit_tickers ORDER BY updatedTime DESC LIMIT 5")
print(res)
Requirements
- Python ≥ 3.10
requests≥ 2.32google-cloud-bigquery≥ 3.35duckdb≥ 1.4.0- CoinGlass API key (
CG_API_KEY) - Bybit API key/secret(V5)
BigQuery は ADC(Application Default Credentials)または Service Account JSON に対応。
Contributing
- Fork & clone this repo
pip install -e .[dev]ruff check . && pytest -q- Make a PR against
main
We ♥ contributions — issues, docs, tests, new features!
License
This project is licensed under the MIT License – see the LICENSE file for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file grass_wrapper-0.4.0.tar.gz.
File metadata
- Download URL: grass_wrapper-0.4.0.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e34151334960c3de739c94b8516c0789aae672f0640c92e634f4d1e5b40e56b3
|
|
| MD5 |
d199c4ea1535a0d272c39f4b759a1edf
|
|
| BLAKE2b-256 |
35ef9eb1e8b323f02a89f8c073a349a78da22cd15a51c321ad11c98e91ae92cb
|
File details
Details for the file grass_wrapper-0.4.0-py3-none-any.whl.
File metadata
- Download URL: grass_wrapper-0.4.0-py3-none-any.whl
- Upload date:
- Size: 13.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab2aee17f12d6055313e54d4a26db0caf4225b2342e3d3f991ab20979d3986dc
|
|
| MD5 |
dbddf53be0f120f728cfad7cef3a43ee
|
|
| BLAKE2b-256 |
92bf429d1ca72d0a0daca0bcc11d8134b4d97ad6f475d2bffaa38c2fb629e0a3
|