Simulate financial markets
Project description
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
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:
pip install pymicrostructure
Quick Start
Here's a simple example to get you started with pymicrostructure:
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.
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 file for details on how to contribute, report issues, or suggest enhancements.
License
pymicrostructure is released under the MIT License. See the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pymicrostructure-0.0.2.tar.gz
.
File metadata
- Download URL: pymicrostructure-0.0.2.tar.gz
- Upload date:
- Size: 26.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0588b9b7aa408e50528a8cac11ab1d4a7cb6b6fd20fb424f71fe2d6219846a2c |
|
MD5 | e22f8840a5f17524f068836d1ce95fed |
|
BLAKE2b-256 | 150e4221a804c72120129de529dfc45d131f52a090f4735e5814b39126be3b00 |
File details
Details for the file pymicrostructure-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: pymicrostructure-0.0.2-py3-none-any.whl
- Upload date:
- Size: 28.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ed9eec183302933f894f6106c2a6fcdcba3187bddc6ad5cc40c476109ed8f0c |
|
MD5 | 861983e4a80ba966574d3ba925fecfcf |
|
BLAKE2b-256 | 936325b7cc77f44902e38a0cb9e3c79a9eef4acc6d8d8f2f1ca3a426363f6ceb |