qywok commited on
Commit
0e963ff
·
verified ·
1 Parent(s): 4c54f77

Update restful/onnx_utilities.py

Browse files
Files changed (1) hide show
  1. restful/onnx_utilities.py +3 -3
restful/onnx_utilities.py CHANGED
@@ -17,7 +17,7 @@ class Utilities:
17
  # return float(Decimal(str(val)).quantize(Decimal('0.01'), rounding=ROUND_DOWN))
18
  def truncate_2_decimal(self, val: float):
19
  try:
20
- return float(Decimal(str(float(val))).quantize(Decimal('0.0001'), rounding=ROUND_DOWN))
21
  except Exception as e:
22
  print("Decimal error:", e)
23
  return float(val)
@@ -68,7 +68,7 @@ class Utilities:
68
  # last_date += pd.Timedelta(days=1)
69
  last_date = pd.to_datetime(last_date) + pd.Timedelta(days=1)
70
  # predicted_prices[last_date.strftime('%Y-%m-%d')] = float(denorm_price)
71
- predicted_prices[last_date] = float(denorm_price)
72
 
73
  lst_seq = np.roll(lst_seq, shift=-1, axis=1)
74
  lst_seq[:, -1, -1] = value
@@ -87,7 +87,7 @@ class Utilities:
87
  close_denorm = self.denormalization(close_values, min_close, max_close)
88
 
89
  actuals = [
90
- {'date': to_datetime(date).strftime('%Y-%m-%d'), 'price': float(price)}
91
  for date, price in zip(df_date, close_denorm)
92
  ]
93
 
 
17
  # return float(Decimal(str(val)).quantize(Decimal('0.01'), rounding=ROUND_DOWN))
18
  def truncate_2_decimal(self, val: float):
19
  try:
20
+ return float(Decimal(str(float(val))).quantize(Decimal('0.001'), rounding=ROUND_DOWN))
21
  except Exception as e:
22
  print("Decimal error:", e)
23
  return float(val)
 
68
  # last_date += pd.Timedelta(days=1)
69
  last_date = pd.to_datetime(last_date) + pd.Timedelta(days=1)
70
  # predicted_prices[last_date.strftime('%Y-%m-%d')] = float(denorm_price)
71
+ predicted_prices[last_date] = self.truncate_2_decimal(denorm_price)
72
 
73
  lst_seq = np.roll(lst_seq, shift=-1, axis=1)
74
  lst_seq[:, -1, -1] = value
 
87
  close_denorm = self.denormalization(close_values, min_close, max_close)
88
 
89
  actuals = [
90
+ {'date': to_datetime(date).strftime('%Y-%m-%d'), 'price': self.truncate_2_decimal(price)}
91
  for date, price in zip(df_date, close_denorm)
92
  ]
93