Algo Trading. How to view order details? Fyers, Python

View Order Details

def exactPositions():

    openPos=(fyers.positions())

    posLength=len(openPos["netPositions"])

    startPos=0

    orderName=""

    orderQty1=0

    print(posLength)

    #print(openPos["netPositions"][1]["qty"])

    #print(openPos["netPositions"][9])

    while(startPos<posLength):

        if(openPos["netPositions"][startPos]["qty"]>0):

            print(openPos["netPositions"][startPos]["qty"])

            qty.delete(0,"end")

            qty.insert(0,openPos["netPositions"][startPos]["qty"])

            orderQty1=int(openPos["netPositions"][startPos]["qty"])

            print(orderQty1)

            orderName=openPos["netPositions"][startPos]["symbol"]

            print(orderName)

            name.delete(0,"end")

            name.insert(0,orderName)

            break

        startPos+=1 

   openOrder=fyers.orderbook()

    orderSize=len(openOrder["orderBook"])

    orderStart=0

    tempQty=0

    tempAvg=0;

    while(orderStart<orderSize):

        if((openOrder["orderBook"][orderStart]["status"]==2)and(openOrder["orderBook"][orderStart]["status"]==2)and(tempQty<orderQty1)and(openOrder["orderBook"][orderStart]["symbol"]==orderName)and(openOrder["orderBook"][orderStart]["side"]==1)):

            tempAvg=tempAvg+(openOrder["orderBook"][orderStart]["tradedPrice"]*openOrder["orderBook"][orderStart]["qty"])

            tempQty=tempQty+openOrder["orderBook"][orderStart]["qty"];

        orderStart+=1

    if((tempQty>0)and(tempAvg>0)):

        name.delete(0,"end")

        name.insert(0,orderName.replace("NSE:",""))

        qty.delete(0,"end")

        qty.insert(0,tempQty)

        avg.delete(0,"end")

        avg.insert(0,tempAvg/tempQty)

        profit.delete(0,"end")

        profit.insert(0,0)

        print("DONE")     



Comments

Popular posts from this blog

Create Option Chain using PYTHON.

How to Place Order in Zerodha using Python

How to place order in zerodha when RSI crosses below 30? Algo Trading Python