Skip to content

HingedGuide/tradeup_optimizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CS2 Trade-Up Optimizer

Python License CS2 Strategy

An open-source CS2 Trade-Up Calculator written in Python.

Unlike web-based calculators that rely on high-fee Steam Community Market prices, this tool integrates directly with CSFloat to find "Sniper" trade-ups with real profit margins. It uses advanced mathematical modeling to solve for the exact maximum input float needed to guarantee profitable outcomes. This project was created to demonstrate Python capabilities and is provided as-is. It is not actively maintained.

Features

  • Automated Metadata Fetching: Retrieves the latest CS2 skin data (collections, rarities, float ranges) from the ByMykel API.
  • Real-Time Price Analysis: Fetches current market prices from:
    • CSFloat (Priority, supports bulk listing prices).
    • Steam Community Market (Fallback).
  • Profitability Calculation: Automatically computes:
    • Return on Investment (ROI)
    • Net Profit (Expected Value)
    • Max average input float required.
  • Smart Filtering: Search based on minimum ROI, minimum profit, and maximum cost constraints.
  • Rich Terminal Output: Displays results in a clean, formatted table using the rich library.

⚡ Why Use This Optimizer?

Most public trade-up tools are broken or misleading because they:

  1. Use Steam Prices: Steam takes a ~15% fee. We use CSFloat prices (~2% fee), uncovering profits that other tools miss.
  2. Assume Average Floats: They assume you buy "average" skins. We calculate the Sniper Float: the exact max float you need to buy to force a Factory New outcome from Field-Tested inputs.
  3. Are Closed Source: You don't know the math behind the curtain. This repo is 100% transparent Python code.

📉 Why Rarity Upgrades Are Not Enough

A common misconception is that simply trading 10 skins of a lower rarity (e.g., Restricted) for 1 skin of a higher rarity (e.g., Classified) yields profit. This is almost always false.

  • The House Wins: In a generic trade-up using average skins, the value of the output skin is usually lower than the cost of the 10 input skins (Negative EV).
  • The "Condition Cliff": The real profit lies in the price jump between conditions. A Minimal Wear skin might be worth $8, while the Factory New version is worth $15.
  • The Arbitrage: This optimizer finds the mathematical "loophole" where you buy Field-Tested inputs (cheap) but mathematically guarantee a Factory New output (expensive).

Example:

  • Standard Trade-Up: 10x Field-Tested Inputs ($10 cost) -> 1x Field-Tested Output ($8 value) = $2 Loss.
  • Sniper Trade-Up: 10x Low-Float Field-Tested Inputs ($10 cost) -> 1x Factory New Output ($15 value) = $5 Profit.

This tool calculates the exact float limit needed to force that Factory New outcome.

Prerequisites

  • Python 3.10+
  • A CSFloat API Key (recommended for accurate pricing)

🧠 The "Sniper" Strategy Explained

This tool implements the "Inverse Trade-Up Formula". Instead of guessing inputs, it works backward:

  1. Target Identification: Finds a profitable outcome (e.g., AK-47 | Slate (FN)).
  2. Float Solving: Calculates the mathematical limit for the average input float using the CS2 formula: OutcomeFloat = (AvgInput * (Max - Min)) + Min
  3. Market Scanning: Checks if inputs below that specific float limit are available on CSFloat for a price that yields the specified ROI.

Installation

  1. Clone the repository:

    git clone <repository-url>
    cd tradeup_optimizer
  2. Install dependencies:

    pip install -r tradeup_optimizer/requirements.txt

Configuration

Create a .env file in the project root directory to configure your API keys and settings.

Example .env:

# Required for accurate market data
CSFLOAT_API_KEY=your_csfloat_api_key_here

# Optional Configuration
PRICE_PROVIDER_PRIORITY=csfloat,steam
DEFAULT_MIN_ROI=0.05
DEFAULT_MIN_PROFIT=1.0
DEFAULT_MAX_TOTAL_COST=100.0

Usage

Run the optimizer using the Python module syntax. The primary command is best, which searches for the best available trade-ups.

Basic Search Command:

python -m tradeup_optimizer.cli best

Custom Filters

Customize your search with the following options:

python -m tradeup_optimizer.cli best --min-roi 0.15 --min-profit 2.0 --max-cost 50
  • --min-roi: Minimum Return on Investment (e.g., 0.15 for 15%).
  • --min-profit: Minimum expected profit in USD.
  • --max-cost: Maximum total cost of input skins in USD.

Project Structure

  • tradeup_optimizer/cli.py: Entry point for the command-line interface.
  • tradeup_optimizer/core/: Core logic for trade-up math and EV calculations.
  • tradeup_optimizer/data_sources/: Clients for fetching skin metadata and prices.
  • tradeup_optimizer/models.py: Pydantic data models for skins and trade-up recipes.

Licensing

This project is licensed under the MIT License. See the LICENSE file for details

Releases

No releases published

Packages

No packages published

Languages