fin 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +26 -0
- data/HISTORY +27 -0
- data/LICENSE +20 -0
- data/README.rdoc +36 -0
- data/Rakefile +25 -0
- data/VERSION +1 -0
- data/features/order_book.feature +9 -0
- data/features/step_definitions/order_book_steps.rb +0 -0
- data/features/support/env.rb +10 -0
- data/features/support/world.rb +12 -0
- data/lib/fin.rb +13 -0
- data/lib/fin/book.rb +50 -0
- data/lib/fin/book_manager.rb +42 -0
- data/lib/fin/changed_list.rb +49 -0
- data/lib/fin/container_list.rb +33 -0
- data/lib/fin/deal_list.rb +18 -0
- data/lib/fin/indexed_list.rb +74 -0
- data/lib/fin/models/deal.rb +75 -0
- data/lib/fin/models/instrument.rb +78 -0
- data/lib/fin/models/model.rb +39 -0
- data/lib/fin/models/money_limit.rb +81 -0
- data/lib/fin/models/order.rb +45 -0
- data/lib/fin/models/position.rb +57 -0
- data/lib/fin/order_list.rb +17 -0
- data/lib/legacy.rb +443 -0
- data/lib/version.rb +8 -0
- data/spec/fin/book_spec.rb +215 -0
- data/spec/fin/changed_list_spec.rb +16 -0
- data/spec/fin/container_list_spec.rb +63 -0
- data/spec/fin/deal_list_spec.rb +102 -0
- data/spec/fin/indexed_list_spec.rb +20 -0
- data/spec/fin/models/deal_spec.rb +140 -0
- data/spec/fin/models/instrument_spec.rb +54 -0
- data/spec/fin/models/model_spec.rb +109 -0
- data/spec/fin/models/money_limit_spec.rb +143 -0
- data/spec/fin/models/order_spec.rb +67 -0
- data/spec/fin/models/position_spec.rb +74 -0
- data/spec/fin/models/shared_examples.rb +5 -0
- data/spec/fin/order_list_spec.rb +140 -0
- data/spec/fin/shared_examples.rb +355 -0
- data/spec/spec_helper.rb +17 -0
- data/tasks/common.rake +18 -0
- data/tasks/doc.rake +14 -0
- data/tasks/gem.rake +40 -0
- data/tasks/git.rake +34 -0
- data/tasks/spec.rake +16 -0
- data/tasks/version.rake +71 -0
- metadata +155 -0
data/lib/version.rb
ADDED
@@ -0,0 +1,215 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fin/shared_examples.rb'
|
3
|
+
|
4
|
+
describe Fin::Book, 'as a replacement for OrderBook' do
|
5
|
+
subject { Fin::Book.new :item_type => Fin::Order,
|
6
|
+
:book_index => proc { |item| item.price },
|
7
|
+
:book_condition => proc { |item| item.price > 0},
|
8
|
+
:isin_id => 123456 }
|
9
|
+
|
10
|
+
let(:item_index) { @item.price }
|
11
|
+
|
12
|
+
before(:each) do
|
13
|
+
@item = Fin::Order.new :id => 0, :price => 20, :isin => 123456
|
14
|
+
@item1 = Fin::Order.new :id => 1, :price => 15, :isin => 123456
|
15
|
+
@item2 = Fin::Order.new :id => 2, :price => 10, :isin => 123456
|
16
|
+
@zero_price_item = Fin::Order.new :id => 3, :price => 0, :isin => 123456
|
17
|
+
@wrong_isin_item = Fin::Order.new :id => 4, :price => 50, :isin => 456123
|
18
|
+
end
|
19
|
+
|
20
|
+
it_behaves_like 'changed_list'
|
21
|
+
|
22
|
+
its (:isin_id) {should == 123456}
|
23
|
+
its (:isin) {should == 123456}
|
24
|
+
its (:changed) {should == true}
|
25
|
+
|
26
|
+
it 'is possible to set its #changed attribute' do
|
27
|
+
subject.changed = false
|
28
|
+
subject.changed.should == false
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'but #isin(_id) attribute is not settable' do
|
32
|
+
expect { subject.isin_id = 1313 }.to raise_error NoMethodError
|
33
|
+
expect { subject.isin = 1313 }.to raise_error NoMethodError
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '#check' do
|
37
|
+
it 'fails if item is not an Order' do
|
38
|
+
subject.check(1).should == false
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'fails if item has wrong isin_id' do
|
42
|
+
subject.check(@wrong_isin_item).should == false
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'fails if item.price <= 0' do
|
46
|
+
subject.check(@zero_price_item).should == false
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'returns true otherwise' do
|
50
|
+
subject.check(@item).should == true
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe 'adding item' do
|
55
|
+
before(:each) do
|
56
|
+
subject.add(@item).size.should == 1
|
57
|
+
subject.changed = false
|
58
|
+
end
|
59
|
+
|
60
|
+
context 'with zero price' do
|
61
|
+
it 'returns self' do
|
62
|
+
subject.add(@zero_price_item).should == subject
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'does not add such item to the list' do
|
66
|
+
subject.add(@zero_price_item)
|
67
|
+
subject[subject.index @zero_price_item].should == nil
|
68
|
+
subject.size.should == 1
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'does not set changed status to true' do
|
72
|
+
subject.add(@zero_price_item)
|
73
|
+
subject.changed.should == false
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'does not set item`s book property' do
|
77
|
+
subject.remove(@zero_price_item)
|
78
|
+
@zero_price_item.book.should == nil
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'sets changed status to true if item was added' do
|
84
|
+
subject.add(@item1)
|
85
|
+
subject.changed.should == true
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'sets added item`s book property' do
|
89
|
+
subject.add(@item1)
|
90
|
+
@item1.book.should == subject
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
describe 'removing item' do
|
95
|
+
before(:each) do
|
96
|
+
subject.add(@item).size.should == 1
|
97
|
+
subject.changed = false
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'sets changed status to true if item was removed' do
|
101
|
+
subject.remove(@item)
|
102
|
+
subject.changed.should == true
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'unsets removed item`s book property' do
|
106
|
+
subject.remove(@item)
|
107
|
+
@item.book.should == nil
|
108
|
+
end
|
109
|
+
|
110
|
+
context 'that is not in list' do
|
111
|
+
|
112
|
+
it 'returns self' do
|
113
|
+
subject.remove(@item1).should == subject
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'does not set changed status to true' do
|
117
|
+
subject.remove(@item1)
|
118
|
+
subject.changed.should == false
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
describe Fin::Book, 'as a replacement for DealBook' do
|
125
|
+
subject { Fin::Book.new :item_type => Fin::Deal,
|
126
|
+
:book_index => proc { |item| item.deal_id },
|
127
|
+
:isin_id => 123456 }
|
128
|
+
let(:item_index) { @item.deal_id }
|
129
|
+
|
130
|
+
before(:each) do
|
131
|
+
@item = Fin::Deal.new :id => 0, :deal_id => 20, :isin => 123456
|
132
|
+
@item1 = Fin::Deal.new :id => 1, :deal_id => 30, :isin => 123456
|
133
|
+
@item2 = Fin::Deal.new :id => 2, :deal_id => 40, :isin => 123456
|
134
|
+
@wrong_isin_item = Fin::Deal.new :id => 3, :deal_id => 50, :isin => 456123
|
135
|
+
end
|
136
|
+
|
137
|
+
it_behaves_like 'changed_list'
|
138
|
+
|
139
|
+
its (:isin_id) {should == 123456}
|
140
|
+
its (:isin) {should == 123456}
|
141
|
+
its (:changed) {should == true}
|
142
|
+
|
143
|
+
it 'is possible to set its #changed attribute' do
|
144
|
+
subject.changed = false
|
145
|
+
subject.changed.should == false
|
146
|
+
end
|
147
|
+
|
148
|
+
it 'but #isin(_id) attribute is not settable' do
|
149
|
+
expect { subject.isin_id = 1313 }.to raise_error NoMethodError
|
150
|
+
expect { subject.isin = 1313 }.to raise_error NoMethodError
|
151
|
+
end
|
152
|
+
|
153
|
+
describe '#check' do
|
154
|
+
it 'fails if item is not a Deal' do
|
155
|
+
subject.check(1).should == false
|
156
|
+
end
|
157
|
+
|
158
|
+
it 'fails if item has wrong isin_id' do
|
159
|
+
subject.check(@wrong_isin_item).should == false
|
160
|
+
end
|
161
|
+
|
162
|
+
it 'returns true otherwise' do
|
163
|
+
subject.check(@item).should == true
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
describe 'adding item' do
|
168
|
+
before(:each) do
|
169
|
+
subject.add(@item).size.should == 1
|
170
|
+
subject.changed = false
|
171
|
+
end
|
172
|
+
|
173
|
+
it 'sets changed status to true if item was added' do
|
174
|
+
subject.add(@item1)
|
175
|
+
subject.changed.should == true
|
176
|
+
end
|
177
|
+
|
178
|
+
it 'sets added item`s book property' do
|
179
|
+
subject.add(@item1)
|
180
|
+
@item1.book.should == subject
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
describe 'removing item' do
|
185
|
+
before(:each) do
|
186
|
+
subject.add(@item).size.should == 1
|
187
|
+
subject.changed = false
|
188
|
+
end
|
189
|
+
|
190
|
+
it 'sets changed status to true if item was removed' do
|
191
|
+
subject.remove(@item)
|
192
|
+
subject.changed.should == true
|
193
|
+
end
|
194
|
+
|
195
|
+
it 'unsets removed item`s book property' do
|
196
|
+
subject.remove(@item)
|
197
|
+
@item.book.should == nil
|
198
|
+
end
|
199
|
+
|
200
|
+
context 'that is not in list' do
|
201
|
+
|
202
|
+
it 'returns self' do
|
203
|
+
subject.remove(@item1).should == subject
|
204
|
+
end
|
205
|
+
|
206
|
+
it 'does not set changed status to true' do
|
207
|
+
subject.remove(@item1)
|
208
|
+
subject.changed.should == false
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
|
215
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fin/shared_examples.rb'
|
3
|
+
|
4
|
+
describe Fin::ChangedList do
|
5
|
+
subject { Fin::ChangedList.new }
|
6
|
+
let(:item_index) { @item.object_id }
|
7
|
+
|
8
|
+
before(:each) do
|
9
|
+
@item = Object.new
|
10
|
+
@item1 = Object.new
|
11
|
+
@item2 = Object.new
|
12
|
+
end
|
13
|
+
|
14
|
+
it_behaves_like 'changed_list'
|
15
|
+
end
|
16
|
+
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fin/shared_examples.rb'
|
3
|
+
|
4
|
+
describe Fin::ContainerList do
|
5
|
+
subject { Fin::ContainerList.new :item_type => Fin::Model }
|
6
|
+
let(:item_index) { @item.index }
|
7
|
+
|
8
|
+
before(:each) do
|
9
|
+
@item = Fin::Model.new
|
10
|
+
@item1 = Fin::Model.new
|
11
|
+
@item2 = Fin::Model.new
|
12
|
+
end
|
13
|
+
|
14
|
+
its(:item_type) { should == Fin::Model }
|
15
|
+
it_behaves_like 'changed_list'
|
16
|
+
|
17
|
+
describe "#check" do
|
18
|
+
it 'checks items for their type' do
|
19
|
+
[@item, @item1, @item2].each do |item|
|
20
|
+
subject.check(item).should be_true
|
21
|
+
end
|
22
|
+
[nil, "none", 1313, [1, 2, 3], Object.new].each do |non_item|
|
23
|
+
subject.check(non_item).should == false
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "#index" do
|
29
|
+
it 'returns items`s own index' do
|
30
|
+
[@item, @item1, @item2].each do |item|
|
31
|
+
subject.index(item).should == item.index
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'returns nil for incorrect items' do
|
36
|
+
[nil, "none", 1313, [1, 2, 3], Object.new].each do |non_item|
|
37
|
+
subject.index(non_item).should == nil
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "#add_record" do # for compatibility
|
43
|
+
it 'delegates to @item_type to create new item' do
|
44
|
+
subject.item_type.should_receive(:from_record).with("Blah").and_return(@item)
|
45
|
+
subject.add_record "Blah"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe Fin::ContainerList, 'as a replacement for InstrumentList' do
|
51
|
+
subject { Fin::ContainerList.new :item_type => Fin::Instrument }
|
52
|
+
let(:item_index) { @item.isin_id }
|
53
|
+
let (:new_item_book_index) {new_item.isin_id}
|
54
|
+
|
55
|
+
before(:each) do
|
56
|
+
@item = Fin::Instrument.new :isin_id => 1234, :name => 'name'
|
57
|
+
@item1 = Fin::Instrument.new :isin_id => 2345, :name => 'name1'
|
58
|
+
@item2 = Fin::Instrument.new :isin_id => 5678, :name => 'name2'
|
59
|
+
end
|
60
|
+
|
61
|
+
it_behaves_like 'changed_list'
|
62
|
+
end
|
63
|
+
|
@@ -0,0 +1,102 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fin/shared_examples.rb'
|
3
|
+
|
4
|
+
describe Fin::DealList do
|
5
|
+
subject { Fin::DealList.new }
|
6
|
+
let(:item_index) { @item.deal_id }
|
7
|
+
let (:new_item_book_index) {new_item.deal_id}
|
8
|
+
|
9
|
+
before(:each) do
|
10
|
+
@item = Fin::Deal.new :isin_id => 1234, :deal_id => 0, :price => 20
|
11
|
+
@item1 = Fin::Deal.new :isin_id => 1234, :deal_id => 1, :price => 10
|
12
|
+
@same_isin_item = @item1
|
13
|
+
@item2 = Fin::Deal.new :isin_id => 5678, :deal_id => 2, :price => 10
|
14
|
+
@diff_isin_item = @item2
|
15
|
+
@zero_price_item = Fin::Deal.new :isin_id => 1234, :deal_id => 3, :price => 0
|
16
|
+
@repeat_item = Fin::Deal.new :isin_id => 1234, :deal_id => 0, :price => 13
|
17
|
+
end
|
18
|
+
|
19
|
+
it_behaves_like 'changed_list'
|
20
|
+
|
21
|
+
specify { subject.books.should be_empty }
|
22
|
+
|
23
|
+
it 'returns book for any isin_id, even if it was not initialized' do
|
24
|
+
book = subject.books[1313]
|
25
|
+
book.should_not be_nil
|
26
|
+
book.should be_an Fin::Book
|
27
|
+
book.should be_empty
|
28
|
+
end
|
29
|
+
|
30
|
+
describe 'adding item' do
|
31
|
+
let(:expected_number_of_books) { 1 }
|
32
|
+
|
33
|
+
context 'to empty OrderList' do
|
34
|
+
let(:new_item) { @item }
|
35
|
+
|
36
|
+
it_behaves_like 'adding_item_to_books'
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'to non-empty OrderList' do
|
40
|
+
before(:each) do
|
41
|
+
subject.add(@item).size.should == 1
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'with existing isin' do
|
45
|
+
let(:new_item) { @same_isin_item }
|
46
|
+
|
47
|
+
it_behaves_like 'adding_item_to_books'
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'with different isin' do
|
51
|
+
let(:new_item) { @diff_isin_item }
|
52
|
+
let(:expected_number_of_books) { 2 }
|
53
|
+
|
54
|
+
it_behaves_like 'adding_item_to_books'
|
55
|
+
end
|
56
|
+
|
57
|
+
context 'with zero price' do
|
58
|
+
let(:new_item) { @zero_price_item }
|
59
|
+
|
60
|
+
it_behaves_like 'adding_item_to_books'
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe 'removing item' do
|
66
|
+
before(:each) do
|
67
|
+
subject.add(@item).size.should == 1
|
68
|
+
end
|
69
|
+
|
70
|
+
context 'with existing item' do
|
71
|
+
let(:unwanted_item) { @item }
|
72
|
+
let(:expected_size) { 0 }
|
73
|
+
|
74
|
+
it 'deletes item from the list' do
|
75
|
+
subject.remove(unwanted_item)
|
76
|
+
subject[unwanted_item.id].should == nil
|
77
|
+
subject.size.should == expected_size
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'removes item from its related book' do
|
81
|
+
subject.remove(unwanted_item)
|
82
|
+
subject.books[unwanted_item.isin_id].should_not have_key unwanted_item.deal_id
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
context 'with non-existing item' do
|
87
|
+
let(:unwanted_item) { @item1 }
|
88
|
+
let(:expected_size) { 1 }
|
89
|
+
|
90
|
+
it 'still returns the list itself' do
|
91
|
+
subject.remove(unwanted_item).should == subject
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'deletes nothing from the list' do
|
95
|
+
subject.remove(unwanted_item)
|
96
|
+
subject[item_index].should == @item
|
97
|
+
subject.size.should == expected_size
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fin/shared_examples.rb'
|
3
|
+
|
4
|
+
describe Fin::IndexedList do
|
5
|
+
subject { Fin::IndexedList.new }
|
6
|
+
let(:item_index) { @item.object_id }
|
7
|
+
|
8
|
+
before(:each) do
|
9
|
+
@item = Object.new
|
10
|
+
@item1 = Object.new
|
11
|
+
@item2 = Object.new
|
12
|
+
end
|
13
|
+
|
14
|
+
it_behaves_like 'index_list'
|
15
|
+
|
16
|
+
it 'checks all items as worthy, by default' do
|
17
|
+
subject.check(@item).should == true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
@@ -0,0 +1,140 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fin/models/shared_examples'
|
3
|
+
|
4
|
+
describe Fin::Deal do
|
5
|
+
|
6
|
+
it_behaves_like 'model'
|
7
|
+
|
8
|
+
describe '#new with empty initializer' do
|
9
|
+
subject { Fin::Deal.new }
|
10
|
+
|
11
|
+
its (:id) {should == nil} # replId
|
12
|
+
its (:rev) {should == nil} # replRev
|
13
|
+
its (:isin_id) {should == nil}
|
14
|
+
its (:isin) {should == nil}
|
15
|
+
its (:deal_id) {should == nil}
|
16
|
+
its (:id_deal) {should == nil}
|
17
|
+
its (:sess_id) {should == nil}
|
18
|
+
its (:session_id) {should == nil}
|
19
|
+
its (:price) {should == nil}
|
20
|
+
its (:amount) {should == nil}
|
21
|
+
its (:moment) {should == nil}
|
22
|
+
its (:status_sell) {should == nil}
|
23
|
+
its (:status_buy) {should == nil}
|
24
|
+
its (:id_ord_sell) {should == nil}
|
25
|
+
its (:id_ord_buy) {should == nil}
|
26
|
+
its (:pos) {should == nil} # ���-�� ������� �� ����������� �� ����� ����� ������.
|
27
|
+
its (:nosystem) {should == nil} # 1-������������ ������, 0-�������
|
28
|
+
its (:id_repo) {should == nil} # ����� ������ ����� ������ ����
|
29
|
+
its (:id_deal_multileg) {should == nil} # ����� ������ �� ������
|
30
|
+
|
31
|
+
its (:book) {should == nil}
|
32
|
+
|
33
|
+
# replID=6607871
|
34
|
+
# replRev=6607876
|
35
|
+
# replAct=0
|
36
|
+
# id_deal=6608653
|
37
|
+
# sess_id=3753
|
38
|
+
# isin_id=154995
|
39
|
+
# price=22194.00000
|
40
|
+
# amount=3
|
41
|
+
# moment=2011/03/23 15:30:04.746
|
42
|
+
# id_ord_sell=2292952813
|
43
|
+
# id_ord_buy=2292952838
|
44
|
+
# status_sell=0
|
45
|
+
# status_buy=0
|
46
|
+
# pos=71148
|
47
|
+
# nosystem=0
|
48
|
+
# id_repo=0
|
49
|
+
# id_deal_multileg=0
|
50
|
+
|
51
|
+
# ���� code_sell, comment_sell, ext_id_sell, trust_sell, hedge_sell,
|
52
|
+
# login_sell, code_rts_sell, fee_sell, code_buy, comment_buy, ext_id_buy,
|
53
|
+
# trust_buy, hedge_buy, login_buy, code_rts_buy, fee_buy -
|
54
|
+
# - ����������� ������ ��� ����� ������.
|
55
|
+
|
56
|
+
# code_sell=
|
57
|
+
# code_buy=
|
58
|
+
# ext_id_sell=0
|
59
|
+
# comment_sell=
|
60
|
+
# trust_sell=0
|
61
|
+
# ext_id_buy=0
|
62
|
+
# comment_buy=
|
63
|
+
# trust_buy=0
|
64
|
+
# hedge_sell=0
|
65
|
+
# hedge_buy=0
|
66
|
+
# fee_sell=0.00
|
67
|
+
# fee_buy=0.00
|
68
|
+
# login_sell=
|
69
|
+
# login_buy=
|
70
|
+
# code_rts_sell=
|
71
|
+
# code_rts_buy=
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
describe '#new with opts' do
|
76
|
+
subject { Fin::Deal.new :isin => 1234567,
|
77
|
+
:id => 12,
|
78
|
+
:rev => 123,
|
79
|
+
:price => 1234,
|
80
|
+
:amount => 12345,
|
81
|
+
:deal_id => 1212,
|
82
|
+
:sess_id => 1213,
|
83
|
+
:moment => 'time',
|
84
|
+
:status_sell => 0,
|
85
|
+
:status_buy => 0,
|
86
|
+
:id_ord_sell => 123456,
|
87
|
+
:id_ord_buy => 654321,
|
88
|
+
:pos => 121212, # ���-�� ������� �� ����������� �� ����� ����� ������.
|
89
|
+
:nosystem => 0, # 1-������������ ������, 0-�������
|
90
|
+
:id_repo => 0, # ����� ������ ����� ������ ����
|
91
|
+
:id_deal_multileg => 0, # ����� ������ �� ������
|
92
|
+
:book=> 123456,
|
93
|
+
}
|
94
|
+
|
95
|
+
its (:isin_id) {should == 1234567}
|
96
|
+
its (:isin) {should == 1234567}
|
97
|
+
its (:id) {should == 12}
|
98
|
+
its (:rev) {should == 123}
|
99
|
+
its (:price) {should == 1234}
|
100
|
+
its (:amount) {should == 12345}
|
101
|
+
|
102
|
+
its (:deal_id) {should == 1212}
|
103
|
+
its (:id_deal) {should == 1212}
|
104
|
+
its (:sess_id) {should == 1213}
|
105
|
+
its (:session_id) {should == 1213}
|
106
|
+
its (:moment) {should == 'time'}
|
107
|
+
its (:status_sell) {should == 0}
|
108
|
+
its (:status_buy) {should == 0}
|
109
|
+
its (:id_ord_sell) {should == 123456}
|
110
|
+
its (:id_ord_buy) {should == 654321}
|
111
|
+
its (:pos) {should == 121212} # ���-�� ������� �� ����������� �� ����� ����� ������.
|
112
|
+
its (:nosystem) {should == 0} # 1-������������ ������, 0-�������
|
113
|
+
its (:id_repo) {should == 0} # ����� ������ ����� ������ ����
|
114
|
+
its (:id_deal_multileg) {should == 0} # ����� ������ �� ������
|
115
|
+
|
116
|
+
its (:book) {should == 123456}
|
117
|
+
|
118
|
+
describe '#to_s, #inspect' do
|
119
|
+
it 'is just right' do
|
120
|
+
subject.to_s.should == "time:12[1234567] 1234>12345"
|
121
|
+
subject.inspect.should == "time:12[1234567] 1234>12345"
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
describe '#price=' do
|
126
|
+
it 'converts given price to Integer if it is integer' do
|
127
|
+
subject.price = 1313.0
|
128
|
+
subject.price.should == 1313
|
129
|
+
subject.price.should be_an Integer
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
describe '#index' do
|
134
|
+
it 'should be equal to isin_id' do
|
135
|
+
subject.index.should == subject.deal_id
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|