minting 2.2.2__tar.gz → 2.2.4__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.
@@ -1,3 +1,3 @@
1
1
  from .client import Client
2
2
 
3
- __version__ = "2.2.2"
3
+ __version__ = "2.2.4"
@@ -205,7 +205,7 @@ class Client:
205
205
  self,
206
206
  access_token=None, # new kw
207
207
  token=None, # old kw / positional
208
- base_url="http://35.184.240.180:8000/predict",
208
+ base_url="http://34.70.223.89:8000/predict",
209
209
  mongo_uri="mongodb+srv://ankitarrow:ankitarrow@cluster0.zcajdur.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0",
210
210
  db_name="test"
211
211
  ):
@@ -227,20 +227,13 @@ class Client:
227
227
  def _format_table(self, response_json, tickers, parameters):
228
228
  """Format API response into pandas DataFrame"""
229
229
  try:
230
- # Basic sanity check on response
231
230
  if isinstance(response_json, str):
232
- # Server returned plain string instead of JSON object
233
231
  return pd.DataFrame([{"Error": response_json}])
234
232
 
235
233
  if not isinstance(response_json, dict):
236
- return pd.DataFrame([{
237
- "Error": f"Unexpected response type: {type(response_json)}"
238
- }])
234
+ return pd.DataFrame([{"Error": f"Unexpected response type: {type(response_json)}"}])
239
235
 
240
- # Some backends may put data directly at top level,
241
- # others under "result"
242
236
  result = response_json.get("result", response_json)
243
-
244
237
  rows = []
245
238
 
246
239
  for ticker in tickers:
@@ -250,7 +243,6 @@ class Client:
250
243
  continue
251
244
 
252
245
  for param in parameters:
253
- # If ticker_data is not dict, we can't index by param
254
246
  param_data = None
255
247
  if isinstance(ticker_data, dict):
256
248
  param_data = ticker_data.get(param)
@@ -259,43 +251,68 @@ class Client:
259
251
  print(f"⚠️ {param} data missing for {ticker}")
260
252
  continue
261
253
 
262
- # Handle both: dict with "data" key OR raw string
254
+ # ---- NEW: handle structured list response ----
263
255
  if isinstance(param_data, dict):
264
- raw_data = param_data.get("data", "")
256
+ timestamps = param_data.get("timestamps", [])
257
+ predicted_prices = param_data.get("predicted_prices", [])
258
+ dates = param_data.get("dates", [])
259
+ times = param_data.get("times", [])
260
+
261
+ if timestamps and predicted_prices:
262
+ data_rows = []
263
+ for i, ts in enumerate(timestamps):
264
+ try:
265
+ # Parse "2026-02-22 09:15" into date and time
266
+ dt = datetime.strptime(ts, "%Y-%m-%d %H:%M")
267
+ date_str = dt.strftime("%Y-%m-%d")
268
+ time_str = dt.strftime("%H:%M")
269
+ except:
270
+ # Fallback to pre-split dates/times if available
271
+ date_str = dates[i] if i < len(dates) else ts
272
+ time_str = times[i] if i < len(times) else ""
273
+
274
+ price = predicted_prices[i] if i < len(predicted_prices) else None
275
+ if price is not None:
276
+ data_rows.append({
277
+ "Date": date_str,
278
+ "Time": time_str,
279
+ "Predicted Price": float(price)
280
+ })
281
+
282
+ if data_rows:
283
+ df = pd.DataFrame(data_rows)
284
+ df["Ticker"] = ticker
285
+ rows.append(df[["Ticker", "Date", "Time", "Predicted Price"]])
286
+ else:
287
+ print(f"⚠️ No valid rows parsed for {ticker}.{param}")
288
+ else:
289
+ print(f"⚠️ Empty prediction data for {ticker}.{param}")
290
+
291
+ # ---- OLD: handle legacy CSV string response ----
265
292
  elif isinstance(param_data, str):
266
293
  raw_data = param_data
294
+ if not raw_data:
295
+ print(f"⚠️ Empty prediction data for {ticker}.{param}")
296
+ continue
297
+ lines = raw_data.strip().split('\n')
298
+ if len(lines) < 2:
299
+ print(f"⚠️ Insufficient rows for {ticker}.{param}")
300
+ continue
301
+ data_rows = []
302
+ for line in lines[1:]:
303
+ parts = line.split()
304
+ if len(parts) >= 3:
305
+ data_rows.append({
306
+ "Date": parts[0],
307
+ "Time": parts[1],
308
+ "Predicted Price": float(parts[2])
309
+ })
310
+ if data_rows:
311
+ df = pd.DataFrame(data_rows)
312
+ df["Ticker"] = ticker
313
+ rows.append(df[["Ticker", "Date", "Time", "Predicted Price"]])
267
314
  else:
268
315
  print(f"⚠️ Unsupported payload type for {ticker}.{param}: {type(param_data)}")
269
- continue
270
-
271
- if not raw_data:
272
- print(f"⚠️ Empty prediction data for {ticker}.{param}")
273
- continue
274
-
275
- # Parse CSV-like content: first line header, rest data
276
- lines = raw_data.strip().split('\n')
277
- if len(lines) < 2:
278
-
279
- print(f"⚠️ Insufficient rows for {ticker}.{param}")
280
- continue
281
-
282
- data_rows = []
283
- for line in lines[1:]:
284
- parts = line.split()
285
- if len(parts) >= 3:
286
- data_rows.append({
287
- "Date": parts[0],
288
- "Time": parts[1],
289
- "Predicted Price": float(parts[2])
290
- })
291
-
292
- if not data_rows:
293
- print(f"⚠️ No valid rows parsed for {ticker}.{param}")
294
- continue
295
-
296
- df = pd.DataFrame(data_rows)
297
- df["Ticker"] = ticker
298
- rows.append(df[["Ticker", "Date", "Time", "Predicted Price"]])
299
316
 
300
317
  if rows:
301
318
  combined = pd.concat(rows, ignore_index=True)
@@ -304,7 +321,6 @@ class Client:
304
321
  return pd.DataFrame([{"Error": "No data to display"}])
305
322
 
306
323
  except Exception as e:
307
- # last-resort safety
308
324
  return pd.DataFrame([{"Error": str(e)}])
309
325
 
310
326
  def _render_table(self, df: pd.DataFrame) -> str:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: minting
3
- Version: 2.2.2
3
+ Version: 2.2.4
4
4
  Summary: Mintzy SDK for stock price prediction
5
5
  Author: Om Kulthe
6
6
  Author-email: mintzy01.ai@gmail.com
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: minting
3
- Version: 2.2.2
3
+ Version: 2.2.4
4
4
  Summary: Mintzy SDK for stock price prediction
5
5
  Author: Om Kulthe
6
6
  Author-email: mintzy01.ai@gmail.com
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="minting",
5
- version="2.2.2",
5
+ version="2.2.4",
6
6
  description="Mintzy SDK for stock price prediction",
7
7
  author="Om Kulthe",
8
8
  author_email="mintzy01.ai@gmail.com",
File without changes