orderbook.cr v0.1.0
Orderbook
An extensible limit order book model written in Crystal.
Designed to be used in live trading and backtesting market making strategies.
It uses the Dense Tick Format for all ticks and orders in an effort to keep the API somewhat uniform.
Installation
-
Add the dependency to your
shard.yml
:dependencies: orderbook: github: nolantait/orderbook.cr
-
Run
shards install
Usage
require "orderbook"
require "big"
book = Orderbook::Partial.new
book.on Orderbook::LimitOrderFilled do |order|
puts "ORDER FILLED"
end
sell_order = Orderbook::LimitOrder.new(
id: "1",
is_bid: false,
quantity: BigDecimal.new(0.5),
price: BigDecimal.new(0.1)
)
tick = Tick.new(
timestamp: 123456,
is_trade: true,
is_bid: true,
price: BigDecimal.new(0.1),
quantity: BigDecimal.new(1)
)
book.add_order sell_order
book.emit tick
OR you could initialize a simple book with just the best bid/ask:
book = Orderbook::Simple.new
tick = Tick.new(
timestamp: 123456,
is_trade: false,
is_bid: true,
price: BigDecimal.new(0.1),
quantity: BigDecimal.new(1)
)
book.emit tick
The above would set the book.best_bid
to equal the new tick
Development
shards install
and then crystal specs
Contributing
- Fork it (https://github.com/nolantait/orderbook/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Contributors
- Nolan J Tait - creator and maintainer
Repository
orderbook.cr
Owner
Statistic
- 2
- 0
- 0
- 0
- 1
- over 2 years ago
- March 27, 2022
License
MIT License
Links
Synced at
Thu, 07 Nov 2024 05:50:44 GMT
Languages