Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,6 +4,8 @@ import matplotlib.pyplot as plt
|
|
| 4 |
import matplotlib.dates as mdates
|
| 5 |
from io import BytesIO
|
| 6 |
import gradio as gr
|
|
|
|
|
|
|
| 7 |
|
| 8 |
# Fetch MEXC OHLCV data
|
| 9 |
def fetch_ohlcv(symbol='BTC/USDT', timeframe='1h', limit=100):
|
|
@@ -69,11 +71,13 @@ def plot_candlestick(df):
|
|
| 69 |
plt.title('Candlestick Chart (MEXC)')
|
| 70 |
plt.tight_layout()
|
| 71 |
|
|
|
|
| 72 |
buf = BytesIO()
|
| 73 |
plt.savefig(buf, format='png')
|
| 74 |
buf.seek(0)
|
| 75 |
plt.close(fig)
|
| 76 |
-
return buf
|
|
|
|
| 77 |
|
| 78 |
# Main function
|
| 79 |
def analyze(pair, timeframe):
|
|
|
|
| 4 |
import matplotlib.dates as mdates
|
| 5 |
from io import BytesIO
|
| 6 |
import gradio as gr
|
| 7 |
+
from PIL import Image
|
| 8 |
+
from PIL import Image
|
| 9 |
|
| 10 |
# Fetch MEXC OHLCV data
|
| 11 |
def fetch_ohlcv(symbol='BTC/USDT', timeframe='1h', limit=100):
|
|
|
|
| 71 |
plt.title('Candlestick Chart (MEXC)')
|
| 72 |
plt.tight_layout()
|
| 73 |
|
| 74 |
+
# Save chart to image object
|
| 75 |
buf = BytesIO()
|
| 76 |
plt.savefig(buf, format='png')
|
| 77 |
buf.seek(0)
|
| 78 |
plt.close(fig)
|
| 79 |
+
return Image.open(buf)
|
| 80 |
+
|
| 81 |
|
| 82 |
# Main function
|
| 83 |
def analyze(pair, timeframe):
|