Adapting Avellaneda & Stoikov market making using ccxt for KuCoin
Influced by this repo: https://github.com/fedecaccia/avellaneda-stoikov
This project implements a simulation of high-frequency trading using the Avellaneda-Stoikov market-making model. The simulation utilizes Brownian motion to model stock price dynamics and implements market-making strategies to manage inventory and optimize profit.
This is the main script that orchestrates the simulation. It initializes the market maker, simulates trading scenarios, and visualizes the results using Matplotlib.
Contains the implementation of the Brownian motion simulation, which is essential for modeling stock price movements over time.
Provides an example of generating a single realization of Brownian motion and plotting it using Matplotlib. This can be useful for understanding the stochastic process used in the simulation.
Lists all the Python libraries and their versions required to run the project. Use pip install -r requirements.txt
to install them.
-
Clone the repository:
git clone https://github.com/your_username/avellaneda-stoikov-market-making.git cd avellaneda-stoikov-market-making
-
Install dependencies:
pip install -r requirements.txt
To run the simulation with default settings (symbol: BTC/USDT, 100 simulations):
python main.py
You can customize the simulation by modifying parameters in main.py
:
- Adjust
n_sim
insimulate()
method to change the number of simulations. - Modify parameters such as
sigma
,T
,N
,dt
,gamma
,k
in thesimulate()
method to explore different scenarios.
To visualize a single realization of Brownian motion:
python brownian_path.py
This will plot the path of Brownian motion over a specified time interval.
The simulation results include:
- Final inventory held
- Last price observed
- Cash balance
- Final wealth (cash + inventory value)
- Maximum and minimum inventory held during the simulation
- Average and standard deviation of Profit and Loss (PnL) across simulations
The parameters used in the simulations can be found and adjusted in main.py
. These include:
sigma
: Volatility of the stockT
: Total time period of simulationN
: Number of steps in the simulationdt
: Time step sizegamma
: Risk factor influencing bid/ask spreadk
: Market model parameter influencing intensity of order placement
This project is licensed under the MIT License - see the LICENSE file for details.
- Federico Caccia https://github.com/fedecaccia/avellaneda-stoikov
- Marco Avellaneda & Sasha Stoikov for their pioneering work on market making models.
- Open-source libraries: CCXT, NumPy, Matplotlib, and SciPy and ChatGPT