$20.00
$15.00
$5.00
$30.00
Bryce Journey
United States
Omaha
Nebraska
flag msg tools
designer
mbmbmbmbmb
There used to be a tool that would calculate the value of one's collection as entered in BGG. Old links to that tool no longer appear to work. Does anyone know what happened to this handy little tool? Was it removed during the site upgrade or is it hiding somewhere?
 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Justin Case
United States
Greensboro
North Carolina
flag msg tools
mbmbmbmbmb

That hasn't been running for quite a while now, and the fellow took the link(s) down, I'm pretty sure. He still has the collection rarity checker, but the collection value tool is no longer on the page.

 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Scott Walker
United States
Bolingbroke
Georgia
flag msg tools
mbmbmbmbmb
I have hacked -- ok, seriously hacked -- a python script that will print out a user's collection value. Tossed it together in Python 3 under Linux. It's not very long, so I'm going to just paste the code in here, and let folks have fun with it. It uses Crustymonkey's PY-BGG package, which you can get from github here:
https://github.com/crustymonkey/py-bgg
I didn't install it as his instructions said; I placed "libbgg" in a directory underneath where I had my python code, and that seemed to work fine from the command line. For example:

cd /home/mine
mkdir bggvalue
cd bggvalue
------> Now, paste in the code below into a file called "bggvalue.py"
------>Then, copy the "libbgg" direcory from github into this directory

To run, first edit the bggvalue.py file, look for USERNAME, and change that to the BGG user name you want collection value for. I left my username in there as an example.
Then, just type:
python3 bggvalue.py

And sit back and let it talk to BGG a bit. Like I said, it isn't pretty, but it works. It only looks at the average US marketplace values. I may devote some time to prettying it up, but feel free to copy the code below and do what you want with it!


------------------------------ cut here, save as bggvalue.py
import time
from libbgg.apiv1 import BGG as BGG1
from libbgg.apiv2 import BGG as BGG2

connection1 = BGG1()
connection2 = BGG2()

# Change this to the user you want collection information on!
USERNAME = 'LKOsiliconMage'


def CalcValue(glist):
global gameswithoutvalue
global gameswithvalue
global averagegamevalue
global totalgamevalue

for glitem in glist:
gameid = glitem['id']

if (isinstance(glitem['name'], dict)):
gamename = glitem['name']['value']
else:
gamename = glitem['name'][0]['value']

print(gameid, ', ', gamename, ' ==> ', end='')

if ('marketplacelistings' in glitem):
marketplace = glitem['marketplacelistings']
else:
marketplace = None

if (marketplace != None):
n = 0
vsum = 0

mp = marketplace['listing']
# PROBLEM! mp is usually a LIST, but if it has only one entry, it becomes a DICTIONARY of mlitem!!!!!
if (isinstance(mp, dict)):
# Convert dictionary to list one dictionary, for consistency later
mp = []
mp.append(marketplace['listing'])

for mlitem in mp:
mlprice = mlitem['price']

if (mlprice['currency'] == 'USD'):
mldate = mlitem['listdate']['value']
mlvalue = float(mlprice['value'])
n += 1
vsum += mlvalue

if (n > 0):
vavg = vsum / n
gameswithvalue += 1
totalgamevalue += vavg
print('Average market value = ', '{:.2f}'.format(vavg))
else:
gameswithoutvalue += 1
print('No U.S. marketplace info.')
else:
gameswithoutvalue += 1
print('No marketplace info.')

##########################################################################################

# Gather user's game collection that is owned
print('Requesting collection info from BGG. This may take some time.')
gamecollection = connection1.get_collection(USERNAME, own = 1)
print('Collection details retrieved.')
if (gamecollection != None):
gamelist = gamecollection['items']['item'] # isolate game information

print('Total items in collection: ', len(gamelist))

# Gather boardgame ids; games and expansions
boardgameids = []
for glitem in gamelist:
gameid = glitem['objectid']
boardgameids.append(gameid)

# Request boardgame details from bgg
print('Requesting board game details from BGG. This may take some time.')
boardgameinfo = connection2.boardgame(boardgameids, marketplace=1)
boardgames = boardgameinfo['items']['item'] # isolate game information
print('Board game details retrieved. Total board games: ', len(boardgames))

# Request board game expansion details from bgg
print('Requesting board game expansion details from BGG. This may take some time.')
boardgameexpansioninfo = connection2.boardgameexpansion(boardgameids, marketplace=1)
boardgameexpansions = boardgameexpansioninfo['items']['item'] # isolate game information
print('Board game expansion details retrieved. Total board games expansions: ', len(boardgameexpansions))

# Calculate collection value
gameswithoutvalue = 0
gameswithvalue = 0
averagegamevalue = 0;
totalgamevalue = 0;

