futapi / fut

fut is a simple library for managing Fifa 19 Ultimate Team.
GNU General Public License v3.0
317 stars 138 forks source link

Level #252

Closed spacedlevo closed 7 years ago

spacedlevo commented 7 years ago

I have been using the library to create a little personal FUTBIN.

One of functions I am writing with your library is to try and return to me the value of my squad based on the current market. The problem that I have got currently is returning the price for variations of players. So e.g. I have an IF Suso and I want to know what his market value is. My function is currently using the AssetID returned to me when I ask for the club list to then go into the searchAuction function to return a list of prices. But it seems that when I am search for Suso I am getting back the BIN values for normal Suso when I was just IF and I don't want to have to hardcode the level.

Just want to know if there is a way to add to the returned dictionary the type of card it is?

j-stone commented 7 years ago

you need to search the transfer market using the resourceId, not the assetId

spacedlevo commented 7 years ago

you need to search the transfer market using the resourceId, not the assetId

I don't see any ability to directly search for resourceId. I have been trying a function:

def find_BIN(assetId, resourceId):
    BIN = list()
    search = fut.searchAuctions(ctype='player', assetId=assetId, page_size=50)
    for player in search:
        if player['resourceId'] == resourceId:
            BIN.append(player['buyNowPrice'])
        sort_BIN = sorted(BIN)
        try:
            return statistics.mode(sort_BIN[0:4])
        except:
            return min(sort_BIN)

so I am getting the search object back and then finding anything that matches the same resource ID as the card that I am trying to find the BIN of, then either returning the mode of the bottom 5 or if there isn't 5 results returned getting the smallest.

Problem I am having even getting a page_size of 50 is that I am not getting enough results back to even have a BIN in the list.

j-stone commented 7 years ago

use 'defId=resourceId' in your searchAuctions call instead of 'assetId=assetId' and you should just get the results for that resourceId which will be specifically one iteration of a player.

spacedlevo commented 7 years ago

Result! Thanks for you help! I can move on to some more stuff that probably I find interesting :) But it will be good to do some messing about with the values of my club