# FC 27 Price Prediction & Econometric Engine

The `@aphrody/fut` Price Prediction Engine provides predictive modeling of transfer market prices across multiple forecasting horizons (`12h`, `24h`, `3d`, `7d`, `14d`).

It combines:
1. **Factual In-Game Meta Valuation**: Evaluates card mechanics (animations, body types, AcceleRATE 2.0, 5★ Weak Foot & Skill Moves, Tier-S PlayStyles+) via `calculateFactualMetaRating`.
2. **Pack Drop Scarcity & Supply Economics**: Connects face overall rating (OVR) and card rarity (Gold Rare, Hero, Icon) to EA pack drop probability distributions.
3. **FC 26 Historical Seasonality Benchmarks**: Analyzes historical price curves across 5 card archetypes (Elite Meta, Competitive Meta, High Fodder, Mid Fodder, Discard Golds) mapped against game cycle phases.
4. **Intra-Week Liquidity Cycles**: Models weekly rhythm (Weekend League demand peaks on Thursday/Friday, sell-off bottoms on Sunday night/Monday morning, and midweek stabilization).
5. **Real-Time Market Prices & EA Tax**: Computes net ROI factoring in the 5% EA transfer tax and rounds to valid EA transfer market bid/BIN tick increments.

---

## Architecture & Equations

### 1. Econometric Fair Value Model (`metaPricingModel.ts`)

Card pricing on the transfer market is a dual-force system:
- **Fodder Price Floor**: The intrinsic value of the card as SBC fuel, governed purely by face OVR and active SBC requirements.
- **Competitive Meta Premium**: The price players are willing to pay for in-game competitive performance in Champions and Rivals.

#### Mathematical Formulation:
$$\text{FairValue} = (1 - w_{\text{fodder}}) \cdot \text{BaseMetaPrice} \cdot M_{\text{WF}} \cdot M_{\text{SM}} \cdot M_{\text{Body}} \cdot M_{\text{PlayStyle}} + w_{\text{fodder}} \cdot \text{FodderFloor}$$

Where:
- $\text{FodderFloor}$: Established from live SBC fodder index (e.g. 84 = ~1,500 coins, 88 = ~14,000 coins).
- $w_{\text{fodder}}$: Weight given to fodder floor, inversely proportional to the card's meta rating:
  $$w_{\text{fodder}} = \max\left(0, 1 - \frac{\text{MetaRating} - 75}{15}\right)$$
  *(Cards with MetaRating $\ge 90$ have $w_{\text{fodder}} = 0$, behaving as pure meta cards).*
- $\text{BaseMetaPrice}$: Scaled exponentially by both MetaRating and OVR supply scarcity:
  $$\text{BaseMetaPrice} = f(\text{MetaRating}) \cdot S(\text{OVR})$$
  *(Prevents low-OVR meta cards like 82-rated Mendy from inflating to millions due to pack availability).*
- Multipliers:
  - $M_{\text{WF}}$: Weak Foot multiplier ($5\star = +30\%$, $4\star = +8\%$, $3\star = 0\%$, $2\star = -15\%$).
  - $M_{\text{SM}}$: Skill Moves multiplier ($5\star = +25\%$, $4\star = +5\%$).
  - $M_{\text{Body}}$: Body Type modifier (`Unique` $= +15\%$, `Lean` $= +6\%$, `Stocky` $= -10\%$).

---

### 2. Intra-Week Liquidity Multipliers (`historicalCycles.ts`)

Market liquidity follows an established weekly cadence driven by competitive events and content drops:

| Day of Week | Elite Meta Multiplier | Mid Meta Multiplier | Fodder Multiplier | Market Dynamics |
| :--- | :--- | :--- | :--- | :--- |
| **Monday** | `0.94` | `0.92` | `0.97` | **Sell-Off Bottom**: Weekend League sell-off, rewards dumping |
| **Tuesday** | `0.96` | `0.95` | `0.98` | **Quiet Accumulation**: Best day for buying meta teams |
| **Wednesday** | `0.98` | `0.98` | `1.04` | **TOTW & Marquee Matchups**: Fodder demand rises |
| **Thursday** | `1.04` | `1.03` | `1.02` | **Rivals Rewards**: Influx of coins, players prepare for WL |
| **Friday** | `1.08` | `1.07` | `1.00` | **WL Launch & Promo 19h**: Peak demand for meta cards |
| **Saturday** | `1.05` | `1.04` | `0.99` | **Active Champions**: High demand continues |
| **Sunday** | `0.98` | `0.95` | `0.96` | **WL Exit**: Players sell off squads after finishing 20 games |

---

### 3. Market Phase Seasonality Benchmarks (`historicalCycles.ts`)

