{"id":33317789,"url":"https://github.com/kzon94/torn-market-analyzer","last_synced_at":"2026-04-11T11:02:11.690Z","repository":{"id":323545490,"uuid":"1093695840","full_name":"kzon94/torn-market-analyzer","owner":"kzon94","description":"Streamlit app that parses Torn Add Listing text, matches items with a custom dictionary, fetches market data via the public API, and generates KPIs and price recommendations using a modular Python analytics pipeline.","archived":false,"fork":false,"pushed_at":"2026-02-17T10:01:55.000Z","size":990,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-17T14:39:52.460Z","etag":null,"topics":["data-analysis","data-engineering","fuzzy-matching","market-analytics","numpy","pandas","python","streamlit","torn-city","torn-city-api"],"latest_commit_sha":null,"homepage":"https://torn-market-analyzer.streamlit.app/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kzon94.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-11-10T18:03:03.000Z","updated_at":"2026-02-17T10:46:50.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/kzon94/torn-market-analyzer","commit_stats":null,"previous_names":["kzon94/torn-market-analyzer"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/kzon94/torn-market-analyzer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kzon94%2Ftorn-market-analyzer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kzon94%2Ftorn-market-analyzer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kzon94%2Ftorn-market-analyzer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kzon94%2Ftorn-market-analyzer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kzon94","download_url":"https://codeload.github.com/kzon94/torn-market-analyzer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kzon94%2Ftorn-market-analyzer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31677819,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-11T08:18:19.405Z","status":"ssl_error","status_checked_at":"2026-04-11T08:17:08.892Z","response_time":54,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-analysis","data-engineering","fuzzy-matching","market-analytics","numpy","pandas","python","streamlit","torn-city","torn-city-api"],"created_at":"2025-11-19T18:00:21.174Z","updated_at":"2026-04-11T11:02:11.685Z","avatar_url":"https://github.com/kzon94.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Torn Market Analyzer\r\n\r\n**Torn Market Analyzer** is a Python + Streamlit tool to help you price **Item Market** listings in the online game **Torn**.\r\n\r\nYou paste the raw text from Torn’s **Item Market -\u003e Add Listing** page, the app matches items to Torn item IDs using a local dictionary, fetches up to the first **100 sell listings** per item from Torn’s **v2 API**, cleans the order book, and outputs **three market-aware price suggestions** per item.\r\n\r\n\r\n\r\n## Output\r\n\r\nFor each matched item, the app suggests:\r\n\r\n- **Fast-sell price** (optimized for quick execution)\r\n- **Fair price** (robust central estimate)\r\n- **Greedy price** (upper-quartile strategy)\r\n\r\nThe UI also shows parsed items, unmatched items, and market diagnostics.\r\n\r\n\r\n\r\n## How it works\r\n\r\n### 1) Parsing \u0026 matching\r\n\r\n- Paste the text copied from Torn’s **Add Listing** page.\r\n- The parser extracts **item names** and **quantities**.\r\n- Lines tagged as **Equipped** or **Untradable** are ignored.\r\n- Item names are resolved through a local dictionary:\r\n  - `data/torn_item_dictionary.csv` (columns: `key`, `id`)\r\n\r\n\u003e Matching is **dictionary-based**. Unmatched items are displayed in the UI.\r\n\r\n### 2) Market fetch (read-only)\r\n\r\n- Calls Torn v2 endpoint: `GET /market/{item_id}/itemmarket`\r\n- Loads up to **100 sell listings** per item (`price`, `amount`).\r\n- Uses a simple **token-bucket rate limiter** to stay under Torn’s request limits.\r\n\r\n### 3) Market cleaning \u0026 market-type detection\r\n\r\nPer item, the order book is processed as follows:\r\n\r\n- Sort by price and compute **cumulative quantity** (market depth).\r\n- Estimate robust center/spread using **median** and **MAD** (median absolute deviation).\r\n- Flag extreme prices using a **robust z-score**.\r\n- Detect **thin / exclusive** markets when either:\r\n  - total clean units ≤ **200**, or\r\n  - a single price level represents ≥ **50%** of the clean volume.\r\n- Remove suspected **anchor listings** for pricing (unless removal would leave no data).\r\n\r\n### 4) Price suggestions\r\n\r\nAll prices are computed from the **cleaned** order book:\r\n\r\n- **Fair price**\r\n  - Weighted median (normal markets) or unweighted median (thin/exclusive markets)\r\n- **Greedy price**\r\n  - Upper quartile (Q3), weighted or unweighted depending on market type\r\n- **Fast-sell price**\r\n  - Thin/exclusive markets: around the **3rd cheapest** clean listing\r\n  - Unit-style markets: around the **10th cheapest** clean listing\r\n  - Bulk markets: first price where cumulative clean depth reaches **100 units** (or full depth if \u003c 100)\r\n  - **Undercut by $1 only in bulk markets**\r\n\r\n\r\n\r\n## Project structure\r\n\r\n```\r\n\r\ntorn-market-analyzer/\r\n├─ app/\r\n│  └─ streamlit_app.py\r\n├─ src/\r\n│  └─ tma/\r\n│     ├─ inventory_matcher.py\r\n│     ├─ market_enrichment.py\r\n│     └─ **init**.py\r\n├─ data/\r\n│  └─ torn_item_dictionary.csv\r\n├─ tools/\r\n│  ├─ dictionary_v2.py\r\n│  └─ output/\r\n│     ├─ torn_items_v2.json\r\n│     └─ torn_item_dictionary.csv\r\n├─ requirements.txt\r\n└─ README.md\r\n\r\n````\r\n\r\n\r\n\r\n## Requirements\r\n\r\n- Python **3.10+**\r\n- Install dependencies from `requirements.txt`\r\n\r\n\r\n\r\n## Run locally\r\n\r\n```bash\r\npip install -r requirements.txt\r\nstreamlit run app/streamlit_app.py\r\n````\r\n\r\nOpen the local URL shown in the terminal (typically `http://localhost:8501`).\r\n\r\n\r\n\r\n## Regenerate the item dictionary\r\n\r\nIf Torn adds/renames items, regenerate the dictionary from the API:\r\n\r\n```bash\r\npython tools/dictionary_v2.py\r\n```\r\n\r\nThe script saves:\r\n\r\n* `tools/output/torn_items_v2.json`\r\n* `tools/output/torn_item_dictionary.csv`\r\n\r\nCopy the generated CSV into `data/torn_item_dictionary.csv` for the app to use the refreshed dictionary.\r\n\r\n\r\n\r\n## Torn API usage \u0026 privacy\r\n\r\n* Uses a **public (read-only)** Torn API key.\r\n* Performs **read-only** requests to the Item Market endpoint.\r\n* No keys or market data are transmitted anywhere except directly to Torn.\r\n* The key is stored only in Streamlit session state while the app is running.\r\n\r\n\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkzon94%2Ftorn-market-analyzer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkzon94%2Ftorn-market-analyzer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkzon94%2Ftorn-market-analyzer/lists"}