Fix hyperparameter parsing for read-only mode
- Improved CSV parsing logic for hyperparameters with empty type cells - Enhanced read-only mode sheet access with multiple URL formats and GID mapping - Added debug logging to identify parameter type mismatches - Fixed UnboundLocalError for max_size variable - Fixed unused variable warnings 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
+12
-1
@@ -150,8 +150,19 @@ def update_markets():
|
||||
|
||||
if len(received_df) > 0:
|
||||
global_state.df, global_state.params = received_df.copy(), received_params
|
||||
|
||||
# Debug: Show what param_types are in the markets data
|
||||
if 'param_type' in received_df.columns:
|
||||
param_types_used = received_df['param_type'].unique()
|
||||
print(f"DEBUG: param_types used in markets: {param_types_used}")
|
||||
print(f"DEBUG: Available hyperparameter types: {list(received_params.keys())}")
|
||||
|
||||
# Check for mismatches
|
||||
missing_params = [pt for pt in param_types_used if pt not in received_params.keys()]
|
||||
if missing_params:
|
||||
print(f"WARNING: Missing hyperparameters for param_types: {missing_params}")
|
||||
|
||||
for idx, row in global_state.df.iterrows():
|
||||
for _, row in global_state.df.iterrows():
|
||||
for col in ['token1', 'token2']:
|
||||
row[col] = str(row[col])
|
||||
|
||||
|
||||
+19
-2
@@ -44,7 +44,24 @@ def get_sheet_df(read_only=None):
|
||||
hyperparams, current_type = {}, None
|
||||
|
||||
for r in records:
|
||||
current_type = r['type'] or current_type
|
||||
hyperparams.setdefault(current_type, {})[r['param']] = r['value']
|
||||
# Update current_type only when we have a non-empty type value
|
||||
if r['type'] and r['type'].strip():
|
||||
current_type = r['type'].strip()
|
||||
|
||||
# Skip rows where we don't have a current_type set
|
||||
if current_type:
|
||||
# Convert numeric values to appropriate types
|
||||
value = r['value']
|
||||
try:
|
||||
# Try to convert to float if it's numeric
|
||||
if isinstance(value, str) and value.replace('.', '').replace('-', '').isdigit():
|
||||
value = float(value)
|
||||
elif isinstance(value, (int, float)):
|
||||
value = float(value)
|
||||
except (ValueError, TypeError):
|
||||
pass # Keep as string if conversion fails
|
||||
|
||||
hyperparams.setdefault(current_type, {})[r['param']] = value
|
||||
|
||||
print(f"DEBUG: Loaded hyperparameters: {hyperparams}")
|
||||
return result, hyperparams
|
||||
|
||||
@@ -119,6 +119,8 @@ async def perform_trade(market):
|
||||
|
||||
# Get trading parameters for this market type
|
||||
params = global_state.params[row['param_type']]
|
||||
print(f"DEBUG: Using param_type: {row['param_type']}, Available params: {params}")
|
||||
print(f"DEBUG: All available param types: {list(global_state.params.keys())}")
|
||||
|
||||
# Create a list with both outcomes for the market
|
||||
deets = [
|
||||
|
||||
Reference in New Issue
Block a user