Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
| 15 |
Args:
|
| 16 |
-
|
| 17 |
-
|
|
|
|
| 18 |
"""
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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:
|