diff --git a/app/api/drift/markets/route.ts b/app/api/drift/markets/route.ts new file mode 100644 index 0000000..a634370 --- /dev/null +++ b/app/api/drift/markets/route.ts @@ -0,0 +1,78 @@ +import { NextRequest, NextResponse } from 'next/server' +import { initializeDriftService, getDriftService } from '@/lib/drift/client' + +/** + * GET /api/drift/markets + * + * Query Drift Protocol perpetual markets + * Optional query param: ?search=FARTCOIN to filter by symbol + */ +export async function GET(request: NextRequest) { + try { + const searchParams = request.nextUrl.searchParams + const searchSymbol = searchParams.get('search')?.toUpperCase() + + await initializeDriftService() + const driftService = getDriftService() + const driftClient = driftService.getClient() + + const perpMarketAccounts = driftClient.getPerpMarketAccounts() + + if (!perpMarketAccounts || perpMarketAccounts.length === 0) { + return NextResponse.json({ markets: [] }) + } + + const markets = perpMarketAccounts.map((market, index) => { + if (!market) return null + + // Decode market name from bytes + const nameBytes = market.name as unknown as number[] + const symbol = nameBytes + ? String.fromCharCode(...Array.from(nameBytes).filter((b: number) => b !== 0)).trim() + : `Market-${index}` + + const minOrderSize = market.amm?.minOrderSize + ? Number(market.amm.minOrderSize) / 1e9 + : 0 + + const tickSize = market.amm?.orderTickSize + ? Number(market.amm.orderTickSize) / 1e6 + : 0.0001 + + const oracleAddress = market.amm?.oracle?.toString() || 'N/A' + + return { + index, + symbol, + oracleAddress, + minOrderSize, + tickSize, + marginRatioInitial: market.marginRatioInitial + ? Number(market.marginRatioInitial) / 10000 + : 0, + marginRatioMaintenance: market.marginRatioMaintenance + ? Number(market.marginRatioMaintenance) / 10000 + : 0, + } + }).filter(Boolean) + + // Filter by search if provided + const filtered = searchSymbol + ? markets.filter(m => m && m.symbol.toUpperCase().includes(searchSymbol)) + : markets + + await driftService.disconnect() + + return NextResponse.json({ + total: markets.length, + filtered: filtered.length, + markets: filtered, + }) + } catch (error: any) { + console.error('āŒ Error fetching markets:', error) + return NextResponse.json( + { error: 'Failed to fetch markets', message: error.message }, + { status: 500 } + ) + } +} diff --git a/cluster/exploration.db b/cluster/exploration.db index e303153..dcbcb97 100644 Binary files a/cluster/exploration.db and b/cluster/exploration.db differ diff --git a/cluster/v11_test_coordinator.py b/cluster/v11_test_coordinator.py index e9469b0..7633990 100755 --- a/cluster/v11_test_coordinator.py +++ b/cluster/v11_test_coordinator.py @@ -215,7 +215,7 @@ def deploy_worker(worker_name: str, chunk_id: str, start_combo: int): 'scp', '-o', 'StrictHostKeyChecking=no', '-o', f'ProxyJump={worker["ssh_hop"]}', - 'cluster/v11_test_worker.py', + 'v11_test_worker.py', f'{worker["host"]}:{workspace}/' ] else: @@ -223,7 +223,7 @@ def deploy_worker(worker_name: str, chunk_id: str, start_combo: int): scp_cmd = [ 'scp', '-o', 'StrictHostKeyChecking=no', - 'cluster/v11_test_worker.py', + 'v11_test_worker.py', f'{worker["host"]}:{workspace}/' ] @@ -263,7 +263,7 @@ def deploy_worker(worker_name: str, chunk_id: str, start_combo: int): # Start worker print(f"šŸš€ Starting worker process...") - worker_cmd = f"cd {workspace} && nohup python3 v11_test_worker.py {DATA_FILE} {chunk_id} {start_combo} > {chunk_id}_worker.log 2>&1 &" + worker_cmd = f"cd {workspace} && nohup .venv/bin/python3 v11_test_worker.py {DATA_FILE} {chunk_id} {start_combo} > {chunk_id}_worker.log 2>&1 &" if 'ssh_hop' in worker: ssh_cmd = [ diff --git a/cluster/v11_test_worker.py b/cluster/v11_test_worker.py index ac682a2..fdc326f 100755 --- a/cluster/v11_test_worker.py +++ b/cluster/v11_test_worker.py @@ -113,6 +113,7 @@ def backtest_config(config: Dict[str, Any]) -> Dict[str, Any]: try: # Create v11 inputs inputs = MoneyLineV11Inputs( + use_quality_filters=True, # šŸ”§ FIX: Enable filters for progressive sweep flip_threshold=config['flip_threshold'], adx_min=config['adx_min'], long_pos_max=config['long_pos_max'], @@ -120,6 +121,8 @@ def backtest_config(config: Dict[str, Any]) -> Dict[str, Any]: vol_min=config['vol_min'], entry_buffer_atr=config['entry_buffer_atr'], rsi_long_min=config['rsi_long_min'], + rsi_long_max=70, # šŸ”§ FIX: Add missing fixed parameter + rsi_short_min=30, # šŸ”§ FIX: Add missing fixed parameter rsi_short_max=config['rsi_short_max'], ) diff --git a/so the whole time all the development we did was not working and therefore we have lost 1000$...... i hope with the new test system this is an issue of the past b/so the whole time all the development we did was not working and therefore we have lost 1000$...... i hope with the new test system this is an issue of the past new file mode 100644 index 0000000..e69de29 diff --git a/test_worker_params.py b/test_worker_params.py new file mode 100644 index 0000000..6716821 --- /dev/null +++ b/test_worker_params.py @@ -0,0 +1,71 @@ +#!/usr/bin/env python3 +"""Test exact parameters worker is using""" + +import pandas as pd +import sys +sys.path.insert(0, 'backtester') + +from v11_moneyline_all_filters import money_line_v11_signals, MoneyLineV11Inputs + +# Load dataset +print("Loading data...") +df = pd.read_csv('data/solusdt_5m.csv') +df['timestamp'] = pd.to_datetime(df['timestamp']) +df = df.set_index('timestamp') +print(f"āœ“ Loaded {len(df)} bars") + +# Test EXACT worker configuration (most permissive combination) +config = { + 'flip_threshold': 0.4, # Most permissive + 'adx_min': 0, # Filter DISABLED + 'long_pos_max': 100, # Most permissive + 'short_pos_min': 0, # Filter DISABLED + 'vol_min': 0.0, # Filter DISABLED + 'entry_buffer_atr': 0.0, # Filter DISABLED + 'rsi_long_min': 25, # Permissive + 'rsi_short_max': 80, # Permissive +} + +print("\nTest 1: Worker parameters WITH use_quality_filters=True") +print(f"Config: {config}") +inputs = MoneyLineV11Inputs( + use_quality_filters=True, + flip_threshold=config['flip_threshold'], + adx_min=config['adx_min'], + long_pos_max=config['long_pos_max'], + short_pos_min=config['short_pos_min'], + vol_min=config['vol_min'], + entry_buffer_atr=config['entry_buffer_atr'], + rsi_long_min=config['rsi_long_min'], + rsi_long_max=70, + rsi_short_min=30, + rsi_short_max=config['rsi_short_max'], +) +print(f"use_quality_filters: {inputs.use_quality_filters}") +print(f"RSI bounds: long [{inputs.rsi_long_min}, {inputs.rsi_long_max}], short [{inputs.rsi_short_min}, {inputs.rsi_short_max}]") + +signals = money_line_v11_signals(df, inputs) +print(f"RESULT: {len(signals)} signals") + +if len(signals) == 0: + print("\nšŸ”“ ZERO SIGNALS - Same as worker!") + print("\nTest 2: Try WITHOUT quality filters") + inputs2 = MoneyLineV11Inputs( + use_quality_filters=False, # Bypass all filters + flip_threshold=0.4, + ) + signals2 = money_line_v11_signals(df, inputs2) + print(f"RESULT: {len(signals2)} signals") + + if len(signals2) > 0: + print("\nāœ“ Filter bypass works - problem is WITH filters") + print("Debugging which filter is blocking...") + + # Check each filter component + print("\n First 10 rows of data:") + print(df[['open', 'high', 'low', 'close', 'volume']].head(10)) +else: + print(f"\nāœ… SUCCESS: {len(signals)} signals generated!") + print(f" First 3 signals:") + for s in signals[:3]: + print(f" {s.timestamp} {s.direction} @ ${s.entry_price:.2f}")