Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -21,7 +21,11 @@ def get_btc_price() -> str:
|
|
| 21 |
|
| 22 |
@tool
|
| 23 |
def get_btc_historical_prices(days: int = 30) -> str:
|
| 24 |
-
"""Fetches historical Bitcoin prices in USD using the CoinGecko API.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
url = f"https://api.coingecko.com/api/v3/coins/bitcoin/market_chart?vs_currency=usd&days={days}&interval=daily"
|
| 26 |
response = requests.get(url)
|
| 27 |
if response.status_code != 200:
|
|
@@ -34,14 +38,22 @@ def get_btc_historical_prices(days: int = 30) -> str:
|
|
| 34 |
|
| 35 |
@tool
|
| 36 |
def analyze_sentiment(text: str) -> str:
|
| 37 |
-
"""Analyzes the sentiment of a given text.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
sentiment_pipeline = pipeline("sentiment-analysis")
|
| 39 |
result = sentiment_pipeline(text)
|
| 40 |
return f"Sentiment: {result[0]['label']}, Score: {result[0]['score']:.2f}"
|
| 41 |
|
| 42 |
@tool
|
| 43 |
def calculate_technical_indicators(data_json: str) -> str:
|
| 44 |
-
"""Calculates technical indicators from historical price data.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
df = pd.read_json(data_json)
|
| 46 |
df.set_index('timestamp', inplace=True)
|
| 47 |
df['SMA_10'] = ta.trend.sma_indicator(df['price'], window=10)
|
|
|
|
| 21 |
|
| 22 |
@tool
|
| 23 |
def get_btc_historical_prices(days: int = 30) -> str:
|
| 24 |
+
"""Fetches historical Bitcoin prices in USD using the CoinGecko API.
|
| 25 |
+
|
| 26 |
+
Args:
|
| 27 |
+
days (int): Number of days to fetch historical prices for.
|
| 28 |
+
"""
|
| 29 |
url = f"https://api.coingecko.com/api/v3/coins/bitcoin/market_chart?vs_currency=usd&days={days}&interval=daily"
|
| 30 |
response = requests.get(url)
|
| 31 |
if response.status_code != 200:
|
|
|
|
| 38 |
|
| 39 |
@tool
|
| 40 |
def analyze_sentiment(text: str) -> str:
|
| 41 |
+
"""Analyzes the sentiment of a given text.
|
| 42 |
+
|
| 43 |
+
Args:
|
| 44 |
+
text (str): The text to analyze.
|
| 45 |
+
"""
|
| 46 |
sentiment_pipeline = pipeline("sentiment-analysis")
|
| 47 |
result = sentiment_pipeline(text)
|
| 48 |
return f"Sentiment: {result[0]['label']}, Score: {result[0]['score']:.2f}"
|
| 49 |
|
| 50 |
@tool
|
| 51 |
def calculate_technical_indicators(data_json: str) -> str:
|
| 52 |
+
"""Calculates technical indicators from historical price data.
|
| 53 |
+
|
| 54 |
+
Args:
|
| 55 |
+
data_json (str): JSON string containing historical price data.
|
| 56 |
+
"""
|
| 57 |
df = pd.read_json(data_json)
|
| 58 |
df.set_index('timestamp', inplace=True)
|
| 59 |
df['SMA_10'] = ta.trend.sma_indicator(df['price'], window=10)
|