diff --git a/coinmetrics/__init__.py b/coinmetrics/__init__.py index 98dec41..1e8482d 100644 --- a/coinmetrics/__init__.py +++ b/coinmetrics/__init__.py @@ -1 +1 @@ -__version__ = "2024.12.20.17" +__version__ = "2024.12.23.19" diff --git a/default.nix b/default.nix index 2bd1e50..67cdce0 100644 --- a/default.nix +++ b/default.nix @@ -20,7 +20,7 @@ buildPythonPackage rec { pname = "coinmetrics-api-client"; - version = "2024.12.20.17"; + version = "2024.12.23.19"; format = "pyproject"; disabled = pythonOlder "3.9"; diff --git a/docs/docs/CHANGELOG.md b/docs/docs/CHANGELOG.md index 8cb7bd4..7608fb5 100644 --- a/docs/docs/CHANGELOG.md +++ b/docs/docs/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## 2024.12.16.21 +### Added +- pd.DateOffset as a valid data type for `time_increment` in `parallel()` + +### Changed +- Update pandas dependency to >= 2.0 and websocket-client >= 1.6.0 + ## 2024.12.16.21 ### Added - Allowed pandas Timestamp data type to be passed in `client` API calls diff --git a/docs/docs/FlatFilesExport.md b/docs/docs/FlatFilesExport.md index e2b898b..7bcf46b 100644 --- a/docs/docs/FlatFilesExport.md +++ b/docs/docs/FlatFilesExport.md @@ -156,7 +156,7 @@ be limited by egress from the files server as well as the specs of your machine. ### Using the CoinMetricsDataExporter in Python instead of CLI Depending on the use case it might be more convenient to use the CoinMetricsDataExporter directly in Python rather than -from the CLI. There is several examples in the `examples/file_downloads directory`. Below is one example. +from the CLI. There is several examples [here](examples/files_download) as well as one below: ```python from coinmetrics.data_exporter import CoinMetricsDataExporter from datetime import datetime diff --git a/docs/docs/index.md b/docs/docs/index.md index fe5f6fe..cf4b32b 100644 --- a/docs/docs/index.md +++ b/docs/docs/index.md @@ -230,7 +230,7 @@ listed below, there's examples covering all the API methods, found in the [examp * `trades_csv_exporter.py`: Queries market trades data then exports the output into a CSV file. * `trades_json_exporter.py`: Queries market trades data then exports the output into a JSON file. -**[Parallel processing exports](https://github.com/coinmetrics/api-client-python/tree/master/examples/parallel_data_export)** +**[Parallel processing exports](https://github.com/coinmetrics/api-client-python/tree/master/examples/parallel_data_export) * `candles_csv_export.py`: Exports market candles in parallel to many separate csv files * `candles_json_export.py`: Exports market candles in parallel to many separate json files * `market_trades_list.py`: Creates a list of market trades, using `.parallel()` feature to improve performance diff --git a/docs/site/CHANGELOG.html b/docs/site/CHANGELOG.html index 20b6415..986f162 100644 --- a/docs/site/CHANGELOG.html +++ b/docs/site/CHANGELOG.html @@ -50,30 +50,38 @@
time_increment
in parallel()
client
API callsreference_data_*().to_dataframe()
returnformat=json_stream
for catalog
and reference_data
functions by default, drastically improving speedtxids
as a valid parallelize_on
variablecatalog_*_v2().to_dataframe()
that flattens these dataframesbase_native
and quote_native
fields to reference_data_markets()
on_error
for CmStream
defaultcatalog
deprecationtxid
, accounts
, block_hashes
, heights
, and sub_accounts
as valid parallel
variablesheight_increment
as a valid parallel
parameterto_dataframe()
call for reference_data_*
and security_master_*
functionsget_market_funding_rates_predicted
, catalog_{full}_market_funding_rates_predicted_v2
blockchain_metadata_tags()
and blockchain_metadata_tagged_entities
functionsget_snapshots_of_asset_metric_constituents
and get_timeframes_of_asset_metric_constituents
get_stream_market_open_interest
get_stream_market_liquidations
metrics
parameter to catalog_{full}_markets_v2
catalog_index_levels_v2
and reference_data_markets
blockchain
endpointsfrequency
parameter with granularity
for get_market_quotes
and get_market_orderbooks
reference_data_assets
, reference_data_indexes
, reference_data_pairs
security_master_assets
, security_master_markets
catalog_{full}_pair_candles_v2
, catalog_{full}_index_candles_v2
, catalog_{full}_asset_chains_v2
, catalog_{full}_mempool_feerates_v2
, catalog_{full}_mining_pool_tips_summaries_v2
, catalog_{full}_transaction_tracker_assets_v2
reference_data_asset_metrics
, reference_data_institution_metrics
catalog_{full}_asset_metrics_v2
, catalog_exchange_{full}_metrics_v2
, catalog_{full}_exchange_asset_metrics_v2
, catalog_{full}_pair_metrics_v2
, catalog_{full}_institution_metrics_v2
on_close
handler to CmStream
catalog_{full}_contract_prices_v2
, catalog_{full}_market_trades_v2
, catalog_{full}_market_candles_v2
, catalog_{full}_market_orderbooks_v2
, catalog_{full}_market_quotes_v2
, catalog_{full}_market_funding_rates_v2
, catalog_{full}_market_contract_prices_v2
, catalog_{full}_market_implied_volatility_v2
, catalog_{full}_market_greeks_v2
, catalog_{full}_market_open_interest
, catalog_{full}_market_liquidations_v2
, catalog_{full}_market_metrics_v2
.The tool is installed a long with the coinmetrics-api-client
, it's recommended to create a new Python [virtual environment]
for your project and install the package:
python -m venv .venv
+python -m venv .venv
source .venv/bin/activate
-pip install coinmetrics-api-client
+pip install coinmetrics-api-client
+
The export tool requires access to a CoinMetrics API key, and is accessed with the environment variable CM_API_KEY
,
the easiest way to set this is to run export CM_API_KEY=<API_KEY>
in your terminal on MacOS/Linux or just set CM_API_KEY=<API_KEY>
on Windows. Additionally, you have the option of passing it in which each command instead.
To confirm the tool is installed correct execute the command coinmetrics export --help
which brings up relevant
documentation. At the bottom of the help message all the available commands are shown:
-
Commands:
+Commands:
get-asset-pairs
get-exchanges
market-candles-future Used to export data related to future market...
@@ -111,11 +112,12 @@ Installation and set up
+ market-trades-spot Used to export data related to spot market trades.
+
Exporting Market Trades Files¶
Further documentation is available on any of the commands by running coinmetrics export <command> --help
, for example
running coinmetrics export market-trades-spot --help
prints:
-
Usage: coinmetrics export market-trades-spot [OPTIONS] EXCHANGES [START_DATE]:
+Usage: coinmetrics export market-trades-spot [OPTIONS] EXCHANGES [START_DATE]:
[%Y-%m-%d|%Y-%m-%dT%H:%M:%S|%Y-%m
-%d %H:%M:%S] [END_DATE]:[%Y-%m-%
d|%Y-%m-%dT%H:%M:%S|%Y-%m-%d
@@ -141,12 +143,12 @@ Exporting Market Trades Files¶
If you want to get the flat files for spot-market-trades from coinbase and binance for the first 5 days of June 2022:
coinmetrics export market-trades-spot binance,coinbase 2022-06-01 2022-06-05
In your current directory you will see:
-
market-trades-spot
+market-trades-spot
├── binance
│ ├── 2022-06-01.json.gz
│ ├── 2022-06-02.json.gz
@@ -158,7 +160,8 @@ Example:gzipped json files - they are compressed in
order to take up less space. If you instead wish to download the data as a csv or json you can use:
coinmetrics export market-trades-spot binance,coinbase 2022-06-01 2022-06-05 --output-format csv
@@ -183,7 +186,7 @@ Exporting market candlesExample to download 5m spot market candles for coinbase and binance for a date range:
coinmetrics export market-candles-spot 5m coinbase,binance 2022-01-01 2022-01-05
Which creates these files:
-market-candles-spot-5m
+market-candles-spot-5m
├── binance
│ ├── 2022-01-01.json.gz
│ ├── 2022-01-02.json.gz
@@ -195,7 +198,8 @@ Exporting market candles
+ └── 2022-01-05.json.gz
+
The functionality is the same for market-candles-future
Using API Key without setting an environment variable¶
If you don't wish to put your CoinMetrics API key in your environment, you may also pass it in with any command with the
@@ -209,21 +213,22 @@
Downloading files in parallelUsing the CoinMetricsDataExporter in Python instead of CLI¶
Depending on the use case it might be more convenient to use the CoinMetricsDataExporter directly in Python rather than
-from the CLI. There is several examples in the examples/file_downloads directory
. Below is one example.
-
from coinmetrics.data_exporter import CoinMetricsDataExporter
-from datetime import datetime
+from the CLI. There is several examples here as well as one below:
+from coinmetrics.data_exporter import CoinMetricsDataExporter
+from datetime import datetime
-CM_API_KEY = "<YOUR_API_KEY>"
-data_exporter = CoinMetricsDataExporter(api_key=CM_API_KEY)
+CM_API_KEY = "<YOUR_API_KEY>"
+data_exporter = CoinMetricsDataExporter(api_key=CM_API_KEY)
-if __name__ == "__main__":
- """
- This script will export all the daily market-trades-spot files for Coinbase and Gemini for the month of January
- """
- start_date = datetime(2019, 1, 1)
- end_date = datetime(2019, 1, 31)
- exchanges = ["coinbase","gemini"]
- data_exporter.export_market_trades_spot_data(start_date=start_date, end_date=end_date, exchanges=exchanges, threaded=True)
+if __name__ == "__main__":
+ """
+ This script will export all the daily market-trades-spot files for Coinbase and Gemini for the month of January
+ """
+ start_date = datetime(2019, 1, 1)
+ end_date = datetime(2019, 1, 31)
+ exchanges = ["coinbase","gemini"]
+ data_exporter.export_market_trades_spot_data(start_date=start_date, end_date=end_date, exchanges=exchanges, threaded=True)
+