gekko 1.0.0 → 1.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.
- checksums.yaml +4 -4
- data/lib/gekko/book.rb +6 -1
- data/lib/gekko/limit_order.rb +3 -3
- data/lib/gekko/market_order.rb +3 -3
- data/lib/gekko/order.rb +4 -3
- data/lib/gekko/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6a24e973cb010d9b1f8067d9bea9cb30a1c3bc4
|
4
|
+
data.tar.gz: f120b77ebf50b3a973a886dc4b8561249c395169
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d14739c0de58e63f2ce1039018911f3689a59c833f1871e136ef6076730337493d709b2efe9e43ff4883228ae795a76a8a66c7c89a3d68dad0c0229132e29ea
|
7
|
+
data.tar.gz: 396fb3177eb9c2fbcdf289fe36ee1cb6abb1658aa4db4eda8b7f3bcbf5e08ec60ee799f487cc3793f8f57f740f06b147d50680208438b4007f8bbd399d672cef
|
data/lib/gekko/book.rb
CHANGED
@@ -34,12 +34,18 @@ module Gekko
|
|
34
34
|
def receive_order(order)
|
35
35
|
raise 'Order must be a Gekko::LimitOrder or a Gekko::MarketOrder' unless [LimitOrder, MarketOrder].include?(order.class)
|
36
36
|
|
37
|
+
# The side from which we'll pop orders
|
38
|
+
opposite_side = order.bid? ? asks : bids
|
39
|
+
|
37
40
|
if received.has_key?(order.id.to_s)
|
38
41
|
tape << order.message(:reject, reason: :duplicate_id)
|
39
42
|
|
40
43
|
elsif order.expired?
|
41
44
|
tape << order.message(:reject, reason: :expired)
|
42
45
|
|
46
|
+
elsif order.post_only && order.crosses?(opposite_side.first)
|
47
|
+
tape << order.message(:reject, reason: :would_execute)
|
48
|
+
|
43
49
|
else
|
44
50
|
old_ticker = ticker
|
45
51
|
|
@@ -47,7 +53,6 @@ module Gekko
|
|
47
53
|
tape << order.message(:received)
|
48
54
|
|
49
55
|
order_side = order.bid? ? bids : asks
|
50
|
-
opposite_side = order.bid? ? asks : bids
|
51
56
|
next_match = opposite_side.first
|
52
57
|
prev_match_id = nil
|
53
58
|
|
data/lib/gekko/limit_order.rb
CHANGED
@@ -7,8 +7,8 @@ module Gekko
|
|
7
7
|
|
8
8
|
attr_accessor :price
|
9
9
|
|
10
|
-
def initialize(side, id, uid, size, price,
|
11
|
-
super(side, id, uid, size,
|
10
|
+
def initialize(side, id, uid, size, price, opts = {})
|
11
|
+
super(side, id, uid, size, opts)
|
12
12
|
@price = price
|
13
13
|
|
14
14
|
raise 'Price must be a positive integer' if @price.nil? || (!@price.is_a?(Fixnum) || (@price <= 0))
|
@@ -45,7 +45,7 @@ module Gekko
|
|
45
45
|
# @return [Gekko::LimitOrder] A limit order
|
46
46
|
#
|
47
47
|
def self.from_hash(hsh)
|
48
|
-
order = LimitOrder.new(hsh[:side], UUID.parse(hsh[:id]), UUID.parse(hsh[:uid]), hsh[:size], hsh[:price], hsh[:expiration])
|
48
|
+
order = LimitOrder.new(hsh[:side], UUID.parse(hsh[:id]), UUID.parse(hsh[:uid]), hsh[:size], hsh[:price], expiration: hsh[:expiration])
|
49
49
|
order.remaining = hsh[:remaining] || hsh[:size]
|
50
50
|
order.created_at = hsh[:created_at] if hsh[:created_at]
|
51
51
|
order
|
data/lib/gekko/market_order.rb
CHANGED
@@ -8,8 +8,8 @@ module Gekko
|
|
8
8
|
|
9
9
|
attr_accessor :quote_margin, :remaining_quote_margin, :max_precision
|
10
10
|
|
11
|
-
def initialize(side, id, uid, size, quote_margin,
|
12
|
-
super(side, id, uid, size,
|
11
|
+
def initialize(side, id, uid, size, quote_margin, opts = {})
|
12
|
+
super(side, id, uid, size, opts)
|
13
13
|
|
14
14
|
@quote_margin = quote_margin
|
15
15
|
@remaining_quote_margin = @quote_margin
|
@@ -46,7 +46,7 @@ module Gekko
|
|
46
46
|
# @return [Gekko::MarketOrder] A market order
|
47
47
|
#
|
48
48
|
def self.from_hash(hsh)
|
49
|
-
order = MarketOrder.new(hsh[:side], UUID.parse(hsh[:id]), UUID.parse(hsh[:uid]), hsh[:size], hsh[:quote_margin], hsh[:expiration])
|
49
|
+
order = MarketOrder.new(hsh[:side], UUID.parse(hsh[:id]), UUID.parse(hsh[:uid]), hsh[:size], hsh[:quote_margin], expiration: hsh[:expiration])
|
50
50
|
order.created_at = hsh[:created_at] if hsh[:created_at]
|
51
51
|
order
|
52
52
|
end
|
data/lib/gekko/order.rb
CHANGED
@@ -9,16 +9,17 @@ module Gekko
|
|
9
9
|
|
10
10
|
include Serialization
|
11
11
|
|
12
|
-
attr_accessor :id, :uid, :side, :size, :remaining, :price, :expiration, :created_at
|
12
|
+
attr_accessor :id, :uid, :side, :size, :remaining, :price, :expiration, :created_at, :post_only
|
13
13
|
|
14
|
-
def initialize(side, id, uid, size,
|
14
|
+
def initialize(side, id, uid, size, opts = {})
|
15
15
|
@id = id
|
16
16
|
@uid = uid
|
17
17
|
@side = side && side.to_sym
|
18
18
|
@size = size
|
19
19
|
@remaining = @size
|
20
|
-
@expiration = expiration
|
20
|
+
@expiration = opts[:expiration]
|
21
21
|
@created_at = Time.now.to_f
|
22
|
+
@post_only = opts[:post_only]
|
22
23
|
|
23
24
|
raise 'Orders must have an UUID' unless @id && @id.is_a?(UUID)
|
24
25
|
raise 'Orders must have a user ID' unless @uid && @uid.is_a?(UUID)
|
data/lib/gekko/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gekko
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David FRANCOIS
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: uuidtools
|