Download tickers.py from sarim/pix: direct link, hf CLI and curl.
- Browser
- Download file 1.1 kB
-
https://huggingface.co/spaces/sarim/pix/resolve/main/tickers.py
- Command line
-
hf download hf://spaces/sarim/pix/tickers.py
-
curl -L -o tickers.py https://huggingface.co/spaces/sarim/pix/resolve/main/tickers.py
1.1 kB
| import psxdata | |
| from typing import List, Dict, Any | |
| import pandas as pd | |
| from models import TickerModel | |
| class PsxIndexAndTickers: | |
| def getAllSymbols(self) -> List[str]: | |
| allShare = psxdata.tickers("ALLSHR") | |
| return allShare | |
| def getIndexTicker(self,index) -> List[TickerModel]: | |
| df = psxdata.indices(index) | |
| print(df) | |
| indexTicker = [ | |
| TickerModel( | |
| symbol = row["symbol"], | |
| name = row["name"], | |
| idx_weight = row["idx_weight"], | |
| ldcp = row['ldcp'], | |
| current = row['current'], | |
| change = row['change'], | |
| volume = row['volume'], | |
| freeFloat = row['freefloat_m'], | |
| marketCap = row['market_cap_m'] | |
| ) | |
| for _, row in df.iterrows() | |
| ] | |
| return indexTicker | |
| def symbolFundamentals(self,symbol): | |
| fund = psxdata.fundamentals() | |
| print(fund) | |
| if __name__ == "__main__": | |
| psxIndex = PsxIndexAndTickers() | |
| psxIndex.symbolFundamentals("EPCL") | |