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
Error on LIVE, not on DEMO: KeyError: 'cst' #41
Comments
it looks like an issue between lower case / upper case. |
If I set the DEMO account credentials, all is ok. If I change to LIVE account credentials I get the error. |
I didn't test with LIVE... so you should fix it and submit a PR. I think you should simply change
to
Please test it and say me if it fix this issue. |
I changed the code but It doesn't fix the issue. /Users/gb/anaconda/lib/python3.5/site-packages/trading_ig/rest.py in _set_headers(self, response_headers, update_cst) 125 if update_cst: 126 #self.CLIENT_TOKEN = response_headers['CST'] --> 127 self.CLIENT_TOKEN = response_headers['cst'] 128 129 if 'X-SECURITY-TOKEN' in response_headers: /Users/gb/anaconda/lib/python3.5/site-packages/requests/structures.py in __getitem__(self, key) 52 53 def __getitem__(self, key): ---> 54 return self._store[key.lower()][1] 55 56 def __delitem__(self, key): KeyError: 'cst' |
I tried line by line: ig_session = ig_stream_service.create_session() # This generates the error ... from trading_ig import IGService, IGStreamService from trading_ig.lightstreamer import Subscription import trading_ig.compat as compat ig_service = IGService(username, password, api_key, acc_type) ig_stream_service = IGStreamService(ig_service) ig_session = ig_stream_service.create_session() # This generates the error |
I can only "blindly" help as I don't use anymore IG live (for now).
to see what is going on |
In LIVE, I get: {'Connection': 'close', 'Vary': 'X-IG-API-KEY,Accept-Encoding', 'Content-Encoding': 'gzip', 'Access-Control-Allow-Headers': 'Content-Type, X-IG-API-KEY, CST, X-SECURITY-TOKEN, VERSION, _method, Authorization, IG-ACCOUNT-ID', 'Date': 'Thu, 23 Feb 2017 11:09:52 GMT', 'Access-Control-Expose-Headers': 'CST, X-SECURITY-TOKEN', 'Access-Control-Allow-Methods': 'POST, GET, PUT, DELETE, OPTIONS, GET, POST, PUT, DELETE', 'Server': 'Apache', 'Access-Control-Max-Age': '3600', 'Access-Control-Allow-Origin': '*', 'Content-Length': '62', 'Content-Type': 'application/json', 'X-STATE': 'live', 'P3P': 'CP="ALL DSP LAW OTPa OUR IND UNI CNT"', 'Cache-Control': 'no-cache, no-store'} If I change from LIVE to DEMO, I get (some data omitted "..." ): {'X-REQUEST-ID': '8...7', 'Server': 'Apache', 'Content-Length': '330', 'P3P': 'CP="ALL DSP LAW OTPa OUR IND UNI CNT"', 'Connection': 'keep-alive', 'Date': 'Thu, 23 Feb 2017 11:13:53 GMT', 'X-STATE': 'live', 'Cache-Control': 'no-cache, no-store', 'Access-Control-Expose-Headers': 'CST, X-SECURITY-TOKEN', 'Access-Control-Max-Age': '3600', 'Pragma': 'no-cache', 'CST': '8...1', 'Access-Control-Allow-Headers': 'Content-Type, X-IG-API-KEY, CST, X-SECURITY-TOKEN, VERSION, _method, Authorization, IG-ACCOUNT-ID', 'Access-Control-Allow-Origin': '*', 'X-SECURITY-TOKEN': '3...3', 'Access-Control-Allow-Methods': 'POST, GET, PUT, DELETE, OPTIONS, GET, POST, PUT, DELETE', 'Content-Type': 'application/json', 'Content-Encoding': 'gzip', 'Expires': '0', 'Vary': 'X-IG-API-KEY,Accept-Encoding'} |
I found the error! |
A better error message is probably required |
@alienoia how did you solve the problem? |
Dear @femtotrader,
DEMO version is ok. When I change from DEMO to LIVE (username, password etc... are changed), I get the folloging error:
KeyError: 'cst'
(see below).Any help?
Thank you in advance,
Gilberto
This is the error output:
This is the main code (modules and credentials account imports are omitted):
The text was updated successfully, but these errors were encountered: