def save_order(ordertype, order): stationid = int(order.find("station").text) PublicMarketOrder.objects.create( last_seen=now, ordertype=ordertype, regionid=int(order.find("region").text), systemid=get_stationsystem(stationid), stationid=stationid, range=int(order.find("range").text), typeid=typeid, volremain=int(order.find("vol_remain").text), price = float(order.find("price").text) )
def get_competitionprice(ordertype, stationid, typeid, volremaining, orderprice, orderrange): systemid = get_stationsystem(stationid) regionid = get_systemregion(systemid) qs = PublicMarketOrder.objects.filter( ordertype=ordertype, regionid=regionid, typeid=typeid, volremain__gt=volremaining * 0.05) price = None for pmo in qs: if pmo.stationid == stationid and abs(pmo.price - orderprice) < 0.005: continue if ordertype == 'sell': max_distance = 3 else: max_distance = pmo.range + orderrange if system_distance(pmo.systemid, systemid) <= max_distance: if price is None: price = pmo.price else: price = min(price, pmo.price) return price