# crypto-msg-parser
Python bindings for the [crypto-msg-parser](https://github.com/crypto-crawler/crypto-crawler-rs/tree/main/crypto-msg-parser) library.
## Install
```bash
pip3 install crypto-msg-parser
```
## Quickstart
```python
from crypto_msg_parser import MarketType, parse_trade
json_arr = parse_trade("binance", MarketType['inverse_swap'], '{"stream":"btcusd_perp@aggTrade","data":{"e":"aggTrade","E":1616201883458,"a":41045788,"s":"BTCUSD_PERP","p":"58570.1","q":"58","f":91864326,"l":91864327,"T":1616201883304,"m":true}}')
assert len(json_arr) == 1
trade = json_arr[0]
assert trade['exchange'] == 'binance'
assert trade['market_type'] == 'inverse_swap'
assert trade['msg_type'] == 'trade'
assert trade['price'] == 58570.1
assert trade['quantity_base'] == 5800.0 / 58570.1
assert trade['quantity_quote'] == 5800.0
assert trade['quantity_contract'] == 58.0
assert trade['side'] == 'sell'
```
Another example, parsing the output of `crypto-crawler`:
```python
from crypto_crawler import MarketType, crawl_trade
from crypto_msg_parser import MarketType, parse_trade
crawl_trade(
"binance",
MarketType.Spot,
["BTCUSDT", "ETHUSDT"],
lambda msg: print(parse_trade(msg.exchange, msg.market_type, msg.json))
)
```
Raw data
{
"_id": null,
"home_page": "https://github.com/soulmachine/crypto-msg-parser-py",
"name": "crypto-msg-parser",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "blockchain,cryptocurrency,trading",
"author": "soulmachine",
"author_email": "",
"download_url": "",
"platform": null,
"description": "# crypto-msg-parser\n\nPython bindings for the [crypto-msg-parser](https://github.com/crypto-crawler/crypto-crawler-rs/tree/main/crypto-msg-parser) library.\n\n## Install\n\n```bash\npip3 install crypto-msg-parser\n```\n\n## Quickstart\n\n```python\nfrom crypto_msg_parser import MarketType, parse_trade\n\njson_arr = parse_trade(\"binance\", MarketType['inverse_swap'], '{\"stream\":\"btcusd_perp@aggTrade\",\"data\":{\"e\":\"aggTrade\",\"E\":1616201883458,\"a\":41045788,\"s\":\"BTCUSD_PERP\",\"p\":\"58570.1\",\"q\":\"58\",\"f\":91864326,\"l\":91864327,\"T\":1616201883304,\"m\":true}}')\n\nassert len(json_arr) == 1\ntrade = json_arr[0]\nassert trade['exchange'] == 'binance'\nassert trade['market_type'] == 'inverse_swap'\nassert trade['msg_type'] == 'trade'\nassert trade['price'] == 58570.1\nassert trade['quantity_base'] == 5800.0 / 58570.1\nassert trade['quantity_quote'] == 5800.0\nassert trade['quantity_contract'] == 58.0\nassert trade['side'] == 'sell'\n```\n\nAnother example, parsing the output of `crypto-crawler`:\n\n```python\nfrom crypto_crawler import MarketType, crawl_trade\nfrom crypto_msg_parser import MarketType, parse_trade\n\ncrawl_trade(\n \"binance\",\n MarketType.Spot,\n [\"BTCUSDT\", \"ETHUSDT\"],\n lambda msg: print(parse_trade(msg.exchange, msg.market_type, msg.json))\n)\n```\n\n\n\n",
"bugtrack_url": null,
"license": "Apache License 2.0",
"summary": "Parse websocket messages from cryptocurreny exchanges",
"version": "2.8.16",
"split_keywords": [
"blockchain",
"cryptocurrency",
"trading"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "4ac3238663420b8e1a39e3d7b3cb4e8d73e1ba6f92d6031cc1fb727419058f1f",
"md5": "bc98a4836299a9344b7339d36a77bab2",
"sha256": "73ca2f9fe4efe2c13b8aa5b59ed49668cfb99cee5f55f38c95920cec8a32fe0e"
},
"downloads": -1,
"filename": "crypto_msg_parser-2.8.16-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"has_sig": false,
"md5_digest": "bc98a4836299a9344b7339d36a77bab2",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 5070846,
"upload_time": "2023-01-06T11:16:33",
"upload_time_iso_8601": "2023-01-06T11:16:33.529488Z",
"url": "https://files.pythonhosted.org/packages/4a/c3/238663420b8e1a39e3d7b3cb4e8d73e1ba6f92d6031cc1fb727419058f1f/crypto_msg_parser-2.8.16-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-01-06 11:16:33",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "soulmachine",
"github_project": "crypto-msg-parser-py",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "crypto-msg-parser"
}