Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to refresh the position and holdings? #57

Open
ak4zh opened this issue Feb 16, 2024 · 1 comment
Open

how to refresh the position and holdings? #57

ak4zh opened this issue Feb 16, 2024 · 1 comment

Comments

@ak4zh
Copy link

ak4zh commented Feb 16, 2024

Describe the bug

Documentation is not clear on how to refresh the data once you have logged in.
I am using this code to calculate my position pnl but the data is not getting updated.

Code snippet

from dotenv import load_dotenv
import os
import pyotp
import time
from jugaad_trader import Zerodha
load_dotenv()

otp_gen = pyotp.TOTP(os.getenv("ZERODHA_TOTP_HASH"))
kite = Zerodha(
    user_id=os.getenv("ZERODHA_ID"), 
    password=os.getenv("ZERODHA_PASSWORD"), 
    twofa=otp_gen.now()
)
kite.login()

while True:
    pnl = 0
    positions = kite.positions()
    for position in positions.get("net"):
        pnl += position.get('pnl')
    print(pnl)
    time.sleep(1)
@sevakram
Copy link
Contributor

Your code looks alright and there is nothing extra that we can add in documentation to address it.

You are getting what Zerodha is sending.. so either portfolio is not updated every second, other than this we are at mercy of Zerodha backend

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants