This repository has been archived by the owner on Aug 26, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 110
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Cache results
Requests of the form ticker/bitcoin?param cause a 301 redirect from the coinmarketcap API. The correct endpoint is ticker/bitcoin/?param (with a '/') between the currency symbol and the ?param. (Refer https://coinmarketcap.com/api/)
Add a '/' after the currency id for api requests
Adds a 'tempdir_cache' boolean option to the Market class which allows the cached market data to be saved to the system temp directory rather than the current working directory. This avoids polluting the working directory with a short-term file that the user likely doesn't need to be able to directly access themselves. By default the tempdir is not used (for backwards compatibility) and has to be explicitly requested by passing 'tempdir_cache = True' when instantiating a Market object.
Allow saving cache data to a temp directory
The ticker method now accepts a 'symbol' paramater. If a currency id is not specified but symbol is, then the appropriate currency id is automatically chosen for the request to the coinmarketcap api. The mappings of currency symbols to currency ids are stored in a 'symbol.json' data file. This is generated using the 'get_symbols.py' script. The data file is static for a given release of the library. Users are not expected to update the data file. To keep the library up to date with new currencies, the 'get_symbols' script should be run from time to time and the update 'symbols.json' file should be moved into the data folder and a new release pushed.
Adds the necessary setup information to ensure the 'symbols.json' data file is included when the package is installed.
Adds a 'Developer' section to the readme with instructions on using 'get_symbols.py' to update 'symbols.json'.
As pointed out by @jorijnsmit, multiple coins can share the same symbol. Allowing such coins to be looked up by symbol would lead to ambiguity about exactly which coin is being requested. The 'get_symbols.py' script has been modified to detect such symbol collisions and exclude them from the symbol lookup dictionary. Attempting to lookup one of those symbols will lead to an error being raised (just as if such a symbol doesn't exist at all). Those coins with colliding symbols can still be looked up by id. When 'get_symbols.py' is run it creates a file 'collisions.log' which lists all collisions. It should be manually copied to 'docs/'.
Small change to keep the symbols in collisions.log sorted alphabetically for better readability.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See #33
The ticker method now accepts a 'symbol' paramater. If a currency id
is not specified but symbol is, then the appropriate currency id is
automatically chosen for the request to the coinmarketcap api.
The mappings of currency symbols to currency ids are stored in a
'symbol.json' data file. This is generated using the 'get_symbols.py'
script. The data file is static for a given release of the library.
Users are not expected to update the data file.
To keep the library up to date with new currencies, the 'get_symbols'
script should be run from time to time and the update 'symbols.json'
file should be moved into the data folder and a new release pushed.