feat: Implement percentage-based position sizing
- Add usePercentageSize flag to SymbolSettings and TradingConfig - Add calculateActualPositionSize() and getActualPositionSizeForSymbol() helpers - Update execute and test endpoints to calculate position size from free collateral - Add SOLANA_USE_PERCENTAGE_SIZE, ETHEREUM_USE_PERCENTAGE_SIZE, USE_PERCENTAGE_SIZE env vars - Configure SOL to use 100% of portfolio (auto-adjusts to available balance) - Fix TypeScript errors: replace fillNotionalUSD with actualSizeUSD - Remove signalQualityVersion and fullyClosed references (not in interfaces) - Add comprehensive documentation in PERCENTAGE_SIZING_FEATURE.md Benefits: - Prevents insufficient collateral errors by using available balance - Auto-scales positions as account grows/shrinks - Maintains risk proportional to capital - Flexible per-symbol configuration (SOL percentage, ETH fixed)
This commit is contained in:
@@ -71,14 +71,17 @@ export async function GET() {
|
||||
// Global fallback
|
||||
MAX_POSITION_SIZE_USD: parseFloat(env.MAX_POSITION_SIZE_USD || '50'),
|
||||
LEVERAGE: parseFloat(env.LEVERAGE || '5'),
|
||||
USE_PERCENTAGE_SIZE: env.USE_PERCENTAGE_SIZE === 'true',
|
||||
|
||||
// Per-symbol settings
|
||||
SOLANA_ENABLED: env.SOLANA_ENABLED !== 'false',
|
||||
SOLANA_POSITION_SIZE: parseFloat(env.SOLANA_POSITION_SIZE || '210'),
|
||||
SOLANA_LEVERAGE: parseFloat(env.SOLANA_LEVERAGE || '10'),
|
||||
SOLANA_USE_PERCENTAGE_SIZE: env.SOLANA_USE_PERCENTAGE_SIZE === 'true',
|
||||
ETHEREUM_ENABLED: env.ETHEREUM_ENABLED !== 'false',
|
||||
ETHEREUM_POSITION_SIZE: parseFloat(env.ETHEREUM_POSITION_SIZE || '4'),
|
||||
ETHEREUM_LEVERAGE: parseFloat(env.ETHEREUM_LEVERAGE || '1'),
|
||||
ETHEREUM_USE_PERCENTAGE_SIZE: env.ETHEREUM_USE_PERCENTAGE_SIZE === 'true',
|
||||
|
||||
// Risk management
|
||||
STOP_LOSS_PERCENT: parseFloat(env.STOP_LOSS_PERCENT || '-1.5'),
|
||||
|
||||
Reference in New Issue
Block a user