The annual cycle is benchmarked against observed FC 26 trajectory curves:
1. `PRE_LAUNCH`: Web App open, ultra-high demand for top-tier meta, low coin liquidity.
2. `LAUNCH_WEEK`: Global release, huge pack openings. Low-rated meta cards drop; top-tier cards rise as coins circulate.
3. `FIRST_WL`: First competitive Champions weekend. Meta cards reach short-term peak.
4. `EARLY_CYCLE`: Weeks 2-6. Gradual deflation on mid-tier cards as supply outpaces demand.
5. `PRE_BLACK_FRIDAY`: Panic selling in anticipation of lightning rounds.
6. `MID_CYCLE`: Stable period with promo-driven spikes.
7. `TOTY_CRASH`: Mass market sell-off ahead of Team of the Year.
8. `LATE_CYCLE`: Post-TOTS deflation.

---

### 4. Multi-Horizon Forecasting Engine (`timeSeriesPredictor.ts`)

For any forecast horizon $h \in \{12\text{h}, 24\text{h}, 3\text{d}, 7\text{d}, 14\text{d}\}$:

1. **Mean Reversion**: Cards drift towards their intrinsic fair value over time:
   $$\Delta_{\text{FairValue}} = (\text{FairValue} - P_{\text{Live}}) \cdot \alpha_h$$
2. **Seasonality Drift**: Historical FC 26 trend applied according to archetype:
   $$\Delta_{\text{Season}} = P_{\text{Live}} \cdot (\beta_{\text{archetype}, h} - 1)$$
3. **Intra-Week Shift**: Ratio of target day-of-week multiplier to current day-of-week multiplier:
   $$\Delta_{\text{Day}} = \frac{M_{\text{target}}}{M_{\text{current}}}$$
4. **Net ROI & EA Tax**:
   $$\text{PredictedPrice} = \text{RoundToTick}\left( (P_{\text{Live}} + \Delta_{\text{FairValue}} + \Delta_{\text{Season}}) \cdot \Delta_{\text{Day}} \right)$$
   $$\text{NetRoi} = \frac{\text{PredictedPrice} \cdot 0.95 - P_{\text{Live}}}{P_{\text{Live}}} \cdot 100\%$$
5. **Trade Signals**:
   - `STRONG_BUY`: Net ROI $\ge +15\%$ and card underpriced relative to fair value.
   - `BUY`: Net ROI between $+6\%$ and $+15\%$.
   - `HOLD`: Net ROI between $-4\%$ and $+6\%$.
   - `SELL`: Net ROI between $-12\%$ and $-4\%$.
   - `PANIC_SELL`: Net ROI $< -12\%$ or severe incoming promo/seasonality crash.

---

## CLI Usage

### 1. Predict Specific Player
```bash
bxc fut predict mbappe
bxc fut predict "Ferland Mendy" --live-price 18000
bxc fut predict vinnie --horizon 7d
```

Output:
```
======================================================================
  FC 27 PRICE PREDICTOR: Kylian Mbappé (91 ST)
======================================================================
  * Meta Rating     : 98.4/100 (GOD_TIER)
  * Live Market BIN : 2,450,000 coins
  * Fair Value Model: 2,750,000 coins (+12.2% Undervalued)
  * Current Phase   : PRE_LAUNCH (Day 1)
  * Intra-Week Day  : THURSDAY

----------------------------------------------------------------------
  MULTI-HORIZON FORECASTS (Net after 5% EA tax):
----------------------------------------------------------------------
  12h :   2,550,000 coins | Net ROI:  -1.0% | Trend: STABLE
  24h :   2,700,000 coins | Net ROI:  +4.7% | Trend: STABLE
  3d  :   2,900,000 coins | Net ROI: +12.4% | Trend: UP
  7d  :   3,150,000 coins | Net ROI: +22.1% | Trend: STRONG_UP
  14d :   3,400,000 coins | Net ROI: +31.8% | Trend: STRONG_UP

----------------------------------------------------------------------
  ACTION SIGNAL: STRONG_BUY
  Target Buy  : 2,350,000 coins
  Target Sell : 3,100,000 coins
  Stop Loss   : 2,200,000 coins
  Risk Level  : LOW
----------------------------------------------------------------------
  * Catalysts:
    - First Weekend League demand surge
    - High tier-S PlayStyles and 5★ SM boost
  * Risks:
    - Promo packs or untradeable store pack flooding
======================================================================
```

### 2. Scan Market Opportunities
```bash
# Scan opportunities with 50,000 coins budget
bxc fut predict opps --budget 50000

# Scan opportunities with 500,000 coins budget and minimum 10% net ROI
bxc fut predict opps --budget 500000 --min-roi 10 --horizon 7d
```

### 3. Display Current Market Phase and Intra-Week Multipliers
```bash
bxc fut predict cycle
```
