hawk-sdk 0.0.4__tar.gz → 0.0.6__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 hawk-sdk might be problematic. Click here for more details.
- {hawk_sdk-0.0.4 → hawk_sdk-0.0.6}/PKG-INFO +1 -1
- {hawk_sdk-0.0.4 → hawk_sdk-0.0.6}/README.md +1 -1
- hawk_sdk-0.0.6/hawk_sdk/api/futures/__init__.py +1 -0
- {hawk_sdk-0.0.4 → hawk_sdk-0.0.6}/hawk_sdk/api/futures/main.py +13 -1
- {hawk_sdk-0.0.4 → hawk_sdk-0.0.6}/hawk_sdk/api/futures/repository.py +58 -2
- {hawk_sdk-0.0.4 → hawk_sdk-0.0.6}/hawk_sdk/api/futures/service.py +10 -0
- hawk_sdk-0.0.6/hawk_sdk/api/system/__init__.py +1 -0
- {hawk_sdk-0.0.4 → hawk_sdk-0.0.6}/hawk_sdk.egg-info/PKG-INFO +1 -1
- {hawk_sdk-0.0.4 → hawk_sdk-0.0.6}/setup.py +1 -1
- hawk_sdk-0.0.4/hawk_sdk/__init__.py +0 -1
- hawk_sdk-0.0.4/hawk_sdk/core/common/__init__.py +0 -0
- {hawk_sdk-0.0.4/hawk_sdk/api/futures → hawk_sdk-0.0.6/hawk_sdk}/__init__.py +0 -0
- {hawk_sdk-0.0.4 → hawk_sdk-0.0.6}/hawk_sdk/api/__init__.py +0 -0
- {hawk_sdk-0.0.4 → hawk_sdk-0.0.6}/hawk_sdk/api/system/main.py +0 -0
- {hawk_sdk-0.0.4 → hawk_sdk-0.0.6}/hawk_sdk/api/system/repository.py +0 -0
- {hawk_sdk-0.0.4 → hawk_sdk-0.0.6}/hawk_sdk/api/system/service.py +0 -0
- {hawk_sdk-0.0.4/hawk_sdk/api/system → hawk_sdk-0.0.6/hawk_sdk/core}/__init__.py +0 -0
- {hawk_sdk-0.0.4/hawk_sdk/core → hawk_sdk-0.0.6/hawk_sdk/core/common}/__init__.py +0 -0
- {hawk_sdk-0.0.4 → hawk_sdk-0.0.6}/hawk_sdk/core/common/base_enum.py +0 -0
- {hawk_sdk-0.0.4 → hawk_sdk-0.0.6}/hawk_sdk/core/common/constants.py +0 -0
- {hawk_sdk-0.0.4 → hawk_sdk-0.0.6}/hawk_sdk/core/common/data_object.py +0 -0
- {hawk_sdk-0.0.4 → hawk_sdk-0.0.6}/hawk_sdk.egg-info/SOURCES.txt +0 -0
- {hawk_sdk-0.0.4 → hawk_sdk-0.0.6}/hawk_sdk.egg-info/dependency_links.txt +0 -0
- {hawk_sdk-0.0.4 → hawk_sdk-0.0.6}/hawk_sdk.egg-info/requires.txt +0 -0
- {hawk_sdk-0.0.4 → hawk_sdk-0.0.6}/hawk_sdk.egg-info/top_level.txt +0 -0
- {hawk_sdk-0.0.4 → hawk_sdk-0.0.6}/setup.cfg +0 -0
|
@@ -53,7 +53,7 @@ pip install dist/your_package_name-X.Y.Z-py3-none-any.whl
|
|
|
53
53
|
```
|
|
54
54
|
|
|
55
55
|
### 6. Upload to PyPI
|
|
56
|
-
Once you’re satisfied with the package, upload it to PyPI:
|
|
56
|
+
Once you’re satisfied with the package, upload it to PyPI. Contact Rithwik for the pypi API key:
|
|
57
57
|
|
|
58
58
|
```bash
|
|
59
59
|
twine upload dist/*
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from hawk_sdk.api.futures.main import Futures
|
|
@@ -24,7 +24,7 @@ class Futures:
|
|
|
24
24
|
def get_ohlcvo(self, start_date: str, end_date: str, interval: str, hawk_ids: List[int]) -> DataObject:
|
|
25
25
|
"""Fetch open, high, low, close, volume, and open interest data for the given date range and hawk_ids.
|
|
26
26
|
|
|
27
|
-
:param start_date:
|
|
27
|
+
:param start_date: %The start date for the data query (YYYY-MM-DD).
|
|
28
28
|
:param end_date: The end date for the data query (YYYY-MM-DD).
|
|
29
29
|
:param interval: The interval for the data query (e.g., '1d', '1h', '1m').
|
|
30
30
|
:param hawk_ids: A list of specific hawk_ids to filter by.
|
|
@@ -34,3 +34,15 @@ class Futures:
|
|
|
34
34
|
name="futures_ohlcvo",
|
|
35
35
|
data=self.service.get_ohlcvo(start_date, end_date, interval, hawk_ids)
|
|
36
36
|
)
|
|
37
|
+
|
|
38
|
+
def get_snapshot(self, timestamp: str, hawk_ids: List[int]) -> DataObject:
|
|
39
|
+
"""Fetch snapshot data for the specified timestamp and hawk_ids.
|
|
40
|
+
|
|
41
|
+
:param timestamp: The timestamp for the data query (YYYY-MM-DD HH:MM:SS).
|
|
42
|
+
:param hawk_ids: A list of specific hawk_ids to filter by.
|
|
43
|
+
:return: A hawk DataObject containing the snapshot data.
|
|
44
|
+
"""
|
|
45
|
+
return DataObject(
|
|
46
|
+
name="futures_snapshot",
|
|
47
|
+
data=self.service.get_snapshot(timestamp, hawk_ids)
|
|
48
|
+
)
|
|
@@ -22,8 +22,7 @@ class FuturesRepository:
|
|
|
22
22
|
self.environment = environment
|
|
23
23
|
|
|
24
24
|
def fetch_ohlcvo(self, start_date: str, end_date: str, interval: str, hawk_ids: List[int]) -> Iterator[dict]:
|
|
25
|
-
"""Fetches raw data from BigQuery for the given date range and hawk_ids using query parameters."""
|
|
26
|
-
|
|
25
|
+
"""Fetches raw OHLCVO data from BigQuery for the given date range and hawk_ids using query parameters."""
|
|
27
26
|
query = f"""
|
|
28
27
|
WITH records_data AS (
|
|
29
28
|
SELECT
|
|
@@ -85,3 +84,60 @@ class FuturesRepository:
|
|
|
85
84
|
except Exception as e:
|
|
86
85
|
logging.error(f"Failed to fetch OHLCVO data: {e}")
|
|
87
86
|
raise
|
|
87
|
+
|
|
88
|
+
def fetch_snapshot(self, timestamp: str, hawk_ids: List[int]) -> Iterator[dict]:
|
|
89
|
+
"""Fetches the most recent snapshot data from BigQuery for the given time and hawk_ids."""
|
|
90
|
+
query = f"""
|
|
91
|
+
WITH records_data AS (
|
|
92
|
+
SELECT
|
|
93
|
+
r.record_timestamp AS date,
|
|
94
|
+
hi.value AS ticker,
|
|
95
|
+
MAX(CASE WHEN f.field_name = 'close_snapshot' THEN r.double_value END) AS close_snapshot,
|
|
96
|
+
MAX(CASE WHEN f.field_name = 'high_snapshot' THEN r.double_value END) AS high_snapshot,
|
|
97
|
+
MAX(CASE WHEN f.field_name = 'low_snapshot' THEN r.double_value END) AS low_snapshot,
|
|
98
|
+
MAX(CASE WHEN f.field_name = 'cvol_snapshot' THEN r.int_value END) AS cvol_snapshot,
|
|
99
|
+
MAX(CASE WHEN f.field_name = 'bid_snapshot' THEN r.double_value END) AS bid_snapshot,
|
|
100
|
+
MAX(CASE WHEN f.field_name = 'ask_snapshot' THEN r.double_value END) AS ask_snapshot
|
|
101
|
+
FROM
|
|
102
|
+
`wsb-hc-qasap-ae2e.{self.environment}.records` AS r
|
|
103
|
+
JOIN
|
|
104
|
+
`wsb-hc-qasap-ae2e.{self.environment}.fields` AS f
|
|
105
|
+
ON r.field_id = f.field_id
|
|
106
|
+
JOIN
|
|
107
|
+
`wsb-hc-qasap-ae2e.{self.environment}.hawk_identifiers` AS hi
|
|
108
|
+
ON r.hawk_id = hi.hawk_id
|
|
109
|
+
WHERE
|
|
110
|
+
r.hawk_id IN UNNEST(@hawk_ids)
|
|
111
|
+
AND f.field_name IN ('close_snapshot', 'high_snapshot', 'low_snapshot', 'cvol_snapshot', 'bid_snapshot', 'ask_snapshot')
|
|
112
|
+
AND r.record_timestamp <= @timestamp
|
|
113
|
+
GROUP BY
|
|
114
|
+
date, ticker
|
|
115
|
+
)
|
|
116
|
+
SELECT DISTINCT
|
|
117
|
+
date,
|
|
118
|
+
ticker,
|
|
119
|
+
close_snapshot,
|
|
120
|
+
high_snapshot,
|
|
121
|
+
low_snapshot,
|
|
122
|
+
cvol_snapshot,
|
|
123
|
+
bid_snapshot,
|
|
124
|
+
ask_snapshot
|
|
125
|
+
FROM
|
|
126
|
+
records_data
|
|
127
|
+
ORDER BY
|
|
128
|
+
date;
|
|
129
|
+
"""
|
|
130
|
+
|
|
131
|
+
query_params = [
|
|
132
|
+
bigquery.ArrayQueryParameter("hawk_ids", "INT64", hawk_ids),
|
|
133
|
+
bigquery.ScalarQueryParameter("timestamp", "DATETIME", timestamp)
|
|
134
|
+
]
|
|
135
|
+
|
|
136
|
+
job_config = bigquery.QueryJobConfig(query_parameters=query_params)
|
|
137
|
+
|
|
138
|
+
try:
|
|
139
|
+
query_job = self.bq_client.query(query, job_config=job_config)
|
|
140
|
+
return query_job.result()
|
|
141
|
+
except Exception as e:
|
|
142
|
+
logging.error(f"Failed to fetch snapshot data: {e}")
|
|
143
|
+
raise
|
|
@@ -31,6 +31,16 @@ class FuturesService:
|
|
|
31
31
|
raw_data = self.repository.fetch_ohlcvo(start_date, end_date, interval, hawk_ids)
|
|
32
32
|
return self._normalize_data(raw_data)
|
|
33
33
|
|
|
34
|
+
def get_snapshot(self, timestamp: str, hawk_ids: List[int]) -> pd.DataFrame:
|
|
35
|
+
"""Fetches snapshot data and normalizes it into a pandas DataFrame.
|
|
36
|
+
|
|
37
|
+
:param timestamp: The timestamp for the data query (YYYY-MM-DD HH:MM:SS).
|
|
38
|
+
:param hawk_ids: A list of specific hawk_ids to filter by.
|
|
39
|
+
:return: A pandas DataFrame containing the normalized snapshot data.
|
|
40
|
+
"""
|
|
41
|
+
raw_data = self.repository.fetch_snapshot(timestamp, hawk_ids)
|
|
42
|
+
return self._normalize_data(raw_data)
|
|
43
|
+
|
|
34
44
|
@staticmethod
|
|
35
45
|
def _normalize_data(data: Iterator[dict]) -> pd.DataFrame:
|
|
36
46
|
"""Converts raw data into a normalized pandas DataFrame.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from hawk_sdk.api.system.main import System
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
from hawk_sdk.api.futures import Futures
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|