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