Skip to main content

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.

Metadata

Release files for mktstructure 0.2.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mktstructure 0.2.11
File Size Uploaded Provenance Actions
mktstructure-0.2.11.tar.gz 20.1 kB Without provenance Details for mktstructure-0.2.11.tar.gz

Release files / mktstructure-0.2.11.tar.gz

Download URL mktstructure-0.2.11.tar.gz
Size 20.1 kB
Tags Source
SHA-256 checksum
How to use checksums
2d61363f91440803edd3f924c7e4f4b6d55f4e4782ba8027628ab64a15c79316
BLAKE2b-256 checksum
How to use checksums
94d856935d8c3dbd2967a23cf6eb203d6f9b62c4b4263374276cd8904371902d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Security for mktstructure 0.2.11

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page