以下是一个简单的示例,用于统计买卖单数据(假设数据以某种形式存在,这里以简单的列表模拟买单和卖单数据):
```python
# 假设买单列表,每个元素表示一个买单的金额
buy_orders = [100, 200, 150, 300]
# 假设卖单列表,每个元素表示一个卖单的金额
sell_orders = [120, 180, 250]
# 计算买单总数
buy_orders_count = len(buy_orders)
# 计算卖单总数
sell_orders_count = len(sell_orders)
# 计算买单总金额
buy_orders_total_amount = sum(buy_orders)
# 计算卖单总金额
sell_orders_total_amount = sum(sell_orders)
# 平均买单金额
if buy_orders_count > 0:
average_buy_amount = buy_orders_total_amount / buy_orders_count
else:
average_buy_amount = 0
# 平均卖单金额
if sell_orders_count > 0:
average_sell_amount = sell_orders_total_amount / sell_orders_count
else:
average_sell_amount = 0
print("买单总数:", buy_orders_count)
print("卖单总数:", sell_orders_count)
print("买单总金额:", buy_orders_total_amount)
print("卖单总金额:", sell_orders_total_amount)
print("平均买单金额:", average_buy_amount)
print("平均卖单金额:", average_sell_amount)
```
在实际应用中,买卖单数据可能来自数据库、交易接口或者其他数据源,并且数据结构可能更加复杂,可能包含时间戳、订单号、下单者等更多信息。如果是在金融交易领域,可能还需要考虑订单的状态(如部分成交、完全成交、未成交等)等复杂因素。
|
|