-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
69 lines (58 loc) · 2.61 KB
/
app.py
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import streamlit as st
from backend.gmgn_api import GMGNTradingAPI
from backend.ai_model import AIModel
from backend.risk_analysis import RiskAnalyzer
from utils.visualizations import plot_risk_analysis, plot_trade_history
import pandas as pd
# Initialize components
gmgn_api = GMGNTradingAPI()
ai_model = AIModel()
risk_analyzer = RiskAnalyzer()
# App configuration
st.set_page_config(page_title="Crypto Trading Pro", layout="wide")
# Sidebar for settings
st.sidebar.title("Settings")
with st.sidebar:
st.subheader("AI Model Settings")
ai_model_option = st.selectbox("AI Model", ["Gemini 2.0 Flash"], key="ai_model")
ai_api_key = st.text_input("AI Model API Key", type="password", key="ai_api_key")
st.subheader("Network Settings")
rpc_endpoint = st.text_input("RPC Endpoint", value="https://rpc.solana.com", key="rpc_endpoint")
quicknode_api_key = st.text_input("QuickNode API Key", type="password", key="quicknode_key")
theme = st.radio("Select Theme", ["Light", "Dark"], key="theme")
st.button("Save Settings")
# Main UI
st.title("Crypto Trading Pro")
st.markdown("**Powered by Gemini 2.0 Flash AI & GMGN Trading API**")
# Apply theme
if theme == "Dark":
st.markdown("""<style>body { background-color: #121212; color: white; }</style>""", unsafe_allow_html=True)
# Main layout
col1, col2 = st.columns([2, 1])
with col1:
st.header("Risk Analysis Dashboard")
token_symbol = st.text_input("Token Address or Symbol", key="token_symbol")
if st.button("Analyze Token"):
price_data = gmgn_api.get_price_data(token_symbol)
predictions = ai_model.predict(price_data)
risks = risk_analyzer.calculate_risks(price_data, predictions)
st.subheader("Risk Scores")
st.write(risks)
st.subheader("Trade Recommendation")
st.write(predictions["trade_signal"])
plot_risk_analysis(risks)
st.pyplot()
with col2:
st.header("Quick Trade")
action = st.radio("Select Action", ["Buy", "Sell"], horizontal=True, key="trade_action")
amount = st.number_input("Amount (SOL)", min_value=0.01, step=0.01, key="trade_amount")
slippage = st.slider("Max Slippage %", min_value=0, max_value=5, value=1, key="slippage")
if st.button("Place Trade"):
trade_result = gmgn_api.execute_trade(token_symbol, amount, action, slippage)
st.write(trade_result)
st.header("Trade History")
if st.button("Export to CSV"):
trade_history = gmgn_api.get_trade_history()
csv_path = f"data/trade_results/trade_history.csv"
pd.DataFrame(trade_history).to_csv(csv_path, index=False)
st.write(f"Trade history exported to {csv_path}.")