print('Calculating board game values.')
CalcValue(boardgames)
print('Calculating board game expansion values.')
CalcValue(boardgameexpansions)
print()

# All done! What's it worth?
if (gameswithvalue > 0) :
averagegamevalue = totalgamevalue / gameswithvalue
print('Collection Value...')
print('Number of games: ', len(gamelist))
print('Number of games with a value: ', gameswithvalue)
print('Number of games without a value: ', gameswithoutvalue)
print('Total game value: ', '{:.2f}'.format(totalgamevalue))
print('Average game value: ', '{:.2f}'.format(averagegamevalue))
3 
 Thumb up
2.00
 tip
 Hide
  • [+] Dice rolls
Jay D
United States
Washington
flag msg tools
mbmbmbmbmb
Nice! This is similar to what I do here: https://games.splitstreams.com/?u=LKOsiliconMage
1 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
that Matt
United States
Ann Arbor
Michigan
flag msg tools
I'm a quitter. I come from a long line of quitters. It's amazing I'm here at all.
badge
I can feel bits of my brain falling away like wet cake.
mbmbmbmbmb
LKOsiliconMage wrote:
It uses Crustymonkey's PY-BGG package, which you can get from github here:
https://github.com/crustymonkey/py-bgg
I didn't install it as his instructions said; I placed "libbgg" in a directory underneath where I had my python code, and that seemed to work fine from the command line. For example:

cd /home/mine
mkdir bggvalue
cd bggvalue
------> Now, paste in the code below into a file called "bggvalue.py"
------>Then, copy the "libbgg" direcory from github into this directory

To be clear for people who'd rather take the easy library install, that'd be: pip install py-bgg



1 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
that Matt
United States
Ann Arbor
Michigan
flag msg tools
I'm a quitter. I come from a long line of quitters. It's amazing I'm here at all.
badge
I can feel bits of my brain falling away like wet cake.
mbmbmbmbmb
LKOsiliconMage wrote:
USERNAME = 'LKOsiliconMage'

So your script works great from Windows command line minus the dreaded

57390 , Catacombs ==> Average market value = 96.33
67239 , Traceback (most recent call last):
File "C:\...\bggvalue.py", line 101, in <module>
CalcValue(boardgames)
File "C:\...\bggvalue.py", line 26, in CalcValue
print(gameid, ', ', gamename, ' ==> ', end='')
File "C:\Program Files (x86)\Python35-32\lib\encodings\cp437.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u2013' in position 37: character maps to <undefined>


Yes, it's choking on the character '–'

Someone bothering to read this far can probably fix more properly, but I the script runs just fine once I stuff in sys.stdout.encoding thusly:

Line 1 replace
import time
with
import sys # p.s. you didn't actually use time ;)

Line 25 replace
print(gameid, ', ', gamename, ' ==> ', end='')
with
try:
print(gameid, ', ', gamename, ' ==> ', end='')
except UnicodeEncodeError:
print(gameid, ', ', gamename.encode(sys.stdout.encoding, errors='replace'), ' ==> ', end='')


That said, working from listings instead of actually sold prices leads to certain issues. Like the guy selling a Magic the Gathering collection for $100,000 creating a $5,619.39 "market value" for anyone owning any MtG...
1 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Scott Walker
United States
Bolingbroke
Georgia
flag msg tools
mbmbmbmbmb
Good points!
I don't get the Unicode error; I'm gonna blame Windows, as I don't have a Windows box to test with. Cue cliche "works fine on my machine" excuse!

Oops, the time import is from my first shot at this while I figured out the data, which used very inefficient BGG calls, and needed throttling. No longer needed once I combined the BGG calls.

Hmmm, you're saying I need to look at the market listing data better. I didn't realize what I grabbed wasn't completed sales. Nor did I think of the case of a collection within the collection, as with MtG or Heroclix. I was kind of imagining how the old web-based tool might have worked. This is what happens when I throw a script together...

I'll look into the market stuff and see if I can fix the MtG issue.
1 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Scott Walker
United States
Bolingbroke
Georgia
flag msg tools
mbmbmbmbmb
Well, I came across this:
https://boardgamegeek.com/thread/427153/great-new-web-app-ga...
Which still works, so I know it is possible to filter by actual sold items, but I didn't see how after a cursory look through the data. Hopefully I'll have some more time during Christmas break to dig into this and fix it!
 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Hector L.
United States
Illinois
flag msg tools
Is there a simpler user guide?
 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Oriol Vilanova
Spain
Les Franqueses
Barcelona
flag msg tools
mbmbmbmbmb
Hi! how good of a tool! I've been looking for something like this every now and then...

