Skip to content

Commit

Permalink
feat(main): Add ability to change acceptable steam min volume #22
Browse files Browse the repository at this point in the history
Signed-off-by: hldh214 <hldh214@gmail.com>
  • Loading branch information
hldh214 committed Oct 31, 2023
1 parent 71f7f74 commit 3705e10
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ docker run -it --name buff2steam --rm -v $PWD/config.json:/app/config.json ghcr.
"game": "csgo", // dota2
"game_appid": "730", // 570
"accept_buff_threshold": 0.65, // acceptable ratio
"accept_steam_threshold": 0.8, // acceptable maximum ratio before fetching prices (in case of Steam API ratelimit)
"min_volume": 0, // minimal number of sales in 24 hours for an item to be viable
"min_price": 500, // CNY, 500 == 5 yuan
"max_price": 30000 // CNY, 30000 == 300 yuan
},
Expand All @@ -120,8 +122,6 @@ docker run -it --name buff2steam --rm -v $PWD/config.json:/app/config.json ghcr.
}
},
"steam": {
"min_volume": 0, //minimal number of sales in 24 hours for an item to be viable
"min_ration_for_buyorder": 1, //minimal ration before checking buy order prices
"request_interval": 4, // steam api request interval (in seconds)
"requests_kwargs": {
"headers": {
Expand Down
16 changes: 7 additions & 9 deletions buff2steam/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from buff2steam.provider.steam import Steam


async def main_loop(buff, steam, min_volume, min_ration_for_buyorder):
async def main_loop(buff, steam):
total_page = await buff.get_total_page()
visited = set()
for each_page in range(1, total_page + 1):
Expand Down Expand Up @@ -40,17 +40,17 @@ async def main_loop(buff, steam, min_volume, min_ration_for_buyorder):
continue

volume = price_overview_data['volume']
if min_volume > volume:
logger.debug(f'{market_hash_name}: volume: {min_volume} > {volume}, skipping.')
min_volume = config['main']['min_volume']
if volume < min_volume:
logger.debug(f'{market_hash_name}: volume: {volume} < {min_volume}, skipping.')
continue

current_ratio = buff_min_price / (price_overview_data['price'] / (1 + steam.fee_rate))
buff_min_price_human = float(buff_min_price / 100)

orders_data = None
if volume > 0:
if current_ratio < min_ration_for_buyorder:
orders_data = await steam.orders_data(market_hash_name)
if current_ratio < config['main']['accept_steam_threshold']:
orders_data = await steam.orders_data(market_hash_name)

result = [
f'buff_id/price: {item["id"]}/{buff_min_price_human};',
Expand All @@ -71,8 +71,6 @@ async def main_loop(buff, steam, min_volume, min_ration_for_buyorder):
async def main():
try:
while True:
min_volume = config['steam']['min_volume']
min_ration_for_buyorder = config['steam']['min_ration_for_buyorder']
async with Buff(
game=config['main']['game'],
game_appid=config['main']['game_appid'],
Expand All @@ -83,7 +81,7 @@ async def main():
request_interval=config['steam']['request_interval'],
request_kwargs=config['steam']['requests_kwargs'],
) as steam:
await main_loop(buff, steam, min_volume, min_ration_for_buyorder)
await main_loop(buff, steam)
except KeyboardInterrupt:
exit('Bye~')

Expand Down
4 changes: 2 additions & 2 deletions config.sample.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"game": "dota2",
"game_appid": "570",
"accept_buff_threshold": 0.65,
"accept_steam_threshold": 0.8,
"min_volume": 0,
"min_price": 500,
"max_price": 30000
},
Expand All @@ -19,8 +21,6 @@
}
},
"steam": {
"min_volume": 0,
"min_ration_for_buyorder": 1,
"request_interval": 4,
"requests_kwargs": {
"headers": {
Expand Down

0 comments on commit 3705e10

Please sign in to comment.