tiantian-paris commited on
Commit
f91532f
·
verified ·
1 Parent(s): 5bd60f9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -7
app.py CHANGED
@@ -11,14 +11,27 @@ from Gradio_UI import GradioUI
11
 
12
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
13
  @tool
14
- def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
15
- #Keep this format for the description / args / args description but feel free to modify the tool
16
- """A tool that does nothing yet
17
- Args:
18
- arg1: the first argument
19
- arg2: the second argument
 
 
 
 
20
  """
21
- return "What magic will you build ?"
 
 
 
 
 
 
 
 
 
22
 
23
  @tool
24
  def get_current_time_in_timezone(timezone: str) -> str:
 
11
 
12
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
13
  @tool
14
+ def calculate_historical_var(returns, var_level=0.95):
15
+ """
16
+ Calculate the Value at Risk (VaR) using the historical method.
17
+
18
+ Parameters:
19
+ returns (np.array): Array of daily returns.
20
+ var_level (float): VaR level (e.g., 0.95 for 95%).
21
+
22
+ Returns:
23
+ float: VaR value.
24
  """
25
+ # Sort the returns in ascending order
26
+ sorted_returns = np.sort(returns)
27
+
28
+ # Determine the index for the VaR level
29
+ index = int((1 - var_level) * len(returns))
30
+
31
+ # Get the VaR value
32
+ var_value = sorted_returns[index]
33
+
34
+ return var_value
35
 
36
  @tool
37
  def get_current_time_in_timezone(timezone: str) -> str: