|
@@ 57-71 (lines=15) @@
|
| 54 |
|
else: |
| 55 |
|
return item[condition.key] >= 0 and (item[condition.key] < avg_value + condition.value) |
| 56 |
|
|
| 57 |
|
def _check_below_cheapest_last_sold(self, item: LockedDict, condition: LockedDict) -> bool: |
| 58 |
|
"""Check if the value of the item is below the average of the cheapest sold items |
| 59 |
|
of the last 20 purchases |
| 60 |
|
|
| 61 |
|
:type item: LockedDict |
| 62 |
|
:type condition: LockedDict |
| 63 |
|
:return: |
| 64 |
|
""" |
| 65 |
|
last_sold = self.get_sold_history(market_name=item.market_name, no_delay=True) |
| 66 |
|
lowest_value = min([sold_item[condition.key] for sold_item in last_sold.data.sales]) |
| 67 |
|
|
| 68 |
|
if condition.unit == "%": |
| 69 |
|
return item[condition.key] >= 0 and (item[condition.key] < lowest_value * (1 + condition.value)) |
| 70 |
|
else: |
| 71 |
|
return item[condition.key] >= 0 and (item[condition.key] < lowest_value + condition.value) |
| 72 |
|
|
| 73 |
|
def check_condition(self, item: LockedDict, settings: LockedDict) -> bool: |
| 74 |
|
"""Check if the set condition matches on the passed item |
|
@@ 42-55 (lines=14) @@
|
| 39 |
|
""" |
| 40 |
|
return item[condition.key] >= 0 and (item[condition.key] < condition.value) |
| 41 |
|
|
| 42 |
|
def _check_below_average_last_sold(self, item: LockedDict, condition: LockedDict) -> bool: |
| 43 |
|
"""Check if the value of the item is below the average of the last 20 sold items |
| 44 |
|
|
| 45 |
|
:type item: LockedDict |
| 46 |
|
:type condition: LockedDict |
| 47 |
|
:return: |
| 48 |
|
""" |
| 49 |
|
last_sold = self.get_sold_history(market_name=item.market_name, no_delay=True) |
| 50 |
|
avg_value = sum([sold_item[condition.key] for sold_item in last_sold.data.sales]) / len(last_sold.data.sales) |
| 51 |
|
|
| 52 |
|
if condition.unit == "%": |
| 53 |
|
return item[condition.key] >= 0 and (item[condition.key] < avg_value * (1 + condition.value)) |
| 54 |
|
else: |
| 55 |
|
return item[condition.key] >= 0 and (item[condition.key] < avg_value + condition.value) |
| 56 |
|
|
| 57 |
|
def _check_below_cheapest_last_sold(self, item: LockedDict, condition: LockedDict) -> bool: |
| 58 |
|
"""Check if the value of the item is below the average of the cheapest sold items |