Spaces:
Runtime error
Runtime error
File size: 1,640 Bytes
ef93efa |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
import streamlit as st
from binance.client import Client
from binance_api.client import BinanceClient
from indicators.sma import calculate_sma
from indicators.bollinger_bands import calculate_bollinger_bands
from signals.strategy import generate_signals
from utils.plotting import plot_data_with_indicators_and_signals
import pandas as pd
# Initialize Streamlit app
st.title('CryptoApp: Cryptocurrency Trading Signals')
# User inputs
symbol = st.text_input('Enter the cryptocurrency symbol (e.g., BTCUSDT):').upper()
api_key = st.text_input('Enter your Binance API Key:')
api_secret = st.text_input('Enter your Binance API Secret:', type="password")
# Analyze button
if st.button('Analyze'):
if not symbol or not api_key or not api_secret:
st.error('Please provide both the cryptocurrency symbol and your Binance API credentials.')
else:
# Initialize Binance Client
try:
client = BinanceClient(api_key, api_secret)
# Fetch historical price data
data = client.fetch_historical_prices(symbol=symbol, interval=Client.KLINE_INTERVAL_1HOUR, days=30)
# Calculate indicators
data = calculate_sma(data, 'close', 21)
data = calculate_sma(data, 'close', 50)
data = calculate_bollinger_bands(data)
# Generate signals
data = generate_signals(data)
# Plotting
st.write(f'Analysis and Signals for {symbol}')
plot_data_with_indicators_and_signals(data)
except Exception as e:
st.error(f'Failed to fetch and analyze data for {symbol}. Error: {str(e)}')
|