Skip to content

Commit

Permalink
add config and run handling to support ignoring auction house / bazaa…
Browse files Browse the repository at this point in the history
…r stuff
  • Loading branch information
MyNameIsRomayne committed Aug 25, 2024
1 parent a6b880b commit f23f0cb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
2 changes: 2 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
always_revalidate_key = False # use this if you expect your keys to be invalidated a lot
announce_queries = False # debug option, print on each query to debug query optimizaiton
disable_cooldown_limiters = True # For having auction house data load faster. Disable if you keep hitting rate limits
include_auction_house = True # In case you dont feel like doing AH stuff
include_bazaar = True # I dunno but i guess
cooldown_request_seconds = 1 # 300 per 5mins is listed via API, so 1 per second is compliant

json_key_api_key = "api_key"
Expand Down
22 changes: 15 additions & 7 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,15 @@ def get_item_bz_price(product_data):

api.info()

bz = Bazaar(api)
if not include_bazaar and not include_auction_house:
print("No source to compare prices with. Please enable either the auction house and/or the bazaar.")

ah = AuctionHouse(api)
if include_bazaar:
bz = Bazaar(api)

ah_items = ah.get_items_keyed_by("item_name")
if include_auction_house:
ah = AuctionHouse(api)
ah_items = ah.get_items_keyed_by("item_name")

item_data = []

Expand All @@ -52,25 +56,29 @@ def get_item_bz_price(product_data):
coins_for_product = 0
coins_per_bit = 0
ah_entries = 0
if product_id != None:
is_auction_house_item = False
if include_bazaar and (product_id != None):
coins_for_product = get_item_bz_price(bz.whole_bazaar_data["products"][product_id])
coins_for_product *= (1 - BAZAAR_TAX)
elif (item_key in ah_items.keys()):
elif include_auction_house and (item_key in ah_items.keys()):
is_auction_house_item = True
ah_entries = len(ah_items[item_key])
coins_for_product = get_item_ah_price(item_key, ah_items)
# Fees (Listing BIN)
coins_for_product -= get_profits_fee(coins_for_product)
# Fees (Duration)
coins_for_product -= AUCTION_HOUSE_FEE
else:
continue

coins_per_bit = coins_for_product / bit_items[item_key]["cost_bits"]

item_data.append({
"item_name": item_key,
"coins_per_bit": round(coins_per_bit, 2),
"coins_for_product": round(coins_for_product, 2),
"on_ah": product_id == None,
"ah_entries": ah_entries
"on_ah": is_auction_house_item,
"ah_entries": ah_entries,
})

item_data.sort(key=(lambda s: s["coins_per_bit"]), reverse=True)
Expand Down

0 comments on commit f23f0cb

Please sign in to comment.