Skip to content

Min distance fix 251224#19

Merged
lbsm2017 merged 6 commits intomainfrom
min_distance_fix_251224
Dec 24, 2025
Merged

Min distance fix 251224#19
lbsm2017 merged 6 commits intomainfrom
min_distance_fix_251224

Conversation

@lbsm2017
Copy link
Owner

No description provided.

- Introduced `practical_scenarios.py` to demonstrate scoring evaluations with real-world market examples.
- Created `quick_validation.py` for running all validation tests and summarizing results.
- Developed `test_scoring_validation.py` to validate scoring behavior across realistic scenarios, edge cases, and randomized inputs.
- Added `validation_results.txt` to log output from validation runs.
Copilot AI review requested due to automatic review settings December 24, 2025 11:32
…g algorithm improvements

- Deleted FINE_TUNING_SUMMARY.md, QUICK_REFERENCE.txt, SUMMARY.md, detailed_analysis.py, momentum_impact_demo.py, scoring_fixes.py as they are no longer needed.
- Enhanced scoring algorithm to improve momentum alignment impact, increasing multipliers and introducing a risk penalty for misaligned momentum.
- Updated validation tests to ensure all scenarios pass with the new scoring adjustments.
- Confirmed that the scoring system now effectively reflects the risk of counter-trend setups while maintaining sweet spot dominance.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request implements a minimum distance filter and comprehensive scoring system improvements for the Polymarket pullback hunter, with a complete validation suite to ensure correctness.

Key Changes:

  • Added min_distance filter to exclude markets too close to 0% or 100% (preventing trades on markets about to resolve)
  • Refactored calculate_opportunity_score function to use multi-modal optimization targeting a 2-5% distance, 7-10 day sweet spot
  • Strengthened momentum alignment impact (counter-trend penalty increased from 1.8 to 6.6 points)
  • Created comprehensive validation suite with 114+ tests covering realistic scenarios, edge cases, and randomized inputs

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
app.py Added min_distance parameter and slider (lines 1287-1298), implemented filtering logic (lines 1647-1658), completely refactored calculate_opportunity_score function with polynomial/sigmoid curves for smooth scoring transitions
tests/test_momentum_hunter.py Updated test_score_calculation to use new multi-modal scoring API, added comprehensive min_distance validation tests (5 new test methods)
validation/test_scoring_validation.py New comprehensive test suite with 114 tests across realistic scenarios, edge cases, randomized inputs, and comparative analysis
validation/practical_scenarios.py New real-world scenario demonstrations with 6 practical examples and trading interpretations
validation/detailed_analysis.py New deep-dive analysis tool for investigating specific scoring scenarios
validation/quick_validation.py New fast validation runner (64 tests in ~10 seconds)
validation/rigorous_testing.py New rigorous scenario testing across distance, time, volume, APY, momentum, and spread dimensions
validation/momentum_impact_demo.py New demonstration of momentum alignment impact after fine-tuning
validation/scoring_fixes.py Analysis document explaining the momentum alignment issue and proposed fixes
validation/README.md Comprehensive documentation of validation suite with 250 lines
validation/SUMMARY.md High-level validation results summary
validation/QUICK_REFERENCE.txt Quick reference guide with 178 lines covering common scenarios and development workflow
validation/FINE_TUNING_SUMMARY.md Detailed summary of scoring algorithm fine-tuning with before/after results
validation_results.txt Test execution output showing Unicode encoding error

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1153 to +1156
else: # >10pp/day
# Logarithmic for extreme charm (diminishing returns)
log_charm = min(1.0, math.log10(abs_charm - 9) / 1.0)
charm_score = 90 + log_charm * 10
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logarithm calculation math.log10(abs_charm - 9) can produce a math domain error when abs_charm equals exactly 10.0. At that value, abs_charm - 9 = 1.0, and log10(1) = 0, which is fine. However, if abs_charm is between 10.0 and 10.0 (exclusive), say 10.0 exactly, the calculation works. But the issue is that when abs_charm = 10.0, we have log10(1.0) = 0, which is correct. However, there's a potential edge case if abs_charm is slightly less than 10.0 due to floating point precision and falls into this else branch—then abs_charm - 9 would be less than 1.0, and log10(x) where x < 1 is negative, which is mathematically valid but might not match the intended behavior. The real issue is if abs_charm exactly equals 10.0, it should probably use a different formula or be handled by the previous condition. Consider using elif abs_charm <= 10.0 instead of < 10.0 for the previous condition to avoid edge cases.

Copilot uses AI. Check for mistakes.

for i in range(n_tests):
# Generate random but plausible parameters
prob = random.uniform(0.01, 0.99)
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Variable prob is not used.

Suggested change
prob = random.uniform(0.01, 0.99)

Copilot uses AI. Check for mistakes.

from app import calculate_opportunity_score
import random
import math
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import of 'math' is not used.

Suggested change
import math

Copilot uses AI. Check for mistakes.
from app import calculate_opportunity_score
import random
import math
from typing import Dict, List, Tuple
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import of 'Tuple' is not used.
Import of 'List' is not used.

Suggested change
from typing import Dict, List, Tuple
from typing import Dict

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

Validation Results

Quick Validation: Completed (64 tests)

Full Validation: Completed (114 tests)
Rigorous Testing: Completed

NOTE: app.py modified - comprehensive validation run

Check the "Checks" tab for detailed validation output.

@lbsm2017 lbsm2017 merged commit 7443c53 into main Dec 24, 2025
9 checks passed
@lbsm2017 lbsm2017 deleted the min_distance_fix_251224 branch December 24, 2025 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants