Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import json
- import math
- from datetime import datetime
- min_keys = 15
- max_keys = 150
- hat_list = ["Charmer's Chapeau","Le Party Phantom","Fancy Fedora","Aviator Assassin","Hat of Cards","L'homme Burglerre","D\u00e9tective Noir","Frenchman's Beret"]
- current_time = datetime.now()
- percentage = 5
- effect_qs_dict = {'6':'45', #Green Confetti
- '7':'45', #Purple Confetti
- '8':'40', #Haunted Ghosts
- '9':'35', #Green Energy
- '10':'35', #Purple Energy
- '11':'40', #Circling TF Logo
- '12':'45', #Massed Flies
- '13':'35', #Burning Flames
- '14':'35', #Scorching Flames
- '17':'35', #Sunbeams
- '29':'40', #Stormy Storm
- '33':'40', #Orbiting Fire
- '34':'45', #Bubbling
- '35':'45', #Smoking
- '36':'45', #Steaming
- '38':'35', #Cloudy Moon
- '56':'45', #Kill-a-Watt
- '57':'45', #Terror-Watt
- '58':'45', #Cloud 9
- '70':'35', #Time Warp
- '15':'40', #Searing Plasma
- '16':'40', #Vivid Plasma
- '18':'40', #Circling Peace Sign
- '19':'40', #Circling Heart
- '30':'40', #Blizzardy Storm
- '31':'45', #Nuts n' Bolts
- '32':'45', #Orbiting Planets
- '37':'45', #Flaming Lantern
- '39':'45', #Cauldron Bubbles
- '40':'45', #Eerie Orbiting Fire
- '43':'30', #Knifestorm
- '44':'30', #Misty Skull
- '45':'30', #Harvest Moon
- '46':'30', #It's A Secret To Everybody
- '47':'30', #Stormy 13th Hour
- '59':'45', #Aces High
- '60':'45', #Dead Presidents
- '61':'45', #Miami Nights
- '62':'40', #Disco Beat Down
- '63':'40', #Phosphorous
- '64':'40', #Sulphurous
- '65':'45', #Memory Leak
- '66':'45', #Overclocked
- '67':'45', #Electrostatic
- '68':'45', #Power Surge
- '69':'35', #Anti-Freeze
- '71':'35', #Green Black Hole
- '72':'35', #Roboactive
- '73':'30', #Arcana
- '74':'30', #Spellbound
- '75':'30', #Chiroptera Venenata
- '76':'30', #Poisoned Shadows
- '77':'30', #Something Burning This Way Comes
- '78':'30', #Hellfire
- '79':'30', #Darkblaze
- '80':'30', #Demonflame
- '3001':'69', #Showstopper
- '3003':'69', #Holy Grail
- '3004':'69', #'72
- '3005':'69', #Fountain of Delight
- '3006':'69', #Screaming Tiger
- '3007':'69', #Skill Gotten Gains
- '3008':'69', #Midnight Whirlwind
- '3009':'69', #Silver Cyclone
- '3010':'69', #Mega Strike
- '81':'30', #Bonzo The All-Gnawing
- '82':'40', #Amaranthine
- '83':'40', #Stare From Beyond
- '84':'40', #The Ooze
- '85':'30', #Ghastly Ghosts Jr
- '86':'30', #Haunted Phantasm Jr
- '3011':'69', #Haunted Phantasm
- '3012':'69', #Ghastly Ghosts
- '87':'35', #Frostbite
- '88':'45', #Molten Mallard
- '89':'40', #Morning Glory
- '90':'40', #Death at Dusk
- '91':'69', #Abduction
- '92':'69', #Atomic
- '93':'69', #Subatomic
- '94':'69', #Electric Hat Protector
- '95':'69', #Magnetic Hat Protector
- '96':'69', #Voltaic Hat Protector
- '97':'69', #Galactic Codex
- '98':'69', #Ancient Codex
- '99':'35', #Nebula
- '100':'69', #Death by Disco
- '101':'69', #It's a mystery to everyone
- '102':'69', #It's a puzzle to me
- '103':'69', #Ether Trail
- '104':'69', #Nether Trail
- '105':'69', #Ancient Eldritch
- '106':'69', #Eldritch Flame
- '701':'69', #Weapon Effect
- '702':'69', #Weapon Effect
- '703':'69', #Weapon Effect
- '704':'69', #Weapon Effect
- '107':'69', #Neutron Star
- '108':'69', #Tesla Coil
- '109':'69', #Startstorm Slumber
- '110':'69', #Starstorm Insomnia
- '3014':'69', #Spectral Swirl
- '3015':'69', #Infernal Flame
- '3013':'69', #Hellish Inferno
- '3016':'69'} #Infernal Smoke
- price_order_list = ["Burning Flames","Scorching Flames","Sunbeams","Bonzo The All-Gnawing","Spellbound","Arcana","Poisoned Shadows","Chiroptera Venenata","Something Burning This Way Comes","Darkblaze","Hellfire","Demonflame","Knifestorm","Stormy 13th Hour","Harvest Moon","It's A Secret To Everybody","Misty Skull","Cloudy Moon","Ghastly Ghosts Jr","Haunted Phantasm Jr","Roboactive","Anti-Freeze","Purple Energy","Green Energy","Green Black Hole","Time Warp","Frostbite","Sulphurous","Amaranthine","The Ooze","Stare From Beyond","Phosphorous","Morning Glory","Death at Dusk","Disco Beat Down","Circling Heart","Vivid Plasma","Haunted Ghosts","Searing Plasma","Miami Nights","Cloud 9","Stormy Storm","Blizzardy Storm","Circling Peace Sign","Circling TF Logo","Orbiting Fire","Molten Mallard","Eerie Orbiting Fire","Flaming Lantern","Terror-Watt","Kill-a-Watt","Purple Confetti","Green Confetti","Cauldron Bubbles","Smoking","Steaming","Bubbling","Power Surge","Electrostatic","Memory Leak","Overclocked","Aces High","Dead Presidents","Orbiting Planets","Nuts n' Bolts","Massed Flies"]
- effect_dict={'6':'Green Confetti','7':'Purple Confetti','8':'Haunted Ghosts','9':'Green Energy','10':'Purple Energy','11':'Circling TF Logo','12':'Massed Flies','13':'Burning Flames','14':'Scorching Flames','17':'Sunbeams','29':'Stormy Storm','33':'Orbiting Fire','34':'Bubbling','35':'Smoking','36':'Steaming','38':'Cloudy Moon','56':'Kill-a-Watt','57':'Terror-Watt','58':'Cloud 9','70':'Time Warp','15':'Searing Plasma','16':'Vivid Plasma','18':'Circling Peace Sign','19':'Circling Heart','30':'Blizzardy Storm','31':"Nuts n' Bolts",'32':'Orbiting Planets','37':'Flaming Lantern','39':'Cauldron Bubbles','40':'Eerie Orbiting Fire','43':'Knifestorm','44':'Misty Skull','45':'Harvest Moon','46':"It's A Secret To Everybody",'47':'Stormy 13th Hour','59':'Aces High','60':'Dead Presidents','61':'Miami Nights','62':'Disco Beat Down','63':'Phosphorous','64':'Sulphurous','65':'Memory Leak','66':'Overclocked','67':'Electrostatic','68':'Power Surge','69':'Anti-Freeze','71':'Green Black Hole','72':'Roboactive','73':'Arcana','74':'Spellbound','75':"Chiroptera Venenata",'76':'Poisoned Shadows','77':'Something Burning This Way Comes','78':'Hellfire','79':'Darkblaze','80':'Demonflame','3001':'Showstopper','3003':'Holy Grail','3004':'72','3005':'Fountain of Delight','3006':'Screaming Tiger','3007':'Skill Gotten Gains','3008':'Midnight Whirlwind','3009':'Silver Cyclone','3010':'Mega Strike','81':'Bonzo The All-Gnawing','82':'Amaranthine','83':'Stare From Beyond','84':'The Ooze','85':'Ghastly Ghosts Jr','86':'Haunted Phantasm Jr','3011':'Haunted Phantasm','3012':'Ghastly Ghosts','87':'Frostbite','88':'Molten Mallard','89':'Morning Glory','90':'Death at Dusk','91':'Abduction','92':'Atomic','93':'Subatomic','94':'Electric Hat Protector','95':'Magnetic Hat Protector','96':'Voltaic Hat Protector','97':'Galactic Codex','98':'Ancient Codex','99':'Nebula','100':'Death by Disco','101':'Its a mystery to everyone','102':'Its a puzzle to me','103':'Ether Trail','104':'Nether Trail','105':'Ancient Eldritch','106':'Eldritch Flame','701':'Weapon Effect','702':'Weapon Effect','703':'Weapon Effect','704':'Weapon Effect','107':'Neutron Star','108':'Tesla Coil','109':'Startstorm Slumber','110':'Starstorm Insomnia','3014':'Spectral Swirl','3015':'Infernal Flame','3013':'Hellish Inferno','3016':'Infernal Smoke'}
- with open('api_key.txt', 'r') as myfile:
- backpack_api_token = myfile.read().replace('\n', '')
- print('Requesting backpack.tf for prices')
- payload = {'key':backpack_api_token}
- r1 = requests.get('http://backpack.tf/api/IGetPrices/v4',params=payload)
- ret1 = r1.json()
- print('Response Recieved')
- if ret1['response']['success'] == 0:
- print('300 second cooldown in effect, loading old json file')
- with open('response.json') as json_data:
- ret1 = json.load(json_data)
- else:
- with open('response.json', 'w') as outfile:
- json.dump(ret1, outfile)
- open('output.txt', 'w').close()
- with open("output.txt", "a", encoding='utf-8') as myfile:
- myfile.write('[b][color=yellow]HI, IM QUICKBUYING THESE UNUSUALS![/color]\n\n')
- myfile.write('[color=#00FF04]CURRENTLY IN STOCK:[/color] [color=yellow]0[/color] [color=#00FF04]keys and[/color] [color=yellow]0[/color] [color=#00FF04]ref![/color]\n\n')
- myfile.write('[color=yellow]Im quickbuying almost[/color] [color=crimson]ANY[/color] [color=yellow]hat as long as its[/color] [color=crimson]30[/color][color=yellow]/[/color][color=crimson]35%[/color] [color=yellow]off High Tier,[/color] [color=crimson]40%[/color] [color=yellow]off Mid Tier and[/color] [color=crimson]45%[/color] [color=yellow]off Low Tier effects and meets[/color] [color=crimson]ALL[/color] [color=yellow]of my rules![/color]\n')
- myfile.write('[color=crimson]Im[/color] [color=yellow]MOSTLY[/color] [color=crimson]interested in[/color] [color=yellow]100[/color] [color=crimson](and less) key unusuals![/color]\n')
- myfile.write('[color=yellow]Press[/color] [color=crimson]F3[/color] [color=yellow]to search for the unusual you are quickselling![/color]\n')
- myfile.write('[color=crimson]My key stock is limited, so I get to choose the hats I buy![/color]\n')
- myfile.write('[color=yellow]Any unusuals that exceed my key stock cannot be purchased![/color]\n')
- myfile.write('[color=crimson]I always keep my key stock updated![/color]\n')
- myfile.write('[color=yellow]I pretty much always keep the prices listed below in date![/color]\n')
- myfile.write('[color=crimson]I have one of the[/color] [color=yellow]BEST[/color] [color=crimson]prices on the market![/color]\n\n')
- myfile.write('[color=yellow]🔥[/color] [color=crimson]30[/color][color=yellow]/[/color][color=crimson]35%[/color] [color=yellow]off High Tier effects![/color]\n')
- myfile.write('[color=yellow]🔥[/color] [color=crimson]40%[/color] [color=yellow]off Mid Tier effects![/color]\n')
- myfile.write('[color=yellow]🔥[/color] [color=crimson]45%[/color] [color=yellow]off Low Tier effects![/color]\n\n')
- myfile.write('[color=red]RULES:[/color]\n\n')
- myfile.write('[color=crimson]🔥[/color] [color=yellow]I do[/color] [color=crimson]NOT[/color] [color=yellow]buy Robo hats, Taunts and hats with 2016 Halloween effects![/color]\n')
- myfile.write('[color=crimson]🔥[/color] [color=yellow]If your unusual is[/color] [color=crimson]DUPED[/color][color=yellow], I will pay additional[/color] [color=crimson]10%[/color] [color=yellow]less![/color]\n[color=crimson]🔥[/color] [color=yellow]If your unusual costs over[/color] [color=crimson]100[/color] [color=yellow]keys, I will pay additional[/color] [color=crimson]5%[/color] [color=yellow]less![/color]\n')
- myfile.write('[color=crimson]🔥[/color] [color=yellow]If your unusual costs over[/color] [color=crimson]150[/color] [color=yellow]keys, I will[/color] [color=crimson]NOT[/color] [color=yellow]buy it![/color]\n')
- myfile.write('[color=crimson]🔥[/color] [color=yellow]If your hat is overpriced[/color][color=crimson]/[/color][color=yellow]inflated[/color][color=crimson]/[/color][color=yellow]outdated, i will[/color] [color=crimson]NOT[/color] [color=yellow]value it at current bp.tf price (i will most likely value it lower)![/color]\n\n')
- myfile.write('[color=yellow]Send me a trade offer here:[/color][/b] https://steamcommunity.com/tradeoffer/new/?partner=134757237&token=A-Bi9UpQ\n')
- myfile.write('[color=crimson]-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------[/color]\n')
- for name,prices in ret1['response']['items'].items():
- for qualtiy,values in prices['prices'].items():
- if qualtiy == '5':
- check_list = price_order_list
- price_check_dict = {}
- for check_effect in check_list:
- for chk_name,chk_prices in ret1['response']['items'].items():
- for chk_qualtiy,chk_values in chk_prices['prices'].items():
- if chk_qualtiy == '5' and 'Craftable' in chk_values['Tradable'].keys() and chk_name == name:
- if isinstance(chk_values['Tradable']['Craftable'],dict):
- for chk_effect,chk_price in chk_values['Tradable']['Craftable'].items():
- if chk_name in hat_list and chk_effect in effect_qs_dict.keys():
- if chk_price['currency'] == 'keys':
- chk_low = chk_price['value']
- if 'value_high' in chk_price.keys():
- chk_high = chk_price['value_high']
- else:
- chk_high = chk_low
- chk_avg_price = (chk_high + chk_low) / 2
- chk_last_updated = datetime.fromtimestamp(chk_price['last_update'])
- chk_delta = current_time - chk_last_updated
- #print(chk_name+name+effect_dict[chk_effect]+check_effect)
- if chk_name == name and effect_dict[chk_effect] == check_effect:
- price_check_dict[effect_dict[chk_effect]] = (chk_avg_price,chk_delta.days)
- indate_list = []
- for effect_name in price_order_list:
- if effect_name in price_check_dict.keys():
- if price_check_dict[effect_name][1] < 90:
- indate_list.append([effect_name,price_check_dict[effect_name][0],price_check_dict[effect_name][1]])
- #print(name)
- remove_list = []
- for i in range(len(indate_list)):
- for j in range(i):
- #print(i,j)
- if indate_list[i][1] > indate_list[j][1]:
- remove_list.append(indate_list[i])
- break
- for item in remove_list:
- indate_list.remove(item)
- if indate_list:
- max_predicted_value = indate_list[0][1]
- else:
- max_predicted_value = 0
- for i in range(len(indate_list) - 1):
- distance = price_order_list.index(indate_list[i+1][0]) - price_order_list.index(indate_list[0][0])
- predicted_value = indate_list[i+1][1] * ((1+percentage/100)**distance)
- if predicted_value < max_predicted_value:
- max_predicted_value = (max_predicted_value + predicted_value) / 2
- if name in hat_list:
- with open("output.txt", "a", encoding='utf-8') as myfile:
- myfile.write('\n[b][color=#00FF04]'+name+'[/color][/b]\n\n')
- if 'Craftable' in values['Tradable'].keys():
- if isinstance(values['Tradable']['Craftable'],dict):
- with open("output.txt", "a", encoding='utf-8') as myfile:
- myfile.write('[color=red]High Tier:[/color]\n\n')
- for effect,price in values['Tradable']['Craftable'].items():
- if price['currency'] == 'keys' and effect_qs_dict[str(effect)] == '35':
- low = price['value']
- if 'value_high' in price.keys():
- high = price['value_high']
- else:
- high = low
- avg_price = (high + low) / 2
- last_updated = datetime.fromtimestamp(price['last_update'])
- delta = current_time - last_updated
- if indate_list:
- distance = price_order_list.index(indate_list[0][0]) - price_order_list.index(effect_dict[effect])
- if distance < 0:
- predicted_price = max_predicted_value * ((1-(percentage/100))**abs(distance))
- else:
- predicted_price = max_predicted_value * ((1+(percentage/100))**abs(distance))
- #print(name,effect_dict[effect],'Bp.tf price - ' + str(avg_price),'Predicted price - '+str(predicted_price),distance)
- if predicted_price < avg_price:
- avg_price = predicted_price
- #print(name,effect_dict[effect],avg_price, distance)
- if avg_price > min_keys and avg_price < max_keys:
- if avg_price > 100:
- qs_price = int(avg_price * (100 - int(effect_qs_dict[effect] )- 5) / 100)
- else:
- qs_price = int(avg_price * (100 - int(effect_qs_dict[effect])) / 100)
- if qs_price < 7:
- qs_price = 7
- if qs_price < 150:
- with open("output.txt", "a", encoding='utf-8') as myfile:
- myfile.write(effect_dict[str(effect)]+' - '+str(qs_price)+' keys'+'\n')
- with open("output.txt", "a", encoding='utf-8') as myfile:
- myfile.write('\n[color=crimson]-------------------------------------------------------------------------------[/color]\n\n[color=orange]Mid Tier:[/color]\n\n')
- for effect,price in values['Tradable']['Craftable'].items():
- if price['currency'] == 'keys' and effect_qs_dict[str(effect)] == '40':
- low = price['value']
- if 'value_high' in price.keys():
- high = price['value_high']
- else:
- high = low
- avg_price = (high + low) / 2
- last_updated = datetime.fromtimestamp(price['last_update'])
- delta = current_time - last_updated
- if indate_list:
- distance = price_order_list.index(indate_list[0][0]) - price_order_list.index(effect_dict[effect])
- if distance < 0:
- predicted_price = max_predicted_value * ((1-(percentage/100))**abs(distance))
- else:
- predicted_price = max_predicted_value * ((1+(percentage/100))**abs(distance))
- if predicted_price < avg_price:
- avg_price = predicted_price
- #print(name,effect_dict[effect],avg_price, distance)
- if avg_price > min_keys and avg_price < max_keys:
- if avg_price > 100:
- qs_price = int(avg_price * (100 - int(effect_qs_dict[effect] )- 5) / 100)
- else:
- qs_price = int(avg_price * (100 - int(effect_qs_dict[effect])) / 100)
- if qs_price < 7:
- qs_price = 7
- if qs_price < 150:
- with open("output.txt", "a", encoding='utf-8') as myfile:
- myfile.write(effect_dict[str(effect)]+' - '+str(qs_price)+' keys'+'\n')
- with open("output.txt", "a", encoding='utf-8') as myfile:
- myfile.write('\n[color=crimson]-------------------------------------------------------------------------------[/color]\n\n[color=orange]Low Tier:[/color]\n\n')
- for effect,price in values['Tradable']['Craftable'].items():
- if price['currency'] == 'keys' and effect_qs_dict[str(effect)] == '45':
- low = price['value']
- if 'value_high' in price.keys():
- high = price['value_high']
- else:
- high = low
- avg_price = (high + low) / 2
- last_updated = datetime.fromtimestamp(price['last_update'])
- delta = current_time - last_updated
- if indate_list:
- distance = price_order_list.index(indate_list[0][0]) - price_order_list.index(effect_dict[effect])
- if distance < 0:
- predicted_price = max_predicted_value * ((1-(percentage/100))**abs(distance))
- else:
- predicted_price = max_predicted_value * ((1+(percentage/100))**abs(distance))
- if predicted_price < avg_price:
- avg_price = predicted_price
- #print(name,effect_dict[effect],avg_price, distance)+
- if avg_price > min_keys and avg_price < max_keys:
- if avg_price > 100:
- qs_price = int(avg_price * (100 - int(effect_qs_dict[effect] )- 5) / 100)
- else:
- qs_price = int(avg_price * (100 - int(effect_qs_dict[effect])) / 100)
- if qs_price < 7:
- qs_price = 7
- if qs_price < 150:
- with open("output.txt", "a", encoding='utf-8') as myfile:
- myfile.write(effect_dict[str(effect)]+' - '+str(qs_price)+' keys'+'\n')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement