krishnavelu / alice_blue

Official Python library for Alice Blue API trading
GNU General Public License v3.0
133 stars 82 forks source link

issue with token #97

Closed keerthankumar closed 4 years ago

keerthankumar commented 4 years ago
  1. sometime while placing order I get below error     place_alice_sell(alice_contract, int(config['size']))   File "i:/vscode/ib_insync/statergy_1/main_alice_blue.py", line 50, in place_alice_sell     alice.place_order(transaction_type = TransactionType.Sell,   File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\alice_blue\alice_blue.py", line 528, in place_order     return self.api_call_helper(helper, Requests.POST, None, order)   File "C:\Users\keerthan\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\alice_blue\alice_blue.py", line 824, in api_call_helper     raise requests.HTTPError(response.text) requests.exceptions.HTTPError: {"status":"error","message":"Request Unauthorised","data":{}} is this the bug ? if I regenerate the token it will work fine. can you please help me with this ? how long does the token valid ?
krishnavelu commented 4 years ago

A token is valid for 24 hours. That doesn’t mean you can generate token on 2:00pm today and use it till tomorrow 2:00pm. Token gets cleared around 6:00am(approx) every morning. So try to generate token just before market and use it till market close.