pix / tickers.py
sarim's picture
updated commodities
9e0b833
Raw History Blame Contribute Delete
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")