I post a slightly modified version of your code here. I just implemented a function that allows to take the average over every entry in the marketplace by converting the different currencies to USD, so the prices are more significative.
* Please note that the currency exchange rates are hardcoded, so they need to be updated by hand periodically... These could be easily retrieved automatically, from e.g. www.xe.com.


Also, I modified the print format for better readability (100% mispelled for sure)

It would be great if we create a github page with this code, so other people interested in this, contributes?

Thanks and good job!

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ bggvalue.py ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

import time
from libbgg.apiv1 import BGG as BGG1
from libbgg.apiv2 import BGG as BGG2

connection1 = BGG1()
connection2 = BGG2()

# Change this to the user you want collection information on!
USERNAME = 'YOUR_USERNAME_HERE'


def toUSD(currency, amount):
dollar = 0
if currency == 'USD':
dollar = amount*1.00
elif currency == 'EUR':
dollar = amount*1.04
elif currency == 'GBP':
dollar = amount*1.23
elif currency == 'AUD':
dollar = amount*0.72
elif currency == 'CAD':
dollar = amount*0.75
return dollar




def CalcValue(glist):
global gameswithoutvalue
global gameswithvalue
global averagegamevalue
global totalgamevalue

for glitem in glist:
gameid = glitem['id']

if (isinstance(glitem['name'], dict)):
gamename = glitem['name']['value']
else:
gamename = glitem['name'][0]['value']

print("%s\t%30s\t" % (gameid.strip(), (gamename.strip())[:30]), end='' )

if ('marketplacelistings' in glitem):
marketplace = glitem['marketplacelistings']
else:
marketplace = None

if (marketplace != None):
n = 0
vsum = 0

mp = marketplace['listing']
# PROBLEM! mp is usually a LIST, but if it has only one entry, it becomes a DICTIONARY of mlitem!!!!!
if (isinstance(mp, dict)):
# Convert dictionary to list one dictionary, for consistency later
mp = []
mp.append(marketplace['listing'])

for mlitem in mp:
mlprice = mlitem['price']

if (mlprice['currency'] in ['USD','EUR','GBP','AUD','CAD']):
mldate = mlitem['listdate']['value']
mlvalue = toUSD(mlprice['currency'], float(mlprice['value']))
n += 1
vsum += mlvalue

if (n > 0):
vavg = vsum / n
gameswithvalue += 1
totalgamevalue += vavg
print('%3d' % n, 'items\tUSD', '{:.2f}'.format(vavg))
else:
gameswithoutvalue += 1
print('No U.S. marketplace info.')
else:
gameswithoutvalue += 1
print('No info.')

##########################################################################################

# Gather user's game collection that is owned
print('Requesting collection info from BGG. This may take some time.')
gamecollection = connection1.get_collection(USERNAME, own = 1)
print('Collection details retrieved.')
if (gamecollection != None):
gamelist = gamecollection['items']['item'] # isolate game information

print('Total items in collection: ', len(gamelist))

# Gather boardgame ids; games and expansions
boardgameids = []
for glitem in gamelist:
gameid = glitem['objectid']
boardgameids.append(gameid)

# Request boardgame details from bgg
print('Requesting board game details from BGG. This may take some time.')
boardgameinfo = connection2.boardgame(boardgameids, marketplace=1)
boardgames = boardgameinfo['items']['item'] # isolate game information
print('Board game details retrieved. Total board games: ', len(boardgames))

# Request board game expansion details from bgg
print('Requesting board game expansion details from BGG. This may take some time.')
boardgameexpansioninfo = connection2.boardgameexpansion(boardgameids, marketplace=1)
boardgameexpansions = boardgameexpansioninfo['items']['item'] # isolate game information
print('Board game expansion details retrieved. Total board games expansions: ', len(boardgameexpansions))

# Calculate collection value
gameswithoutvalue = 0
gameswithvalue = 0
averagegamevalue = 0;
totalgamevalue = 0;

print('ID', '%30s' % 'Name', '\tMarket\t\tAverage Value')
#print('Calculating board game values.')
CalcValue(boardgames)
#print('Calculating board game expansion values.')
CalcValue(boardgameexpansions)
print()

# All done! What's it worth?
if (gameswithvalue > 0) :
averagegamevalue = totalgamevalue / gameswithvalue
print('Collection Value...')
print('Number of games: ', len(gamelist))
print('Number of games with a value: ', gameswithvalue)
print('Number of games without a value: ', gameswithoutvalue)
print('Total game value: ', '{:.2f}'.format(totalgamevalue))
print('Average game value: ', '{:.2f}'.format(averagegamevalue))
2 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Front Page | Welcome | Contact | Privacy Policy | Terms of Service | Advertise | Support BGG | Feeds RSS
Geekdo, BoardGameGeek, the Geekdo logo, and the BoardGameGeek logo are trademarks of BoardGameGeek, LLC.