Hi i am trying to get live data from aliceblue which i am able to fetch but am unable to convert them into a pandas dataframe for further analysis.I am in the process of building a strategy where data from nifty 50 stocks is used to calculate nifty fut movement.I have done it successfully in excel but now i want to do it python as in excel connection needs to be refreshed due to disconnection time and again.Any help would be appreciated.
Tell with your patch of code on exact where you’re stuck. Prices to Pandas storing has examples with Zerodha API. You can find in unofficed.com/diary.
See if that helps.
Tip: You should use timeseries database instead. It helps a lot. Try InfluxDB
After login in for alice blue and streaming data started i try to get the entire code reflected in excel from where i can generate the required signal…following is the code:
socket_opened = False
def event_handler_quote_update(message):
print(f"quote update {message}")
def open_callback():
global socket_opened
socket_opened = True
alice.start_websocket(subscribe_callback=event_handler_quote_update,
socket_open_callback=open_callback,
run_in_background=True)
while(socket_opened==False):
pass
alice.subscribe(alice.get_instrument_by_symbol(‘NSE’, ‘SBIN’), LiveFeedType.MARKET_DATA)
sleep(10)
#create a excel sheet with same file name in the folder where the program is being run
import xlwings as xw
currentRow=2
FILENAME = ‘saveAliceData21.xlsx’
wb = xw.Book(FILENAME)
ws = wb.sheets[‘Sheet1’]
Why you are dealing with XLS. Use CSV please. It’s simple data.
CSV to Pandas and vice-versa is one-liner.
hi dexter i am trying to take the data from aliceblue screener withg help of the link provided by you.
link=“Ant Web”
but i am not able to convert this into a dataframe.My code is as follows
import requests
Making a GET request
r = requests.get(‘Ant Web’)
check status code for response received
success code - 200
print(r)
print content of request
print(r.content)
import pandas as pd
df=pd.DataFrame(r)
df.head()
r.content returns a byte stream
use r.text or r.json()