Metadata-Version: 2.1
Name: pymicrostructure
Version: 0.0.2
Summary: Simulate financial markets
Author-email: Bartosz Bieganowski <bartosz.bieganowski.office@gmail.com>
License: Copyright (c) 2024, ROBUST GAMMA BARTOSZ BIEGANOWSKI
        
        Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Project-URL: Homepage, https://github.com/BBieganowski/pymicrostructure
Keywords: finance,quant,trading
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE.md
Requires-Dist: feedparser >=5.2.0
Requires-Dist: html2text
Requires-Dist: numpy >=2.0.0
Requires-Dist: pandas >=2.0.0
Requires-Dist: matplotlib >=3.9.0
Requires-Dist: tqdm >=4.0.0
Requires-Dist: dill >=0.3.4
Requires-Dist: scipy >=1.7.0
Requires-Dist: statsmodels >=0.13.0
Requires-Dist: seaborn >=0.11.2
Requires-Dist: tomli ; python_version >= "3.11"
Provides-Extra: dev
Requires-Dist: black ; extra == 'dev'
Requires-Dist: bumpver ; extra == 'dev'
Requires-Dist: isort ; extra == 'dev'
Requires-Dist: pip-tools ; extra == 'dev'
Requires-Dist: pytest ; extra == 'dev'

# PyMicrostructure

pymicrostructure is a powerful Python library for simulating and analyzing financial market microstructure. It provides a flexible framework for modeling various market participants, implementing trading strategies, and evaluating market performance metrics.

## Table of Contents

1. [Features](#features)
2. [Installation](#installation)
3. [Quick Start](#quick-start)
4. [Documentation](#documentation)
5. [Examples](#examples)
6. [Contributing](#contributing)
7. [License](#license)

## Features

- Flexible market simulation framework
- Various trader types (e.g., informed traders, noise traders, market makers)
- Customizable trading strategies
- Comprehensive set of market performance metrics
- Order book visualization tools
- Easy-to-use API for creating and running simulations

### Key Components

- **Markets**: Implement different market models (e.g., continuous double auction)
- **Traders**: Model various types of market participants
- **Orders**: Support for different order types (e.g., market orders, limit orders)
- **Strategies**: Implement and test different trading strategies
- **Metrics**: Analyze market efficiency, liquidity, and other performance indicators

## Installation

To install pymicrostructure, run the following command:

```bash
pip install pymicrostructure
```

## Quick Start

Here's a simple example to get you started with pymicrostructure:

```python
from pymicrostructure.markets.continuous import ContinuousDoubleAuction
from pymicrostructure.traders.market_maker import *
from pymicrostructure.traders.informed import *
from pymicrostructure.traders.noise import *
from pymicrostructure.traders.strategy import *

from pymicrostructure.visualization.summary import participant_comparison, price_path
from pymicrostructure.metrics.trader import participants_report

market   = ContinuousDoubleAuction(initial_fair_price=1000)
mm       = BaseMarketMaker(market,
                           fair_price_strategy=OrderFlowMagnitudeFairPrice(window=10, aggressiveness=1),
                           volume_strategy=MaxFractionVolume(fraction=0.1), 
                           spread_strategy=OrderFlowImbalanceSpread(window=5, aggressiveness=10, min_halfspread=3),
                           max_inventory=1000)

informed = TWAPInformedTrader(market)
noise    = NoiseTrader(market, submission_rate=1, volume_size=lambda:np.random.randint(1, 5))

market.run(300)
participant_comparison(market.participants)
price_path(market)
```

## Documentation

For detailed documentation, please visit our [documentation site](https://pymicrostructure.readthedocs.io).

## Examples

You can find more examples in the `examples/` directory of this repository. These examples cover various scenarios and use cases, such as:

- Implementing custom trading strategies
- Analyzing market liquidity
- Visualizing order book dynamics
- Comparing performance of different trader types

## Contributing

We welcome contributions to pymicrostructure! Please see our [CONTRIBUTING.md](CONTRIBUTING.md) file for details on how to contribute, report issues, or suggest enhancements.

## License

pymicrostructure is released under the MIT License. See the [LICENSE](LICENSE) file for details.
