# mktstructure
A simple command-line tool to download data from Refinitiv Tick History and compute some market microstructure measures.
## Installation
You can install `mktstructure` via `pip`:
``` bash
pip install mktstructure
```
## Quick Start
Use `-h` or `--help` to see the usage instruction:
``` bash
$ mktstructure -h
usage: mktstructure [OPTION]...
Download data from Refinitiv Tick History and compute some market microstructure measures.
optional arguments:
-h, --help show this help message and exit
-v, --version show program's version number and exit
Sub-commands:
Choose one from the following. Use `mktstructure subcommand -h` to see help for each sub-command.
{download,clean,classify,compute}
download Download data from Refinitiv Tick History
clean Clean downloaded data
classify Classify ticks into buy and sell orders
compute Compute market microstructure measures
```
### 1. Download data
Let's download the tick history for all S&P500 component stocks from Jan 1, 2022, to Jan 31, 2022:
``` bash
mktstructure download -u {username} -p {password} --sp500 --parse --data_dir "./data" -b 2022-01-01 -e 2022-01-31
```
where `{username}` and `{password}` are the login credentials of Refinitiv DataScope Select.
Note that we set the `--parse` flag to parse the downloaded data (gzip) into csv files by stock and date into the `./data` folder.
### 2. Clean data
Then we clean the downloaded and parsed data in the `./data` folder: sorting by time, removing duplicates, etc.
``` bash
mktstructure clean --all --data_dir "./data" --replace
```
The ``--replace`` flag, if set, asks the program to replace the data file with the cleaned one to save disk space.
### 3. Classify trade directions
Use the `classify` subcommand to classify trades into buys and sells by the Lee and Ready (1991) algorithm.
``` bash
mktstructure classify --all --data_dir "./data"
```
### 4. Compute
Lastly, use the `compute` subcommand to compute specified market microstructure measures:
``` bash
mktstructure compute --all --data_dir "./data" --out bidaskspread.csv --bid_ask_spread
```
## Note
This tool is still a work in progress. Some breaking changes may be expected but will be kept minimal.
Raw data
{
"_id": null,
"home_page": "https://github.com/mgao6767/mktstructure",
"name": "mktstructure",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "Mingze Gao",
"author_email": "mingze.gao@sydney.edu.au",
"download_url": "https://files.pythonhosted.org/packages/56/58/522447f2952220d4cac3f515597bfad9f5a930721696972faae94957f3ab/mktstructure-0.2.9.tar.gz",
"platform": null,
"description": "# mktstructure\n\nA simple command-line tool to download data from Refinitiv Tick History and compute some market microstructure measures.\n\n## Installation\n\nYou can install `mktstructure` via `pip`:\n\n``` bash\npip install mktstructure\n```\n\n## Quick Start\n\nUse `-h` or `--help` to see the usage instruction:\n\n``` bash\n$ mktstructure -h\nusage: mktstructure [OPTION]...\n\nDownload data from Refinitiv Tick History and compute some market microstructure measures.\n\noptional arguments:\n -h, --help show this help message and exit\n -v, --version show program's version number and exit\n\nSub-commands:\n Choose one from the following. Use `mktstructure subcommand -h` to see help for each sub-command.\n\n {download,clean,classify,compute}\n download Download data from Refinitiv Tick History\n clean Clean downloaded data\n classify Classify ticks into buy and sell orders\n compute Compute market microstructure measures\n```\n\n### 1. Download data\n\nLet's download the tick history for all S&P500 component stocks from Jan 1, 2022, to Jan 31, 2022:\n\n``` bash\nmktstructure download -u {username} -p {password} --sp500 --parse --data_dir \"./data\" -b 2022-01-01 -e 2022-01-31\n```\n\nwhere `{username}` and `{password}` are the login credentials of Refinitiv DataScope Select.\n\nNote that we set the `--parse` flag to parse the downloaded data (gzip) into csv files by stock and date into the `./data` folder.\n\n### 2. Clean data\n\nThen we clean the downloaded and parsed data in the `./data` folder: sorting by time, removing duplicates, etc.\n\n``` bash\nmktstructure clean --all --data_dir \"./data\" --replace\n```\n\nThe ``--replace`` flag, if set, asks the program to replace the data file with the cleaned one to save disk space.\n\n### 3. Classify trade directions\n\nUse the `classify` subcommand to classify trades into buys and sells by the Lee and Ready (1991) algorithm.\n\n``` bash\nmktstructure classify --all --data_dir \"./data\"\n```\n\n### 4. Compute\n\nLastly, use the `compute` subcommand to compute specified market microstructure measures:\n\n``` bash\nmktstructure compute --all --data_dir \"./data\" --out bidaskspread.csv --bid_ask_spread\n```\n\n## Note\n\nThis tool is still a work in progress. Some breaking changes may be expected but will be kept minimal.",
"bugtrack_url": null,
"license": "MIT",
"summary": "Download data from Refinitiv Tick History and compute some market microstructure measures.",
"version": "0.2.9",
"project_urls": {
"Homepage": "https://github.com/mgao6767/mktstructure"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "5658522447f2952220d4cac3f515597bfad9f5a930721696972faae94957f3ab",
"md5": "e0236e0edefbcf589abe431266fbf071",
"sha256": "beda19b5132b8c2de16861aad8214a631e8bbc6041eec30f74ac4aa447d3e079"
},
"downloads": -1,
"filename": "mktstructure-0.2.9.tar.gz",
"has_sig": false,
"md5_digest": "e0236e0edefbcf589abe431266fbf071",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 19989,
"upload_time": "2023-05-10T03:39:29",
"upload_time_iso_8601": "2023-05-10T03:39:29.833985Z",
"url": "https://files.pythonhosted.org/packages/56/58/522447f2952220d4cac3f515597bfad9f5a930721696972faae94957f3ab/mktstructure-0.2.9.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-05-10 03:39:29",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "mgao6767",
"github_project": "mktstructure",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "mktstructure"
}