Closed AdamAdamsson closed 4 years ago
FYI: @Eriz11
Hi @AdamAdamsson!
I have just tried that exact script with newly generated API credentials
and it works without problems.
The first thing you should try to do is: pip install -U darwinexapis
and confirm that you have the latest version of the package.
Please, could you try to regenerate the API credentials
and re-run the script? They might have expired as they expire in about an hour. If that still does not resolve the issue, please let me know and I will try to assist, but the problem might be related to your account.
Best,
Hi Eriz,
I did a pip install according your instruction, but it looks as I have tha last version: "Requirement already up-to-date: darwinexapis in c:\users\dan\anaconda3\lib\site-packages (0.4.3)"
I generated new tokens at the demo tab in https://www.darwinex.com/data/darwin-api/ But still same error message when I run DarwinAPIClassesExample.py from my Jupyter environment:
DarwinAPIClassesExample.py
%run DarwinAPIClassesExample.py
[INIT] - Creating AUTH creds... [INIT] - Access token will be created again at 1600091403.6370587 UNIX timestamp [DarwinInfoAPI] Getting first 50 DARWINs..
[DECORATOR] - The expiration time has NOT reached yet > Continue... FULL URL ENDPOINT : https://api.darwinex.com/darwininfo/2.0/products?status=ACTIVE&page=0&per_page=50 <Response [403]> {"fault":{"code":900908,"message":"Resource forbidden ","description":"Access failure for API: /darwininfo/2.0, version: 2.0 status: (900908) - Resource forbidden "}}
---------------------------------------------------------------------------KeyError
Traceback (most recent call
last)~\darwinexapis-master\darwinexapis\EXAMPLE_SCRIPTS\DarwinAPIClassesExample.py
in
On Mon, Sep 14, 2020 at 1:21 PM Eriz Zárate notifications@github.com wrote:
Hi @AdamAdamsson https://github.com/AdamAdamsson!
Although this is not the repository for the darwinexapis package (this is the actual one https://github.com/darwinex/darwinexapis), I will answer the question directly here.
I have just tried that exact script with newly generated API credentials and it works without problems.
The first thing you should try to do is: pip install -U darwinexapis and confirm that you have the latest version of the package.
Please, could you try to regenerate the API credentials and re-run the script? They might have expired as they expire in about an hour. If that still does not resolve the issue, please let me know and I will try to assist, but the problem might be related to your account.
Best,
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/darwinex/darwinexapis/issues/2#issuecomment-691989221, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQ6XIL7DOX2PLITHAV7LHITSFX4CRANCNFSM4RLNKBQA .
Enclosing the modified Python script
Regards,
On Mon, Sep 14, 2020 at 2:58 PM Dan Browall dan@browall.com wrote:
Hi Eriz,
I did a pip install according your instruction, but it looks as I have tha last version: "Requirement already up-to-date: darwinexapis in c:\users\dan\anaconda3\lib\site-packages (0.4.3)"
I generated new tokens at the demo tab in https://www.darwinex.com/data/darwin-api/ But still same error message when I run DarwinAPIClassesExample.py from my Jupyter environment:
DarwinAPIClassesExample.py
%run DarwinAPIClassesExample.py
[INIT] - Creating AUTH creds... [INIT] - Access token will be created again at 1600091403.6370587 UNIX timestamp [DarwinInfoAPI] Getting first 50 DARWINs..
[DECORATOR] - The expiration time has NOT reached yet > Continue... FULL URL ENDPOINT : https://api.darwinex.com/darwininfo/2.0/products?status=ACTIVE&page=0&per_page=50 <Response [403]> {"fault":{"code":900908,"message":"Resource forbidden ","description":"Access failure for API: /darwininfo/2.0, version: 2.0 status: (900908) - Resource forbidden "}}
---------------------------------------------------------------------------KeyError Traceback (most recent call last)~\darwinexapis-master\darwinexapis\EXAMPLE_SCRIPTS\DarwinAPIClassesExample.py in
25 26 ### DWX_Info_API:---> 27 darwinUniverse = darwinexInfo._Get_DARWINUniverse(_status='ACTIVE', _iterate=True, _perPage=50) 28 pprint.pprint(darwinUniverse) 29 darwinUniverse.to_csv('C:/Users/Dan/darwinexapis-master/darwinexapis/darwinUniverse.csv') ~\anaconda3\lib\site-packages\darwinexapis\API\InfoAPI\DWX_Info_API.py in _Get_DARWINUniverse(self, _status, _endpoint, _query_string, _page, _perPage, _iterate, _delay) 222 223 # Calculate number of pages--> 224 _pages = int(_darwins['totalPages']) 225 226 # Keep 'content' list of DARWINs, discard everything else KeyError: 'totalPages' On Mon, Sep 14, 2020 at 1:21 PM Eriz Zárate notifications@github.com wrote:
Hi @AdamAdamsson https://github.com/AdamAdamsson!
Although this is not the repository for the darwinexapis package (this is the actual one https://github.com/darwinex/darwinexapis), I will answer the question directly here.
I have just tried that exact script with newly generated API credentials and it works without problems.
The first thing you should try to do is: pip install -U darwinexapis and confirm that you have the latest version of the package.
Please, could you try to regenerate the API credentials and re-run the script? They might have expired as they expire in about an hour. If that still does not resolve the issue, please let me know and I will try to assist, but the problem might be related to your account.
Best,
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/darwinex/darwinexapis/issues/2#issuecomment-691989221, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQ6XIL7DOX2PLITHAV7LHITSFX4CRANCNFSM4RLNKBQA .
Hi @AdamAdamsson,
I have again tried with brand new credentials and it works on my side, so I don't know what else could be happening here.
My logs:
[INIT] - Creating AUTH creds...
[INIT] - Access token will be created again at 1600092537.0590665 UNIX timestamp
[DarwinInfoAPI] Getting first 50 DARWINs..
[DECORATOR] - The expiration time has NOT reached yet > Continue...
**** FULL URL ENDPOINT ****: https://api.darwinex.com/darwininfo/2.0/products?status=ACTIVE&page=0&per_page=50
<Response [200]>
{"content":[{"productName":"AAE.5.6","shortName":"AAE","status":"ACTIVE","migrationDate":0,"validationDate":1491074214598,"resetDate":0,"currency":"USD"},{"productName":"AAJ.5.12","shortName":"AAJ","status":"ACTIVE","migrationDate":0,"validationDate":1491163200000,"resetDate":0,"currency":"USD"},{"productName":"AAN.4.2","shortName":"AAN","status":"ACTIVE","migrationDate":0,"validationDate":1491163200000,"resetDate":0,"currency":"EUR"},{"productName":"AAN.5.2","shortName":"AAN","status":"ACTIVE","migrationDate":0,"validationDate":1491163200000,"resetDate":0,"currency":"EUR"},{"productName":"AAO.5.7","shortName":"AAO","status":"ACTIVE","migrationDate":0,"validationDate":1491163200000,"resetDate":0,"currency":"USD"},{"productName":"AAP.5.12","shortName":"AAP","status":"ACTIVE","migrationDate":0,"validationDate":1491817584802,"resetDate":0,"currency":"EUR"},{"productName":"AAY.5.5","shortName":"AAY","status":"ACTIVE","migrationDate":0,"validationDate":1491163200000,"resetDate":0,"currency":"USD"},{"productName":"ABF.4.4","shortName":"ABF","status":"ACTIVE","migrationDate":0,"validationDate":1494235542733,"resetDate":0,"currency":"EUR"},{"productName":"ABF.5.4","shortName":"ABF","status":"ACTIVE","migrationDate":0,"validationDate":1494235542733,"resetDate":0,"currency":"EUR"},{"productName":"ABH.4.21","shortName":"ABH","status":"ACTIVE","migrationDate":1499560262000,"validationDate":1500297536616,"resetDate":0,"currency":"USD"},{"productName":"ABH.5.21","shortName":"ABH","status":"ACTIVE","migrationDate":1499560262000,"validationDate":1500297536616,"resetDate":0,"currency":"USD"},{"productName":"ABK.5.19","shortName":"ABK","status":"ACTIVE","migrationDate":0,"validationDate":1502719270616,"resetDate":0,"currency":"EUR"},{"productName":"ABN.4.6","shortName":"ABN","status":"ACTIVE","migrationDate":0,"validationDate":1511779606914,"resetDate":0,"currency":"EUR"},{"productName":"ABN.5.6","shortName":"ABN","status":"ACTIVE","migrationDate":0,"validationDate":1511779606914,"resetDate":0,"currency":"EUR"},{"productName":"ABO.5.1","shortName":"ABO","status":"ACTIVE","migrationDate":0,"validationDate":1491163200000,"resetDate":0,"currency":"USD"},{"productName":"ABP.5.17","shortName":"ABP","status":"ACTIVE","migrationDate":1500165029000,"validationDate":1500896845659,"resetDate":0,"currency":"USD"},{"productName":"ABT.5.3","shortName":"ABT","status":"ACTIVE","migrationDate":0,"validationDate":1497868739729,"resetDate":0,"currency":"EUR"},{"productName":"ACB.5.22","shortName":"ACB","status":"ACTIVE","migrationDate":0,"validationDate":1520242907747,"resetDate":0,"currency":"EUR"},{"productName":"ACE.4.1","shortName":"ACE","status":"ACTIVE","migrationDate":0,"validationDate":1491058173393,"resetDate":0,"currency":"USD"},{"productName":"ACE.5.1","shortName":"ACE","status":"ACTIVE","migrationDate":0,"validationDate":1491058173393,"resetDate":0,"currency":"USD"},{"productName":"ACG.5.7","shortName":"ACG","status":"ACTIVE","migrationDate":0,"validationDate":1527503604551,"resetDate":0,"currency":"EUR"},{"productName":"ACH.5.6","shortName":"ACH","status":"ACTIVE","migrationDate":0,"validationDate":1491072588807,"resetDate":0,"currency":"USD"},{"productName":"ACM.5.7","shortName":"ACM","status":"ACTIVE","migrationDate":0,"validationDate":1511175473638,"resetDate":0,"currency":"EUR"},{"productName":"ACN.5.6","shortName":"ACN","status":"ACTIVE","migrationDate":0,"validationDate":1501491207975,"resetDate":0,"currency":"EUR"},{"productName":"ACR.5.12","shortName":"ACR","status":"ACTIVE","migrationDate":0,"validationDate":1519036820808,"resetDate":0,"currency":"EUR"},{"productName":"ACS.5.6","shortName":"ACS","status":"ACTIVE","migrationDate":0,"validationDate":1520855974029,"resetDate":0,"currency":"EUR"},{"productName":"ACT.5.5","shortName":"ACT","status":"ACTIVE","migrationDate":0,"validationDate":1491163200000,"resetDate":0,"currency":"USD"},{"productName":"ACU.5.3","shortName":"ACU","status":"ACTIVE","migrationDate":0,"validationDate":1491163200000,"resetDate":0,"currency":"USD"},{"productName":"ACY.4.17","shortName":"ACY","status":"ACTIVE","migrationDate":0,"validationDate":1523866238424,"resetDate":0,"currency":"USD"},{"productName":"ACY.5.17","shortName":"ACY","status":"ACTIVE","migrationDate":0,"validationDate":1523866238424,"resetDate":0,"currency":"USD"},{"productName":"ADB.5.13","shortName":"ADB","status":"ACTIVE","migrationDate":0,"validationDate":1491163200000,"resetDate":0,"currency":"EUR"},{"productName":"ADD.5.23","shortName":"ADD","status":"ACTIVE","migrationDate":1482021026000,"validationDate":1491072650423,"resetDate":0,"currency":"USD"},{"productName":"ADE.5.22","shortName":"ADE","status":"ACTIVE","migrationDate":0,"validationDate":1491163200000,"resetDate":0,"currency":"EUR"},{"productName":"ADH.5.16","shortName":"ADH","status":"ACTIVE","migrationDate":0,"validationDate":1493580146055,"resetDate":0,"currency":"USD"},{"productName":"ADL.5.20","shortName":"ADL","status":"ACTIVE","migrationDate":0,"validationDate":1528112127598,"resetDate":0,"currency":"USD"},{"productName":"ADO.5.14","shortName":"ADO","status":"ACTIVE","migrationDate":0,"validationDate":1491163200000,"resetDate":0,"currency":"USD"},{"productName":"ADU.5.4","shortName":"ADU","status":"ACTIVE","migrationDate":0,"validationDate":1491163200000,"resetDate":0,"currency":"USD"},{"productName":"ADY.5.10","shortName":"ADY","status":"ACTIVE","migrationDate":1517221320000,"validationDate":1517831483779,"resetDate":0,"currency":"USD"},{"productName":"ADZ.5.11","shortName":"ADZ","status":"ACTIVE","migrationDate":0,"validationDate":1499073034936,"resetDate":0,"currency":"USD"},{"productName":"AEB.5.4","shortName":"AEB","status":"ACTIVE","migrationDate":1537662726000,"validationDate":1538988064731,"resetDate":0,"currency":"USD"},{"productName":"AEC.5.8","shortName":"AEC","status":"ACTIVE","migrationDate":0,"validationDate":1512994404273,"resetDate":0,"currency":"EUR"},{"productName":"AED.5.20","shortName":"AED","status":"ACTIVE","migrationDate":0,"validationDate":1553513941116,"resetDate":0,"currency":"USD"},{"productName":"AEE.5.15","shortName":"AEE","status":"ACTIVE","migrationDate":1544315525000,"validationDate":1549878664854,"resetDate":0,"currency":"USD"},{"productName":"AEF.5.9","shortName":"AEF","status":"ACTIVE","migrationDate":0,"validationDate":1547555840887,"resetDate":0,"currency":"EUR"},{"productName":"AEG.5.18","shortName":"AEG","status":"ACTIVE","migrationDate":0,"validationDate":1527498709343,"resetDate":0,"currency":"EUR"},{"productName":"AEK.5.8","shortName":"AEK","status":"ACTIVE","migrationDate":0,"validationDate":1552297398603,"resetDate":0,"currency":"USD"},{"productName":"AEM.5.8","shortName":"AEM","status":"ACTIVE","migrationDate":0,"validationDate":1553513787538,"resetDate":0,"currency":"USD"},{"productName":"AEO.5.16","shortName":"AEO","status":"ACTIVE","migrationDate":0,"validationDate":1491163200000,"resetDate":0,"currency":"EUR"},{"productName":"AEQ.5.23","shortName":"AEQ","status":"ACTIVE","migrationDate":1552782685000,"validationDate":1553513181589,"resetDate":0,"currency":"USD"},{"productName":"AER.5.2","shortName":"AER","status":"ACTIVE","migrationDate":0,"validationDate":1531737667944,"resetDate":0,"currency":"USD"}],"pageable":{"sort":{"sorted":false,"unsorted":true,"empty":true},"pageNumber":0,"pageSize":50,"offset":0,"unpaged":false,"paged":true},"last":false,"totalPages":132,"totalElements":6591,"sort":{"sorted":false,"unsorted":true,"empty":true},"first":true,"numberOfElements":50,"size":50,"number":0,"empty":false}
[DarwinInfoAPI] 132 pages of 50 DARWINs each found.. iterating, stand by! :muscle:
[DarwinInfoAPI] Getting page 2 of 132
My suggestion is that you reach out to info@darwinex.com and ask about your rate limits for the InfoAPI
and if there happens to be any resource forbidden for your username. Attach your logs, the response you get from the REST API
so that they can check it out and the link to this issue.
Another suggestion is that you try to run it outside a Jupyter Notebook. I actually run it on VSCode
for reference.
Best,
Hi, I am experimenting with your API package for Python and using your exemple script DarwinAPIClassesExample.py.
I have activated the following code in the example:
Let's create the access token variable: AUTH_CREDS = {'access_token': 'fe1e00f4-bdf6-313d-915b-3ac4eea325d1', 'consumer_key': 'IR5UvEGyEMK8combIVBLbcof_WMa', 'consumer_secret': 'WKcuZy981a14pmvyj1cPTK6cjo4a', 'refresh_token': '1e109063-4a36-3565-86d6-d9d46c2e7467',}
darwinexInfo = DWX_Info_API(AUTH_CREDS, _version=2.0, _demo=True)
DWX_Info_API: darwinUniverse = darwinexInfo.Get_DARWIN_Universe(_status='ACTIVE', _iterate=True, _perPage=50) pprint.pprint(darwinUniverse) darwinUniverse.to_csv('/Users/Dan/darwin-api-tutorials-master/PYTHON/NOTEBOOKS/12_quant_workflow_algo_trading_darwin_api/darwinUniverse.csv')
When I run the code, I receive the following message:
[INIT] - Creating AUTH creds... [INIT] - Access token will be created again at 1599829976.2918148 UNIX timestamp [INIT] - Creating AUTH creds... [INIT] - Access token will be created again at 1599829976.292811 UNIX timestamp [DarwinInfoAPI] Getting first 50 DARWINs..
[DECORATOR] - The expiration time has NOT reached yet > Continue... FULL URL ENDPOINT : https://api.darwinex.com/darwininfo/2.0/products?status=ACTIVE&page=0&per_page=50 <Response [403]> {"fault":{"code":900908,"message":"Resource forbidden ","description":"Access failure for API: /darwininfo/2.0, version: 2.0 status: (900908) - Resource forbidden "}}
It appears that I need "Authorization: Bearer ACCESS_TOKEN", but I do not know how to do that. I have provided the authorization tokens above that is newly created on https://www.darwinex.com/data/darwin-api.
I would very much appreciate your assistance.