gekko 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c6a62cd6a603df96f06b4d067339fd3099fa7210
4
- data.tar.gz: 89b432fea332373c19f364503f978bd48e36acb6
3
+ metadata.gz: b6a24e973cb010d9b1f8067d9bea9cb30a1c3bc4
4
+ data.tar.gz: f120b77ebf50b3a973a886dc4b8561249c395169
5
5
  SHA512:
6
- metadata.gz: 5bafd1be42f260eb676f90c849d32bd862a70001bd1cd46d89dc609bd125235618d59cc69299bfd489bf15270e26c442cc29a2f75cf7918f8d0008085a1049ae
7
- data.tar.gz: 487cf829c967a2737ce01ad0caaf53a415de0bc1106a442f90df1643d08dd4291d109385a59b1e23fc29fb3ccb9ec83f68f874f5a0748637eeb99a956de2b063
6
+ metadata.gz: 0d14739c0de58e63f2ce1039018911f3689a59c833f1871e136ef6076730337493d709b2efe9e43ff4883228ae795a76a8a66c7c89a3d68dad0c0229132e29ea
7
+ data.tar.gz: 396fb3177eb9c2fbcdf289fe36ee1cb6abb1658aa4db4eda8b7f3bcbf5e08ec60ee799f487cc3793f8f57f740f06b147d50680208438b4007f8bbd399d672cef
@@ -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
 
@@ -7,8 +7,8 @@ module Gekko
7
7
 
8
8
  attr_accessor :price
9
9
 
10
- def initialize(side, id, uid, size, price, expiration = nil)
11
- super(side, id, uid, size, expiration)
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
@@ -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, expiration = nil)
12
- super(side, id, uid, size, expiration)
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
@@ -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, expiration = nil)
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)
@@ -1,6 +1,6 @@
1
1
  module Gekko
2
2
 
3
3
  # The Gekko version string
4
- VERSION = '1.0.0'
4
+ VERSION = '1.1.0'
5
5
 
6
6
  end
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.0.0
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-15 00:00:00.000000000 Z
11
+ date: 2016-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: uuidtools