TRIN STRATEGY-sentiment indicators course

Hi i have been trying to recreate the Trin strategy in indian context with nse data.But i am facing some difficulties in getting the data live from market.To solve this i am using a screner from the broker alice blue.But again even though i am getting the data i am unable to convert it into pandas dataframe.I am sharing the code as follows:



#Fetching the data



import requests 


Making a GET request 

r = requests.get('ANT Web Trading Platform - AliceBlue


check status code for response received 

success code - 200 

print(r) 


print content of request 

print(r.json()) 



–This part gives me a dictionary of the advancing and declining stocks  in nifty 50



#converting it to dataframe



import pandas as pd

r=r['data']

df=pd.DataFrame('r')

df.head()



–This gives me an error relating to reading the 'data' part of the derived dictionary

You can try the following code to read the losers and gainers.



import pandas as pd

data = r.json()['data']



losers = pd.DataFrame.from_dict(data['losers'])

gainers = pd.DataFrame.from_dict(data['losers'])



References: 



pandas.DataFrame.from_dict — pandas 2.2.3 documentation



Thanks

works like a charm…thanks