https://github.com/jmcph4/pyobsim
A Python module for market simulation
https://github.com/jmcph4/pyobsim
finance fintech limit-order-book lob market market-simulator order-book python simulation simulator stock-market stock-price-prediction trading
Last synced: 19 days ago
JSON representation
A Python module for market simulation
- Host: GitHub
- URL: https://github.com/jmcph4/pyobsim
- Owner: jmcph4
- License: mit
- Created: 2016-10-03T11:45:14.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2025-01-11T08:55:43.000Z (3 months ago)
- Last Synced: 2025-03-22T10:42:36.659Z (about 1 month ago)
- Topics: finance, fintech, limit-order-book, lob, market, market-simulator, order-book, python, simulation, simulator, stock-market, stock-price-prediction, trading
- Language: Python
- Size: 38.1 KB
- Stars: 23
- Watchers: 3
- Forks: 10
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/jmcph4/PyOBSim)
# PyOBSim - the Python Order Book Simulator #
---PyOBSim is a Python module facilitating market simulation by implementing an order book and other utilities. PyOBSim aims to make testing of trading algorithms clean and simple.
Running simulations is straightforward: simply provide an order flow and fire away:
from pyobsim import *
# build our participants
alice = participant.Participant("Alice", 100, 0) # $100, no units
bob = participant.Participant("Bob", 0, 120) # $0, 120 units
sim = simulation.Simulation("My Simulation", [], [alice, bob])
sim.load("order_flow.csv") # load our order flow from CSV file
sim.run()
print(sim)This gives us our summary:
Simulation
My Simulation
---
Statement of Accounts
Alice: $100.0 with 0 units
Bob: $0.0 with 120 units
---
Market as at present
'GOOG'If we want to inspect the book for `GOOG`:
print(sim.books["GOOG"])
We get:
Book for GOOG
Spread is $0.5
===
Ask
Price Quantity
--------------------------------------------------------------------------------
$1.0 100 |
|$0.5 10
--------------------------------------------------------------------------------
Price Quantity
Bid