File size: 994 Bytes
28493d1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | 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
if __name__ == "__main__":
psxIndex = PsxIndexAndTickers()
psxIndex.getIndexTicker("PSXDIV20")
|