def __init__(self, item_dir = {}): self._dir = item_dir util._setAttrsFromDir(self, item_dir) try: self.details = ItemDetails(self.details) except AttributeError: pass
def __init__(self, listing_dir = {}): self._dir = listing_dir util._setAttrsFromDir(self, listing_dir) self.buy_volume = 0 self.sell_volume = 0 self.max_buy = 0 self.min_sell = 99999999 self.mean_buy = 0 self.median_buy = 0 self.mode_buy = 0 self.mean_sell = 0 self.median_sell = 0 self.mode_sell = 0 self.margin = 0 self.volume_margin = 0 buy_objects = [] #enumerate buys. for raw_buy in self.buys: #Create a offer object for each one. buy = Offer(raw_buy) buy_objects.append(buy) #Compute the max buy, rolling. if buy.unit_price > self.max_buy: self.max_buy = buy.unit_price #Compute the first half of the mean, rolling. self.mean_buy += buy.unit_price * buy.quantity # TODO: an interesting thought would be deriving volume from listing count. self.buy_volume += buy.quantity self.buys = buy_objects sell_objects = [] #Enumerate sells. for raw_sell in self.sells: #Create a offer object for each one. sell = Offer(raw_sell) sell_objects.append(sell) #Compute the min sell, rolling. if sell.unit_price < self.min_sell: self.min_sell = sell.unit_price #Compute the first half of the mean, rolling. self.mean_sell += sell.unit_price * sell.quantity self.sell_volume += sell.quantity self.sells = sell_objects #Calculate the second halves of the means now that we have all listings. if self.sell_volume > 0: self.mean_sell /= self.sell_volume if self.buy_volume > 0: self.mean_buy /= self.buy_volume #TODO: Calculate the medians. remember that each listing has multiple quantity. #Calculate the margin. delta = self.min_sell - self.max_buy fee = (self.min_sell - 1) * .15 self.margin = (delta - fee) / (self.max_buy + 1) #Calculate volume margin self.volume_margin = float("inf") if self.sell_volume: self.volume_margin = self.buy_volume / self.sell_volume
def __init__(self, offer_dir = {}): self._dir = offer_dir util._setAttrsFromDir(self, offer_dir)
def __init__(self, item_dir = {}): self._dir = item_dir util._setAttrsFromDir(self, item_dir)