Download web_development/backend/app/core/contracts.py from lucky-loster/quant_test: direct link, hf CLI and curl.
- Browser
- Download file 7.67 kB
-
https://huggingface.co/lucky-loster/quant_test/resolve/main/web_development/backend/app/core/contracts.py
- Command line
-
hf download hf://lucky-loster/quant_test/web_development/backend/app/core/contracts.py
-
curl -L -o contracts.py https://huggingface.co/lucky-loster/quant_test/resolve/main/web_development/backend/app/core/contracts.py
7.67 kB
| """ | |
| All supported futures contracts β covers every symbol available via akshare (86 total). | |
| Organized by exchange and category. | |
| """ | |
| from dataclasses import dataclass | |
| class ContractInfo: | |
| symbol: str # akshare query name | |
| exchange: str # exchange code | |
| category: str # category key | |
| name_cn: str # display name | |
| EXCHANGES = { | |
| "CFFEX": "δΈε½ιθζθ΄§δΊ€ζζ", | |
| "SHFE": "δΈζ΅·ζθ΄§δΊ€ζζ", | |
| "INE": "δΈζ΅·ε½ι θ½ζΊδΊ€ζδΈεΏ", | |
| "DCE": "ε€§θΏεεδΊ€ζζ", | |
| "CZCE": "ιε·εεδΊ€ζζ", | |
| "GFEX": "εΉΏε·ζθ΄§δΊ€ζζ", | |
| } | |
| CATEGORIES = { | |
| "financial": "ιθζθ΄§", | |
| "precious_metal": "θ΄΅ιε±", | |
| "base_metal": "ζθ²ιε±", | |
| "ferrous": "ι»θ²η³»", | |
| "energy": "θ½ζΊεε·₯", | |
| "agriculture": "εδΊ§ε", | |
| "shipping": "θͺθΏζζ°", | |
| } | |
| CONTRACTS: list[ContractInfo] = [ | |
| # ββ ιθζθ΄§ (CFFEX) βββββββββββββββββββββββββββββββββ | |
| ContractInfo("ζ²ͺζ·±300ζζ°ζθ΄§", "CFFEX", "financial", "ζ²ͺζ·±300"), | |
| ContractInfo("δΈθ―50ζζ°ζθ΄§", "CFFEX", "financial", "δΈθ―50"), | |
| ContractInfo("δΈθ―500ζζ°ζθ΄§", "CFFEX", "financial", "δΈθ―500"), | |
| ContractInfo("δΈθ―1000θ‘ζζθ΄§", "CFFEX", "financial", "δΈθ―1000"), | |
| ContractInfo("2εΉ΄ζε½εΊζθ΄§", "CFFEX", "financial", "2εΉ΄ε½εΊ"), | |
| ContractInfo("5εΉ΄ζε½εΊζθ΄§", "CFFEX", "financial", "5εΉ΄ε½εΊ"), | |
| ContractInfo("10εΉ΄ζε½εΊζθ΄§", "CFFEX", "financial", "10εΉ΄ε½εΊ"), | |
| # ββ θ΄΅ιε± (SHFE / GFEX) ββββββββββββββββββββββββββββ | |
| ContractInfo("ι»ι", "SHFE", "precious_metal", "ι»ι"), | |
| ContractInfo("η½ιΆ", "SHFE", "precious_metal", "η½ιΆ"), | |
| ContractInfo("ι", "GFEX", "precious_metal", "ι"), | |
| ContractInfo("ι―", "GFEX", "precious_metal", "ι―"), | |
| # ββ ζθ²ιε± (SHFE) ββββββββββββββββββββββββββββββββββ | |
| ContractInfo("ζ²ͺι", "SHFE", "base_metal", "ζ²ͺι"), | |
| ContractInfo("ζ²ͺι", "SHFE", "base_metal", "ζ²ͺι"), | |
| ContractInfo("ζ²ͺι", "SHFE", "base_metal", "ζ²ͺι"), | |
| ContractInfo("ζ²ͺι ", "SHFE", "base_metal", "ζ²ͺι "), | |
| ContractInfo("ζ²ͺι", "SHFE", "base_metal", "ζ²ͺι"), | |
| ContractInfo("ζ²ͺι‘", "SHFE", "base_metal", "ζ²ͺι‘"), | |
| ContractInfo("δΈιι’", "SHFE", "base_metal", "δΈιι’"), | |
| ContractInfo("ε½ι ι", "SHFE", "base_metal", "ε½ι ι"), | |
| ContractInfo("ζ°§ει", "SHFE", "base_metal", "ζ°§ει"), | |
| ContractInfo("ιΈι ιειζθ΄§", "SHFE", "base_metal", "ιΈι ιει"), | |
| ContractInfo("ε·₯δΈη‘ ", "GFEX", "base_metal", "ε·₯δΈη‘ "), | |
| ContractInfo("η’³ι Έι", "GFEX", "base_metal", "η’³ι Έι"), | |
| ContractInfo("ε€ζΆη‘ ", "GFEX", "base_metal", "ε€ζΆη‘ "), | |
| # ββ ι»θ²η³» (SHFE / DCE / CZCE) ββββββββββββββββββββββ | |
| ContractInfo("θΊηΊΉι’", "SHFE", "ferrous", "θΊηΊΉι’"), | |
| ContractInfo("ηθ½§ε·ζΏ", "SHFE", "ferrous", "ηε·"), | |
| ContractInfo("ηΊΏζ", "SHFE", "ferrous", "ηΊΏζ"), | |
| ContractInfo("ιηΏη³", "DCE", "ferrous", "ιηΏη³"), | |
| ContractInfo("η¦η €", "DCE", "ferrous", "η¦η €"), | |
| ContractInfo("η¦η", "DCE", "ferrous", "η¦η"), | |
| ContractInfo("ι°η‘ ", "CZCE", "ferrous", "ι°η‘ "), | |
| ContractInfo("η‘ ι", "CZCE", "ferrous", "η‘ ι"), | |
| ContractInfo("ε¨εη €", "CZCE", "ferrous", "ε¨εη €"), | |
| # ββ θ½ζΊεε·₯ (SHFE / INE / DCE / CZCE) ββββββββββββββ | |
| ContractInfo("εζ²Ή", "INE", "energy", "εζ²Ή"), | |
| ContractInfo("ηζ²Ή", "SHFE", "energy", "ηζ²Ή"), | |
| ContractInfo("ζ²₯ι", "SHFE", "energy", "ζ²₯ι"), | |
| ContractInfo("ζ©‘θΆ", "SHFE", "energy", "ζ©‘θΆ"), | |
| ContractInfo("20ε·θΆ", "SHFE", "energy", "20ε·θΆ"), | |
| ContractInfo("δΈδΊη―ζ©‘θΆ", "SHFE", "energy", "δΈδΊη―ζ©‘θΆ"), | |
| ContractInfo("ηΊΈζ΅", "SHFE", "energy", "ηΊΈζ΅"), | |
| ContractInfo("θΆηε°ε·ηΊΈζθ΄§", "SHFE", "energy", "θΆηε°ε·ηΊΈ"), | |
| ContractInfo("δ½η‘«ηζζ²Ή", "SHFE", "energy", "δ½η‘«ηζ²Ή"), | |
| ContractInfo("PTA", "CZCE", "energy", "PTA"), | |
| ContractInfo("ιι", "CZCE", "energy", "η²ι"), | |
| ContractInfo("δΉδΊι", "DCE", "energy", "δΉδΊι"), | |
| ContractInfo("ε°Ώη΄ ", "CZCE", "energy", "ε°Ώη΄ "), | |
| ContractInfo("ηΊ―η’±", "CZCE", "energy", "ηΊ―η’±"), | |
| ContractInfo("η»η", "CZCE", "energy", "η»η"), | |
| ContractInfo("ε‘ζ", "DCE", "energy", "ε‘ζ(LLDPE)"), | |
| ContractInfo("PP", "DCE", "energy", "θδΈη―(PP)"), | |
| ContractInfo("PVC", "DCE", "energy", "θζ°―δΉη―(PVC)"), | |
| ContractInfo("θ―δΉη―", "DCE", "energy", "θ―δΉη―"), | |
| ContractInfo("ηηΊ€", "CZCE", "energy", "ηηΊ€"), | |
| ContractInfo("ζΆ²εη³ζ²Ήζ°", "DCE", "energy", "ζΆ²εζ°(LPG)"), | |
| ContractInfo("ηΊ―θ―", "DCE", "energy", "ηΊ―θ―"), | |
| ContractInfo("η§η’±", "CZCE", "energy", "η§η’±"), | |
| ContractInfo("δΊη²θ―", "CZCE", "energy", "δΊη²θ―(PX)"), | |
| ContractInfo("ηΆηΊ§θι ―εη", "CZCE", "energy", "ηΆη(PET)"), | |
| ContractInfo("δΈη―", "CZCE", "energy", "δΈη―"), | |
| # ββ εδΊ§ε (DCE / CZCE) ββββββββββββββββββββββββββββββ | |
| ContractInfo("θ±δΈ", "DCE", "agriculture", "θ±δΈ"), | |
| ContractInfo("θ±δΊ", "DCE", "agriculture", "θ±δΊ"), | |
| ContractInfo("θ±η²", "DCE", "agriculture", "θ±η²"), | |
| ContractInfo("θ±ζ²Ή", "DCE", "agriculture", "θ±ζ²Ή"), | |
| ContractInfo("ζ£ζ¦", "DCE", "agriculture", "ζ£ζ¦ζ²Ή"), | |
| ContractInfo("θζ²Ή", "CZCE", "agriculture", "θη±½ζ²Ή"), | |
| ContractInfo("θη±½", "CZCE", "agriculture", "θη±½"), | |
| ContractInfo("θη²", "CZCE", "agriculture", "θη²"), | |
| ContractInfo("θ±η", "CZCE", "agriculture", "θ±η"), | |
| ContractInfo("ζ£θ±", "CZCE", "agriculture", "ζ£θ±"), | |
| ContractInfo("ζ£ηΊ±", "CZCE", "agriculture", "ζ£ηΊ±"), | |
| ContractInfo("η½η³", "CZCE", "agriculture", "η½η³"), | |
| ContractInfo("ι²θΉζ", "CZCE", "agriculture", "θΉζ"), | |
| ContractInfo("ηΊ’ζ£", "CZCE", "agriculture", "ηΊ’ζ£"), | |
| ContractInfo("ηη±³", "DCE", "agriculture", "ηη±³"), | |
| ContractInfo("ηη±³ζ·η²", "DCE", "agriculture", "ηη±³ζ·η²"), | |
| ContractInfo("ιΈ‘θ", "DCE", "agriculture", "ιΈ‘θ"), | |
| ContractInfo("ηηͺ", "DCE", "agriculture", "ηηͺ"), | |
| ContractInfo("η²³η±³", "DCE", "agriculture", "η²³η±³"), | |
| ContractInfo("粳稻", "CZCE", "agriculture", "粳稻"), | |
| ContractInfo("εΌΊιΊ¦", "CZCE", "agriculture", "εΌΊιΊ¦"), | |
| ContractInfo("ζ©η±Όη¨»", "CZCE", "agriculture", "ζ©η±Όη¨»"), | |
| ContractInfo("ζ籼稻", "CZCE", "agriculture", "ζ籼稻"), | |
| ContractInfo("ηΊ€η»΄ζΏ", "DCE", "agriculture", "ηΊ€η»΄ζΏ"), | |
| ContractInfo("θΆεζΏ", "DCE", "agriculture", "θΆεζΏ"), | |
| ContractInfo("εζ¨", "DCE", "agriculture", "εζ¨"), | |
| # ββ θͺθΏζζ° (SHFE) βββββββββββββββββββββββββββββββββ | |
| ContractInfo("ιθΏζζ°(欧线)ζθ΄§", "SHFE", "shipping", "ιθΏζζ°(欧线)"), | |
| ] | |
| SYMBOL_LOOKUP: dict[str, ContractInfo] = {c.symbol: c for c in CONTRACTS} | |
| def get_contracts_by_category(category: str | None = None) -> list[ContractInfo]: | |
| if category is None: | |
| return CONTRACTS | |
| return [c for c in CONTRACTS if c.category == category] | |
| def get_contracts_by_exchange(exchange: str | None = None) -> list[ContractInfo]: | |
| if exchange is None: | |
| return CONTRACTS | |
| return [c for c in CONTRACTS if c.exchange == exchange] | |