cx_spend.py 750 B

12345678910111213141516171819202122232425262728
  1. from __future__ import annotations
  2. import typing
  3. import cache
  4. def main() -> None:
  5. for spent_30d, ticker in sorted(items(), reverse=True):
  6. print(f'{ticker:4} {spent_30d:11,.0f}')
  7. def items() -> typing.Iterator[tuple[float, str]]:
  8. raw_prices: list[RawPrice] = cache.get('https://refined-prun.github.io/refined-prices/all.json')
  9. for price in raw_prices:
  10. if price['ExchangeCode'] != 'IC1':
  11. continue
  12. if (vwap_30d := price['VWAP30D']) is None or (traded_30d := price['Traded30D']) is None:
  13. continue
  14. spent_30d = vwap_30d * traded_30d
  15. yield spent_30d, price['MaterialTicker']
  16. class RawPrice(typing.TypedDict):
  17. MaterialTicker: str
  18. ExchangeCode: str
  19. VWAP30D: float | None
  20. Traded30D: float | None
  21. if __name__ == '__main__':
  22. main()