crypto_signal / app.py
netflypsb's picture
Rename app_binance.py to app.py
e7bd7b1 verified
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)}')