Average Command¶
- average.calculate_average(plat_list: list[int], statistic: Literal['geometric', 'mean', 'median', 'mode'], ndigits: int = config.DEFAULT_NDIGITS) float¶
Calculate the specified statistic for a list of prices.
Given a list of integers of prices associated with an item, calculate and return the desired statistic, rounded to the specified number of decimal places.
- Parameters:
plat_list – Prices in platinum of each order.
statistic – Statistic to be calculated.
ndigits – Number of decimals to which the calculated statistic should be rounded, defaults to config.DEFAULT_NDIGITS.
- Raises:
errors.NoListingsFoundError – If
plat_listhas no contents.- Returns:
Desired statistic of the specified item.
- average.in_time_range(last_updated: str, current_time: datetime, time_range: int = config.DEFAULT_TIME) bool¶
Check if order is younger than
time_rangedays.Subtract last_updated field from current_time to check if the difference in days is less than or equal to
time_range.- Parameters:
last_updated – ISO-8601 timestamp of when the order was last updated.
current_time – Current UTC time.
time_range – Maximum age, in days, that an order can be to be accepted, defaults to config.DEFAULT_TIME.
- Returns:
Trueiflast_updated ≤ time_range,Falseiflast_updated > time_range.
- average.check_mod_arcane_rank(order_rank: int | None, item_max_rank: int | None, *, use_maxrank: bool) bool¶
Check if an order’s rank matches user-specified rank level.
Check if an order’s rank equals the rank specified by the user. If the item isn’t a mod or arcane,
order_rankanditem_max_rankshould both beNone. If eitherorder_rankoritem_max_rankisNone, thenTruewill be returned.- Parameters:
order_rank – Rank of the order.
item_max_rank – Maximum possible rank for the item.
use_maxrank – User-specified rank of mod or arcane. If
True, the maximum potential rank of the item will be use. IfFalse, the unranked item will be used.
- Returns:
Trueif the order_rank isNone, if item_max_rank isNone, or if order’s rank matchesitem_max_rank * use_maxrank,Falseotherwise.
- average.check_relic_subtype(subtype: str | None, use_radiant: Literal['intact', 'radiant']) bool¶
Check if an order’s subtype matches user-specified refinement level.
Check if an order’s subtype equals the refinement level specified by the user. If the item isn’t a relic,
subtypeshould beNone.- Parameters:
subtype – Subtype of the order.
use_radiant – User-specified refinement level to compare against. Can be either “radiant” or “intact”.
- Returns:
Trueif the order’s subtype matchesuse_radiantor if subtype isNone,Falseotherwise.
- average.filter_order(order: OrderWithUser, item_info: Item, current_time: datetime, args: Namespace) bool¶
Check if an order meets all user-specified criteria.
Check if an order meets all user-defined conditions:
Whether the order’s last update is within
args.timerangedays.- Whether the order is of “buy” or “sell” type, depending on
args.use_buyers.
- If the item is a mod or arcane, whether its rank is unranked or
the maximum rank, based on
args.maxrank.
- If the item is a relic, whether its refinement is intact or
radiant, based on
args.radiant.
- Parameters:
order – Order to be checked.
item_info – Details about the item.
current_time – Current time.
args – Command-line arguments provided by the user. Must have the fields
use_buyers,maxrank,radiant, andtimerange.
- Returns:
Trueif all specified conditions are met,Falseotherwise.
- average.filtered_plat_list(order_data: list[OrderWithUser], item_info: Item, current_time: datetime, args: Namespace) list[int]¶
Construct a list of prices using a filter.
Return a filtered list of platinum prices given a list of
schema.OrderWithUser, aschema.Item, and the user’s command-line arguments.- Parameters:
order_data – List of
schema.OrderWithUsercontaining information about each individual order.item_info – Object containing information about the item.
current_time – Current time.
args – User-given command line arguments. Must have the fields
statistic,item,porcelain, andtimerange.
- Returns:
List of the platinum prices from the filtered listings.
- average.format_output(stat: float, plat_list: list[int], args: Namespace) str¶
Format the calculated statistic along with additional information.
Format the calculated statistic, along with the maximum and minimum prices of the orders, and the total number of orders that match the search criteria. If
args.porcelainisTrue, separate the fields with a single colon.- Parameters:
stat – Statistic of the item that was found.
plat_list – List of prices of the item.
args – User-given command line arguments. Must have the fields
statistic,item,porcelain, andtimerange.
- Returns:
Return appropriately formatted string.
- average.get_required_data(item: str, http_headers: dict[str, str]) tuple[ItemResponse, OrderResponse]¶
Retrieve the orders and metadata for an item.
- Parameters:
item – Item to retrieve.
http_headers – Headers to be used in the HTTP request.
- Returns:
The item’s metadata and the orders associated with it.
- average.process_data(args: Namespace, http_headers: dict[str, str], current_time: datetime) str¶
Calculate average price of an item from warframe.market.
- Parameters:
args – Parsed command-line args. Must have the fields
statistic,item,porcelain,radiant,use_buyers,maxrank, andtimerange.http_headers – Headers to be used in the HTTP request.
current_time – Current time.
- Returns:
Calculated statistic.