minting 2.2.0__tar.gz → 2.2.2__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.0"
3
+ __version__ = "2.2.2"
@@ -9,6 +9,11 @@ import sys
9
9
  import hashlib
10
10
  from datetime import datetime
11
11
  from pymongo import MongoClient
12
+ from colorama import Fore, init as colorama_init
13
+
14
+ # # ----------------- Database Layer -----------------
15
+ # Initialize ANSI support for Windows terminals
16
+ colorama_init(autoreset=True)
12
17
 
13
18
 
14
19
  # ----------------- Database Layer -----------------
@@ -228,7 +233,7 @@ class Client:
228
233
  return pd.DataFrame([{"Error": response_json}])
229
234
 
230
235
  if not isinstance(response_json, dict):
231
- return pd.DataFrame([{
236
+ return pd.DataFrame([{
232
237
  "Error": f"Unexpected response type: {type(response_json)}"
233
238
  }])
234
239
 
@@ -241,11 +246,7 @@ class Client:
241
246
  for ticker in tickers:
242
247
  ticker_data = result.get(ticker) if isinstance(result, dict) else None
243
248
  if ticker_data is None:
244
- rows.append(pd.DataFrame([{
245
- "Ticker": ticker,
246
- "Parameter": None,
247
- "Error": "No data for ticker"
248
- }]))
249
+ print(f"⚠️ No data returned for {ticker}")
249
250
  continue
250
251
 
251
252
  for param in parameters:
@@ -255,11 +256,7 @@ class Client:
255
256
  param_data = ticker_data.get(param)
256
257
 
257
258
  if param_data is None:
258
- rows.append(pd.DataFrame([{
259
- "Ticker": ticker,
260
- "Parameter": param,
261
- "Error": "No prediction data available"
262
- }]))
259
+ print(f"⚠️ {param} data missing for {ticker}")
263
260
  continue
264
261
 
265
262
  # Handle both: dict with "data" key OR raw string
@@ -268,29 +265,18 @@ class Client:
268
265
  elif isinstance(param_data, str):
269
266
  raw_data = param_data
270
267
  else:
271
- rows.append(pd.DataFrame([{
272
- "Ticker": ticker,
273
- "Parameter": param,
274
- "Error": f"Unsupported data type: {type(param_data)}"
275
- }]))
268
+ print(f"⚠️ Unsupported payload type for {ticker}.{param}: {type(param_data)}")
276
269
  continue
277
270
 
278
271
  if not raw_data:
279
- rows.append(pd.DataFrame([{
280
- "Ticker": ticker,
281
- "Parameter": param,
282
- "Error": "Empty prediction data"
283
- }]))
272
+ print(f"⚠️ Empty prediction data for {ticker}.{param}")
284
273
  continue
285
274
 
286
275
  # Parse CSV-like content: first line header, rest data
287
276
  lines = raw_data.strip().split('\n')
288
277
  if len(lines) < 2:
289
- rows.append(pd.DataFrame([{
290
- "Ticker": ticker,
291
- "Parameter": param,
292
- "Error": "Insufficient data"
293
- }]))
278
+
279
+ print(f"⚠️ Insufficient rows for {ticker}.{param}")
294
280
  continue
295
281
 
296
282
  data_rows = []
@@ -304,11 +290,7 @@ class Client:
304
290
  })
305
291
 
306
292
  if not data_rows:
307
- rows.append(pd.DataFrame([{
308
- "Ticker": ticker,
309
- "Parameter": param,
310
- "Error": "No valid data rows"
311
- }]))
293
+ print(f"⚠️ No valid rows parsed for {ticker}.{param}")
312
294
  continue
313
295
 
314
296
  df = pd.DataFrame(data_rows)
@@ -316,7 +298,8 @@ class Client:
316
298
  rows.append(df[["Ticker", "Date", "Time", "Predicted Price"]])
317
299
 
318
300
  if rows:
319
- return pd.concat(rows, ignore_index=True)
301
+ combined = pd.concat(rows, ignore_index=True)
302
+ return combined[["Ticker", "Date", "Time", "Predicted Price"]]
320
303
  else:
321
304
  return pd.DataFrame([{"Error": "No data to display"}])
322
305
 
@@ -324,6 +307,37 @@ class Client:
324
307
  # last-resort safety
325
308
  return pd.DataFrame([{"Error": str(e)}])
326
309
 
310
+ def _render_table(self, df: pd.DataFrame) -> str:
311
+ """Return a formatted string for the console with a colored header."""
312
+ if df.empty:
313
+ return " No prediction data available."
314
+
315
+ headers = ["Ticker", "Date", "Time", "Predicted Price"]
316
+ values = df[headers].astype(str).values.tolist()
317
+
318
+ col_widths = [max(len(str(item)) for item in col) for col in zip(*([headers] + values))]
319
+
320
+ spacing = " "
321
+ def format_row(row):
322
+ cells = [f"{str(val):<{width}}" for val, width in zip(row, col_widths)]
323
+ return spacing.join(cells)
324
+
325
+ total_width = sum(col_widths) + len(spacing) * (len(headers) - 1)
326
+ divider = "=" * total_width
327
+
328
+ rows_lines = []
329
+ for idx, row in enumerate(values):
330
+ row_line = format_row(row)
331
+ rows_lines.append(row_line)
332
+ next_ticker = values[idx + 1][0] if idx + 1 < len(values) else None
333
+ if next_ticker != row[0]:
334
+ rows_lines.append("-" * total_width)
335
+
336
+ lines = [divider, Fore.CYAN + format_row(headers) + Fore.RESET, divider]
337
+ lines.extend(rows_lines)
338
+ lines.append(divider)
339
+ return "\n".join(lines)
340
+
327
341
 
328
342
  def get_prediction(self, tickers, time_frame, parameters, candle="1m"):
329
343
  # Normalize tickers
@@ -396,7 +410,7 @@ class Client:
396
410
  print("\n" + "="*60)
397
411
  print(f"✅ Predictions ({time_frame}, candle={candle})")
398
412
  print("="*60)
399
- print(df.to_string(index=False))
413
+ print(self._render_table(df))
400
414
  print("="*60)
401
415
  print(f"💳 Remaining credits: {remaining}")
402
416
 
@@ -436,18 +450,4 @@ class Client:
436
450
  return credits
437
451
 
438
452
 
439
- # -------------- local test --------------
440
- # if __name__ == "__main__":
441
- # client = Client(
442
- # access_token="sk_live_2df1613eca06f07cf0208f8ea30e0ce0f5a50c4a90b0f073321bce1c332e9da2"
443
- # )
444
-
445
- # result = client.get_prediction(
446
- # tickers=["HDFCBANK"],
447
- # time_frame="5 minutes",
448
- # parameters=["close"],
449
- # candle="1m"
450
- # )
451
-
452
- # print("\nRAW RESULT DICT:")
453
- # print(result)
453
+ # -------------- local test --------------
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: minting
3
- Version: 2.2.0
3
+ Version: 2.2.2
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.0
3
+ Version: 2.2.2
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.0",
5
+ version="2.2.2",
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