camphong24032002 commited on
Commit
9da4532
·
1 Parent(s): 06613fc

Debug on huggingface

Browse files
Files changed (2) hide show
  1. routes/data.py +3 -3
  2. services/indicator.py +4 -1
routes/data.py CHANGED
@@ -19,7 +19,7 @@ async def get_price_data(payload: PricePayload) -> Sequence[dict]:
19
  payload.count_back,
20
  payload.symbol_type)
21
  if price_df is None:
22
- return {"message": "Error"}
23
  return json.loads(price_df.to_json(orient="records"))
24
 
25
 
@@ -36,7 +36,7 @@ async def get_rsi_data(payload: RSIPayload) -> Sequence[dict]:
36
  payload.smooth_d
37
  )
38
  if rsi_df is None:
39
- return {"message": "Error"}
40
  return json.loads(rsi_df.to_json(orient="records"))
41
 
42
 
@@ -55,5 +55,5 @@ async def get_ichimoku_data(payload: IchimokuPayload) -> Sequence[dict]:
55
  payload.span_b_period,
56
  payload.displacement)
57
  if ichimoku_df is None:
58
- return {"message": "Error"}
59
  return json.loads(ichimoku_df.to_json(orient="records"))
 
19
  payload.count_back,
20
  payload.symbol_type)
21
  if price_df is None:
22
+ return [{"message": "Error"}]
23
  return json.loads(price_df.to_json(orient="records"))
24
 
25
 
 
36
  payload.smooth_d
37
  )
38
  if rsi_df is None:
39
+ return [{"message": "Error"}]
40
  return json.loads(rsi_df.to_json(orient="records"))
41
 
42
 
 
55
  payload.span_b_period,
56
  payload.displacement)
57
  if ichimoku_df is None:
58
+ return [{"message": "Error"}]
59
  return json.loads(ichimoku_df.to_json(orient="records"))
services/indicator.py CHANGED
@@ -6,6 +6,8 @@ from vnstock import longterm_ohlc_data, stock_historical_data, price_board
6
  from pymongo import MongoClient, ASCENDING, DESCENDING
7
  from utils.config import DATE_FORMAT
8
  import os
 
 
9
 
10
  PREFIX = "https://www.hsx.vn/Modules/Chart/StaticChart/"
11
  TIME = {"1m": 2, "3m": 3, "6m": 4, "1y": 5, "2y": 6, "5y": 7}
@@ -52,10 +54,10 @@ class Indicator:
52
  try:
53
  symbol = symbol.upper()
54
  uri = os.environ.get("MONGODB_URI")
55
- print(uri)
56
  client = MongoClient(uri)
57
  database = client.get_database("data")
58
  collection = database.get_collection("rsi")
 
59
  datetime_now = datetime.utcnow()
60
  hour = datetime_now.hour
61
  weekday = datetime_now.weekday()
@@ -87,6 +89,7 @@ class Indicator:
87
  print("Updated data")
88
  except Exception:
89
  error = True
 
90
  records = list(collection.find())
91
  record_df = pd.DataFrame(records).drop(columns=["_id"])
92
  record_df = \
 
6
  from pymongo import MongoClient, ASCENDING, DESCENDING
7
  from utils.config import DATE_FORMAT
8
  import os
9
+ from dotenv import load_dotenv
10
+ load_dotenv()
11
 
12
  PREFIX = "https://www.hsx.vn/Modules/Chart/StaticChart/"
13
  TIME = {"1m": 2, "3m": 3, "6m": 4, "1y": 5, "2y": 6, "5y": 7}
 
54
  try:
55
  symbol = symbol.upper()
56
  uri = os.environ.get("MONGODB_URI")
 
57
  client = MongoClient(uri)
58
  database = client.get_database("data")
59
  collection = database.get_collection("rsi")
60
+ print(collection)
61
  datetime_now = datetime.utcnow()
62
  hour = datetime_now.hour
63
  weekday = datetime_now.weekday()
 
89
  print("Updated data")
90
  except Exception:
91
  error = True
92
+ print("load records")
93
  records = list(collection.find())
94
  record_df = pd.DataFrame(records).drop(columns=["_id"])
95
  record_df = \