woctezuma / steam-market

Find arbitrages on the Steam Market.
MIT License
160 stars 18 forks source link
steam steam-api steam-cards steam-community-market steam-data steam-economy-enhancer steam-farm steam-inventory steam-market steam-market-search steam-market-util steam-marketplace steam-query steam-tools steam-trading-cards steam-web steam-web-api steam-webapi trading-card trading-cards

Steam Market

![Build status][build-image] Code coverage Code Quality

This repository contains Python code to find arbitrages on the Steam Market.

Cover: ranking of market arbitrages

Arbitrages could consist in:

Requirements

pip install -r requirements.txt

Data acquisition

Cookie

To relax the rate limits enforced by Steam API, fill in your cookie information in a file called personal_info.json:

How to fill in your cookie information

1. To do so, make sure you are connected to your Steam account on a Steam Community page, e.g. [Steam Market](https://steamcommunity.com/market/).
![steam community](https://github.com/woctezuma/steam-market/wiki/img/K0P9Uxu.png) 2. Press `` in your web browser to access the storage section of the developer tools.
![storage section](https://github.com/woctezuma/steam-market/wiki/img/xGfyU7r.png) 3. Use the filtering option (in the top right of the storage section) to find the cookie value for `steamLoginSecure`.
![filter for steamLoginSecure](https://github.com/woctezuma/steam-market/wiki/img/YhlPlUy.png) 4. Copy-paste this cookie value into a new file called `personal_info.json`, which will be read by [`src/personal_info.py`](src/personal_info.py).
```json { "steamLoginSecure": "PASTE_YOUR_COOKIE_VALUE_HERE" } ```

NB: In the future, if you notice that the program bugs out due to seemingly very strict rate limits, then it may be a sign that the cookie value tied to your session has changed. In this case, try to fill in your cookie information with its new value.

NB²: If you want to automate the creation and sale of booster packs, you may need:

  1. to have a mobile authenticator app running in the background and auto-confirming market transactions,
  2. to fill in more cookie information. I have been using the following entries, but you might not need to use all of them. Except for browserid, values need to be updated from time to time.
    {
     "browserid": "PASTE_YOUR_COOKIE_VALUE_HERE",
     "steamDidLoginRefresh": "PASTE_YOUR_COOKIE_VALUE_HERE",
     "sessionid": "PASTE_YOUR_COOKIE_VALUE_HERE",
     "steamLoginSecure": "PASTE_YOUR_COOKIE_VALUE_HERE"
    }

Gem cost for crafting Booster Packs

To have access to the gem cost for crafting Booster Packs, you will need to manually copy information available here.

How to list craftable packs with the Booster Creation webpage

1. Press `` to display the HTML code of [the Booster Creation webpage](https://steamcommunity.com/tradingcards/boostercreator/). 2. At the end of the HTML code, find and copy the line below `CBoosterCreatorPage.Init`:
![javascript list of games](https://github.com/woctezuma/steam-market/wiki/img/JBxJue8.png) 3. Paste the line to `data/booster_game_creator_from_javascript.txt`. 4. Strip mentions of packs unavailable because they were crafted less than 24 hours ago. For instance: ```json {"appid":996580,"name":"Spyro\u2122 Reignited Trilogy","series":1,"price":"400", "unavailable":true,"available_at_time":"4 Sep @ 7:06pm"} ``` should be replaced with: ```json {"appid":996580,"name":"Spyro\u2122 Reignited Trilogy","series":1,"price":"400"} ```

To do so, with Visual Studio Code, press <Ctrl-H> and remove occurrences of :
Visual Studio Code: remove mentions of unavailability

   ,"unavailable":true,"available_at_time":"[\w ]*@[\w :]*"

Usage

python market_buzz_detector.py
python market_gamble_detector.py
python market_arbitrage.py
python market_arbitrage_with_foil_cards.py

Caveat: make sure to manually check the goo value of cards with a tool such as this bookmarklet. Indeed, if an arbitrage with foil cards looks too good to be true, it is likely that the goo value was bugged, because of a wrong item type. It can happen for instance if the goo value actually corresponds to emoticon or a profile background, and was then multiplied by 10 to get the value of the non-existent "foil" version of this emoticon or profile background.

javascript:var a=g_rgAssets[Object.keys(g_rgAssets)[0]],b=a[Object.keys(a)[0]],c=b[Object.keys(b)[0]],gem_action=c.owner_actions&&c.owner_actions.filter(function(d){return/javascript:GetGooValue/.test(d.link)})[0];if(gem_action){var matches=gem_action.link.match(/javascript:GetGooValue\( '%contextid%', '%assetid%', (\d+), (\d+), \d+ \)/);fetch("https://steamcommunity.com/auction/ajaxgetgoovalueforitemtype/?appid="+matches[1]+"&item_type="+matches[2]+"&border_color=0").then(function(d){return d.json()}).then(function(d){alert("This is worth "+d.goo_value+" gems")})["catch"](function(d){return console.error(d)})}else alert("This is worth 0 gems");

Caveat²: the bookmarklet linked above does not account for foil versions, so you should multiply by 10 the goo value if you are interested in foil cards. You can check by yourself that the bookmarklet returns the same goo values for normal cards and for foil cards.

Drop-rate estimates

For the gamble detector, we are interested in drop-rate estimates, when crafting badges, for items of Common rarity.

Based on the data so far (1127 crafted badges):

where:

Therefore, we choose to estimate the drop-rates for Common rarity, conditionally to C/UC/R patterns.
The values hard-coded in src/drop_rate_estimates.py are the centers of the Wilson score intervals with 95% confidence.

Results

The Wiki shows a ranking of packs with high buy orders.

Rankings are also available for gambles with items of "Common" rarity, obtained after crafting a badge:

References

[build-image]: <https://github.com/woctezuma/steam-market/workflows/Python application/badge.svg?branch=master>