GOKULSINGHSHAH123 commited on
Commit
791aa4f
·
verified ·
1 Parent(s): 334343c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -15
app.py CHANGED
@@ -33,26 +33,40 @@ trade_type= "PERPETUAL" # perpetual or delivery
33
  # Authenticate using the service account info
34
  creds = Credentials.from_service_account_info(service_account_info, scopes=scopes)
35
  client = gspread.authorize(creds)
 
 
 
 
 
 
36
 
37
- # The ID of the Google Sheet (found in the URL of the sheet)
38
- sheet_id = "1I_PuAeWTaRC4OhS5BA5gv0XQCA17VlIjpA1MvOlzVA8"
39
-
40
- # Open the Google Sheet by sheet ID
41
- workbook = client.open_by_key(sheet_id)
42
-
43
- # Select the specific sheet in the workbook
44
- sheet = workbook.worksheet("usdmHistory")
45
- sheet3 = workbook.worksheet("Performance")
46
-
47
- # Extract the data from the Google Sheet into a pandas DataFrame
48
- data = sheet.get_all_values()
49
 
50
- headers = data.pop(0)
51
- df = pd.DataFrame(data, columns=headers)
 
 
 
52
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
 
54
 
55
 
 
56
 
57
  def combine_chunks(df):
58
  combined_rows = []
@@ -98,7 +112,7 @@ df = df.apply(lambda col: col.map(convert_str_to_list_or_keep))
98
 
99
  df['positionClosed'] = False
100
 
101
- uid_input = str.Upper(st.text_input("Enter U_IDs to filter"))
102
 
103
  option = st.radio("Choose an option:", ["Show Position History", "Show Live Positions"])
104
 
 
33
  # Authenticate using the service account info
34
  creds = Credentials.from_service_account_info(service_account_info, scopes=scopes)
35
  client = gspread.authorize(creds)
36
+ sheet_mapping = {
37
+ "usdm": "usdmHistory",
38
+ "coinm": "coinmHistory",
39
+ "copyTraders": "copyTradersHistory",
40
+ "okx": "okx"
41
+ }
42
 
43
+ # Streamlit UI
44
+ st.title("Google Sheets Selector")
 
 
 
 
 
 
 
 
 
 
45
 
46
+ # Dropdown to select an option
47
+ option = st.selectbox(
48
+ "Select a Sheet",
49
+ ("usdm", "coinm", "copyTraders", "okx")
50
+ )
51
 
52
+ if st.button("Load Sheet"):
53
+ # Get the selected sheet name
54
+ sheet_name = sheet_mapping[option]
55
+
56
+ # Open the Google Sheet and select the worksheet
57
+ sheet_id = "1I_PuAeWTaRC4OhS5BA5gv0XQCA17VlIjpA1MvOlzVA8" # Replace with your actual Sheet ID
58
+ workbook = client.open_by_key(sheet_id)
59
+ sheet = workbook.worksheet(sheet_name)
60
+
61
+ # Fetch data from the worksheet and display it
62
+ data = sheet.get_all_records()
63
+ df = pd.DataFrame(data)
64
+ st.write(f"Displaying data for: {sheet_name}")
65
+ st.dataframe(df)
66
 
67
 
68
 
69
+ sheet3 = workbook.worksheet("Performance")
70
 
71
  def combine_chunks(df):
72
  combined_rows = []
 
112
 
113
  df['positionClosed'] = False
114
 
115
+ uid_input = str.upper(st.text_input("Enter U_IDs to filter"))
116
 
117
  option = st.radio("Choose an option:", ["Show Position History", "Show Live Positions"])
118