feat: Улучшить алгоритм автокурса - занимать позицию в диапазоне#71
Merged
feat: Улучшить алгоритм автокурса - занимать позицию в диапазоне#71
Conversation
dapi
commented
Dec 24, 2025
app/models/gera/exchange_rate.rb
Outdated
| when 'position_aware' | ||
| AutorateCalculators::PositionAware | ||
| else | ||
| AutorateCalculators::Legacy |
| # @param [Float] Порог аномальной комиссии для защиты от манипуляторов (UC-9) | ||
| # Если комиссия отличается от медианы более чем на этот процент - считается аномальной | ||
| mattr_accessor :anomaly_threshold_percent | ||
| @@anomaly_threshold_percent = 50.0 |
Author
There was a problem hiding this comment.
Добавь в README пример как пользоваться этой конфигурацией
Добавлен новый калькулятор PositionAware, который гарантирует, что обменник займёт позицию внутри целевого диапазона, а не перепрыгнет выше. Реализованные use cases: - UC-1..UC-4: Базовая логика без перепрыгивания позиций выше - UC-6: Адаптивный GAP для плотных рейтингов - UC-8: Исключение своего обменника из расчёта (Gera.our_exchanger_id) - UC-9: Защита от манипуляторов с аномальными курсами Архитектура: - Паттерн Strategy: Legacy (старое поведение) и PositionAware (новое) - Выбор калькулятора через поле calculator_type в ExchangeRate - Обратная совместимость: по умолчанию используется Legacy Конфигурация: - Gera.our_exchanger_id - ID обменника для исключения из расчёта - Gera.anomaly_threshold_percent - порог аномалий (по умолчанию 50%) Closes #69 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
… README - В autorate_calculator_class бросаем ArgumentError для неизвестных типов - Добавлена документация по конфигурации автокурса в README 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
bfa151e to
60d5af4
Compare
19 tasks
Author
dapi
added a commit
that referenced
this pull request
Jan 20, 2026
Adapts PR #71 (position-aware autorate) for current master: - Add AutorateCalculators::Legacy and PositionAware with Strategy pattern - Use Manul API instead of BestChange::Service for external rates - Use ActiveJob (perform_later) instead of Sidekiq (perform_async) - Add calculator_type column to exchange_rates for selecting algorithm - Add our_exchanger_id and anomaly_threshold_percent config options The PositionAware calculator prevents "jumping over" positions above the target range, with adaptive GAP and anomaly protection. Closes #69 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This was referenced Jan 20, 2026
This was referenced Jan 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Решает проблему #69: текущий алгоритм автокурса при попытке занять позицию в диапазоне (например, 5-10) перепрыгивает все позиции выше, вместо того чтобы остаться внутри целевого диапазона.
Что сделано
PositionAwareс паттерном StrategyLegacyкалькуляторАрхитектура
Выбор калькулятора через поле
calculator_typeвExchangeRate.Конфигурация
Миграция
Test plan
Closes #69
🤖 Generated with Claude Code