Initial commit

This commit is contained in:
Yaser
2026-08-13 19:50:53 +03:30
commit 38084458fe
879 changed files with 95198 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
# encoding: UTF-8
# frozen_string_literal: true
describe Matching::LimitOrder do
context 'initialize' do
it 'should throw invalid order error for empty attributes' do
expect do
Matching::LimitOrder.new(type: '', price: '', volume: '')
end.to raise_error(Matching::OrderError)
end
it 'should initialize market' do
expect(Matching.mock_limit_order(type: :bid).market).to eq 'btcusd'
end
end
context 'crossed?' do
it 'should cross at lower or equal price for bid order' do
order = Matching.mock_limit_order(type: :bid, price: '10.0'.to_d)
expect(order.crossed?('9.0'.to_d)).to be true
expect(order.crossed?('10.0'.to_d)).to be true
expect(order.crossed?('11.0'.to_d)).to be false
end
it 'should cross at higher or equal price for ask order' do
order = Matching.mock_limit_order(type: :ask, price: '10.0'.to_d)
expect(order.crossed?('9.0'.to_d)).to be false
expect(order.crossed?('10.0'.to_d)).to be true
expect(order.crossed?('11.0'.to_d)).to be true
end
end
end