hawk-sdk 0.0.12__tar.gz → 0.0.14__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.12 → hawk_sdk-0.0.14}/PKG-INFO +1 -1
- {hawk_sdk-0.0.12 → hawk_sdk-0.0.14}/hawk_sdk/api/equities/repository.py +48 -35
- {hawk_sdk-0.0.12 → hawk_sdk-0.0.14}/hawk_sdk/core/common/utils.py +9 -7
- {hawk_sdk-0.0.12 → hawk_sdk-0.0.14}/hawk_sdk.egg-info/PKG-INFO +1 -1
- {hawk_sdk-0.0.12 → hawk_sdk-0.0.14}/setup.py +1 -1
- {hawk_sdk-0.0.12 → hawk_sdk-0.0.14}/README.md +0 -0
- {hawk_sdk-0.0.12 → hawk_sdk-0.0.14}/hawk_sdk/__init__.py +0 -0
- {hawk_sdk-0.0.12 → hawk_sdk-0.0.14}/hawk_sdk/api/__init__.py +0 -0
- {hawk_sdk-0.0.12 → hawk_sdk-0.0.14}/hawk_sdk/api/equities/__init__.py +0 -0
- {hawk_sdk-0.0.12 → hawk_sdk-0.0.14}/hawk_sdk/api/equities/main.py +0 -0
- {hawk_sdk-0.0.12 → hawk_sdk-0.0.14}/hawk_sdk/api/equities/service.py +0 -0
- {hawk_sdk-0.0.12 → hawk_sdk-0.0.14}/hawk_sdk/api/futures/__init__.py +0 -0
- {hawk_sdk-0.0.12 → hawk_sdk-0.0.14}/hawk_sdk/api/futures/main.py +0 -0
- {hawk_sdk-0.0.12 → hawk_sdk-0.0.14}/hawk_sdk/api/futures/repository.py +0 -0
- {hawk_sdk-0.0.12 → hawk_sdk-0.0.14}/hawk_sdk/api/futures/service.py +0 -0
- {hawk_sdk-0.0.12 → hawk_sdk-0.0.14}/hawk_sdk/api/system/__init__.py +0 -0
- {hawk_sdk-0.0.12 → hawk_sdk-0.0.14}/hawk_sdk/api/system/main.py +0 -0
- {hawk_sdk-0.0.12 → hawk_sdk-0.0.14}/hawk_sdk/api/system/repository.py +0 -0
- {hawk_sdk-0.0.12 → hawk_sdk-0.0.14}/hawk_sdk/api/system/service.py +0 -0
- {hawk_sdk-0.0.12 → hawk_sdk-0.0.14}/hawk_sdk/core/__init__.py +0 -0
- {hawk_sdk-0.0.12 → hawk_sdk-0.0.14}/hawk_sdk/core/common/__init__.py +0 -0
- {hawk_sdk-0.0.12 → hawk_sdk-0.0.14}/hawk_sdk/core/common/base_enum.py +0 -0
- {hawk_sdk-0.0.12 → hawk_sdk-0.0.14}/hawk_sdk/core/common/constants.py +0 -0
- {hawk_sdk-0.0.12 → hawk_sdk-0.0.14}/hawk_sdk/core/common/data_object.py +0 -0
- {hawk_sdk-0.0.12 → hawk_sdk-0.0.14}/hawk_sdk.egg-info/SOURCES.txt +0 -0
- {hawk_sdk-0.0.12 → hawk_sdk-0.0.14}/hawk_sdk.egg-info/dependency_links.txt +0 -0
- {hawk_sdk-0.0.12 → hawk_sdk-0.0.14}/hawk_sdk.egg-info/requires.txt +0 -0
- {hawk_sdk-0.0.12 → hawk_sdk-0.0.14}/hawk_sdk.egg-info/top_level.txt +0 -0
- {hawk_sdk-0.0.12 → hawk_sdk-0.0.14}/setup.cfg +0 -0
|
@@ -92,42 +92,55 @@ class EquitiesRepository:
|
|
|
92
92
|
def fetch_adjusted_ohlcv_snapshot(self, timestamp: str, hawk_ids: List[int]) -> Iterator[dict]:
|
|
93
93
|
"""Fetches the most recent snapshot data from BigQuery for the given time and hawk_ids."""
|
|
94
94
|
query = f"""
|
|
95
|
-
WITH
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
95
|
+
WITH latest_timestamp AS (
|
|
96
|
+
SELECT
|
|
97
|
+
MAX(r.record_timestamp) AS max_ts
|
|
98
|
+
FROM
|
|
99
|
+
`wsb-hc-qasap-ae2e.{self.environment}.records` AS r
|
|
100
|
+
WHERE
|
|
101
|
+
r.hawk_id IN UNNEST(@hawk_ids)
|
|
102
|
+
AND r.record_timestamp <= @timestamp
|
|
103
|
+
),
|
|
104
|
+
records_data AS (
|
|
105
|
+
SELECT
|
|
106
|
+
r.record_timestamp AS date,
|
|
107
|
+
hi.value AS ticker,
|
|
108
|
+
MAX(IF(f.field_name = 'adjusted_open_snapshot', r.double_value, NULL)) AS adjusted_open_snapshot,
|
|
109
|
+
MAX(IF(f.field_name = 'adjusted_high_snapshot', r.double_value, NULL)) AS adjusted_high_snapshot,
|
|
110
|
+
MAX(IF(f.field_name = 'adjusted_low_snapshot', r.double_value, NULL)) AS adjusted_low_snapshot,
|
|
111
|
+
MAX(IF(f.field_name = 'adjusted_close_snapshot', r.double_value, NULL)) AS adjusted_close_snapshot,
|
|
112
|
+
MAX(IF(f.field_name = 'volume_snapshot', r.int_value, NULL)) AS volume_snapshot
|
|
113
|
+
FROM
|
|
114
|
+
`wsb-hc-qasap-ae2e.{self.environment}.records` AS r
|
|
115
|
+
JOIN
|
|
116
|
+
`wsb-hc-qasap-ae2e.{self.environment}.fields` AS f
|
|
117
|
+
ON r.field_id = f.field_id
|
|
118
|
+
JOIN
|
|
119
|
+
`wsb-hc-qasap-ae2e.{self.environment}.hawk_identifiers` AS hi
|
|
120
|
+
ON r.hawk_id = hi.hawk_id
|
|
121
|
+
WHERE
|
|
122
|
+
r.hawk_id IN UNNEST(@hawk_ids)
|
|
123
|
+
AND f.field_name IN (
|
|
124
|
+
'adjusted_open_snapshot', 'adjusted_high_snapshot',
|
|
125
|
+
'adjusted_low_snapshot', 'adjusted_close_snapshot',
|
|
126
|
+
'volume_snapshot'
|
|
127
|
+
)
|
|
128
|
+
AND r.record_timestamp = (SELECT max_ts FROM latest_timestamp)
|
|
129
|
+
GROUP BY
|
|
130
|
+
date, ticker
|
|
118
131
|
)
|
|
119
|
-
SELECT
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
FROM
|
|
128
|
-
|
|
129
|
-
ORDER BY
|
|
130
|
-
|
|
132
|
+
SELECT
|
|
133
|
+
date,
|
|
134
|
+
ticker,
|
|
135
|
+
adjusted_open_snapshot,
|
|
136
|
+
adjusted_high_snapshot,
|
|
137
|
+
adjusted_low_snapshot,
|
|
138
|
+
adjusted_close_snapshot,
|
|
139
|
+
volume_snapshot
|
|
140
|
+
FROM
|
|
141
|
+
records_data
|
|
142
|
+
ORDER BY
|
|
143
|
+
ticker;
|
|
131
144
|
"""
|
|
132
145
|
|
|
133
146
|
query_params = [
|
|
@@ -8,14 +8,16 @@ from hawk_sdk.core.common.constants import PROJECT_ID
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
def get_bigquery_client() -> bigquery.Client:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
else:
|
|
16
|
-
# Load the service account credentials from the JSON string
|
|
17
|
-
service_account_json = os.environ.get('SERVICE_ACCOUNT_JSON')
|
|
11
|
+
service_account_json = os.environ.get('SERVICE_ACCOUNT_JSON')
|
|
12
|
+
if service_account_json:
|
|
13
|
+
# Use credentials provided in SERVICE_ACCOUNT_JSON
|
|
18
14
|
credentials = service_account.Credentials.from_service_account_info(
|
|
19
15
|
json.loads(service_account_json)
|
|
20
16
|
)
|
|
21
17
|
return bigquery.Client(project=PROJECT_ID, credentials=credentials)
|
|
18
|
+
else:
|
|
19
|
+
# Rely on Application Default Credentials (ADC),
|
|
20
|
+
# which will automatically use GOOGLE_APPLICATION_CREDENTIALS if set,
|
|
21
|
+
# or use the built-in credentials if running in GCP.
|
|
22
|
+
return bigquery.Client(project=PROJECT_ID)
|
|
23
|
+
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|