netflypsb commited on
Commit
ef93efa
·
verified ·
1 Parent(s): d2493b5

Create app.py

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