pix / tickers.py
sarim's picture
now get all symbols
28493d1
Raw
History Blame Contribute Delete
994 Bytes
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")