Unexpected return observed.

SAPANKHUNTIA
SAPANKHUNTIA edited March 2021 in Python client
Hi traders and coders.

I am very new to coding. This is my code
import datetime
import pytz
import time
import logging
from kiteconnect import KiteConnect, KiteTicker

kite = ""
kws = ""

logging.basicConfig(level=logging.DEBUG)

api_key = 'XXXXXX'
api_secret = 'XXXXXXX
access_token = 'XXXXXXXX'

def get_login(api_key,api_secret):
global kws, kite
kite = KiteConnect(api_key = api_key)

kite.set_access_token(access_token)
kws = KiteTicker(api_key=api_key, access_token = access_token, reconnect = True)

get_login(api_key, api_secret)

print(kite.positions()['net'])
Can someone please explain why I am getting this output for the above code. The first two lines should not be there I think.

DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.kite.trade:443
DEBUG:urllib3.connectionpool:https://api.kite.trade:443 "GET /portfolio/positions HTTP/1.1" 200 None
[{'tradingsymbol': 'PNB', 'exchange': 'NSE', 'instrument_token': 2730497, 'product': 'MIS', 'quantity': 1, 'overnight_quantity': 0, 'multiplier': 1, 'average_price': 41.65, 'close_price': 0, 'last_price': 41.65, 'value': -41.65, 'pnl': 0, 'm2m': 0, 'unrealised': 0, 'realised': 0, 'buy_quantity': 1, 'buy_price': 41.65, 'buy_value': 41.65, 'buy_m2m': 41.65, 'sell_quantity': 0, 'sell_price': 0, 'sell_value': 0, 'sell_m2m': 0, 'day_buy_quantity': 1, 'day_buy_price': 41.65, 'day_buy_value': 41.65, 'day_sell_quantity': 0, 'day_sell_price': 0, 'day_sell_value': 0}]

Thank you all.
Tagged:
  • rakeshr
    rakeshr edited March 2021
    @SAPANKHUNTIA
    The first two lines should not be there I think.
    By, first two lines, do you mean debug log here:
    DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.kite.trade:443
    DEBUG:urllib3.connectionpool:https://api.kite.trade:443 "GET /portfolio/positions HTTP/1.1" 200 None
    If yes, then these are debug logs, you can disable them by removing below line:
    logging.basicConfig(level=logging.DEBUG)
    Also, you should never post app-related keys like api_key, access_token, secret key, etc. As you have posted your app secret key, we will request you to regenerate your API secret from the developer console.
  • SAPANKHUNTIA
    Thank you @rakeshr
    My apologies but I have hidden few characters of the key. Anyway, I will never post like this again.

    So these debug messages are appearing because there's something wrong in the code or what.
  • sujith
    If you set debug logs on then you can see all the request and response details for debugging.
Sign In or Register to comment.