Algo Trading.How to connect to Fyers API? Python

 def connect_fyers():

    global fyers

    session=accessToken.SessionModel(client_id="XXXXXXX-100",

    secret_key="YYYYYYYYYY",redirect_uri="https://trade.fyers.in/", 

    response_type="code", grant_type="authorization_code",

    state="abcdefg",scope="",nonce="")

    response = session.generate_authcode()

    #https://api.fyers.in/api/v2/generate-authcode?client_id=XXXXXXX-100&redirect_uri=https://fyers.in&response_type=code&state=sample_state&nonce=sample_nonce

    auth_code=sessionVar.get()

    top.destroy()

    session.set_token(auth_code)

    response = session.generate_token()

    access_token = response["access_token"]

    fyers = fyersModel.FyersModel(client_id="XXXXXXX-100", token=access_token,log_path="E:\python")

    profile=fyers.get_profile()

    print(profile["data"]["name"])

    print(mav(20))

def session_pop():

    global top

    top=Toplevel(root)

    global sessionVar

    sessionVar=Entry(top)

    sessionVar.grid(row=0,column=0)

    Button(top,text="SUBMIT",command=connect_fyers).grid(row=0,column=1) 

Watch the video below to learn how to do this



Comments

Popular posts from this blog

Zerodha Algo Trading Python, How to connect to kiteconnect?

How to Place Order in Zerodha using Python

Create Option Chain using PYTHON.