nikcane commited on
Commit
2e19029
·
verified ·
1 Parent(s): 0547e8d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -6
app.py CHANGED
@@ -4,19 +4,45 @@ import requests
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
 
 
7
 
8
  from Gradio_UI import GradioUI
9
 
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
  @tool
12
- def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
13
- #Keep this format for the description / args / args description but feel free to modify the tool
14
- """A tool that does nothing yet
 
 
 
15
  Args:
16
- arg1: the first argument
17
- arg2: the second argument
 
18
  """
19
- return "What magic will you build ?"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  @tool
22
  def get_current_time_in_timezone(timezone: str) -> str:
 
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
7
+ import os
8
+ import pandas as pd
9
 
10
  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 get_intraday_data(
15
+ ticker: str,
16
+ start: datetime.datetime,
17
+ end: datetime.datetime
18
+ )-> str:
19
+ """A tool that fetches daily intraday data from EOD data service and returns min and max for the day
20
  Args:
21
+ ticker: the string representing a stock ticker at exchange
22
+ start: timestamp of type datetime.datetime that signals the beginning of the timeframe to fetch. Use NY timezone
23
+ end: timestamp of type datetime.datetime that signals the end of the timeframe to fetch. Use NY timezone
24
  """
25
+ eod_token = os.getenv("EOD_API_KEY")
26
+
27
+ aggs = self.eod_client.get_intraday_historical_data(
28
+ symbol=ticker,
29
+ interval='1m',
30
+ from_unix_time=start.timestamp(),
31
+ to_unix_time=end.timestamp()
32
+ )
33
+ if len(aggs) == 0:
34
+ return pd.DataFrame()
35
+ df = pd.DataFrame(aggs)
36
+ df["date"] = pd.to_datetime(df.timestamp, unit='s')
37
+ df.drop(columns=["timestamp", "gmtoffset", "datetime"], inplace=True)
38
+ df.date = df.date.dt.tz_localize('UTC')
39
+ df.date = df.date.dt.tz_convert('US/Eastern')
40
+ df.set_index("date", inplace=True)
41
+
42
+ max = df.high.max()
43
+ min = df.low.min()
44
+
45
+ return f"Max value: {max}. Min value {min}"
46
 
47
  @tool
48
  def get_current_time_in_timezone(timezone: str) -> str: