heisencoin 0.0.5 → 0.0.6
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/heisencoin/arbitrage.rb +2 -2
- data/tests/arbitrage.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2dffc036acf75b62155032011e468b617504acbe
|
|
4
|
+
data.tar.gz: 4d1c77beca37c3554fd8db474ab5821c47d823a7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 831cf5e34472830840416cd49c3cf4f49c5d81251f2df48a59442f61c818ce48dda1d3874d795fd22d8cfef24358af9a3309132568d64c83e98fa85a2b6c9685
|
|
7
|
+
data.tar.gz: c6ba6d26720f74c4f7e6c38d602fbd28c3fc7c16ac895a40c6fcc594d21682c41086376618e919ae035d5640412e1e6c91008dd57b31a97a95b27bc55d23f5d4
|
data/lib/heisencoin/arbitrage.rb
CHANGED
|
@@ -57,7 +57,7 @@ module Heisencoin
|
|
|
57
57
|
working_bids = bids.dup
|
|
58
58
|
trades = []
|
|
59
59
|
asks.each do |ask|
|
|
60
|
-
step_trades = consume_ask(working_bids, ask, ask.price*(1
|
|
60
|
+
step_trades = consume_ask(working_bids, ask, ask.price*(1+ask.exchange.fee))
|
|
61
61
|
trades += step_trades
|
|
62
62
|
qty_traded = step_trades.reduce(0){|memo, trade| memo += trade.quantity} #sum
|
|
63
63
|
break if qty_traded < ask.quantity #out of coins
|
|
@@ -71,7 +71,7 @@ module Heisencoin
|
|
|
71
71
|
quantity = ask.quantity
|
|
72
72
|
near_zero = 0.0001 #floats
|
|
73
73
|
bids.each do |bid|
|
|
74
|
-
if (bid.price*(1
|
|
74
|
+
if (bid.price*(1-bid.exchange.fee)) >= price
|
|
75
75
|
if bid.quantity > near_zero
|
|
76
76
|
trade_quantity = [bid.quantity, quantity].min
|
|
77
77
|
trades << Trade.new({'from_offer' => ask.to_simple,
|
data/tests/arbitrage.rb
CHANGED
|
@@ -52,8 +52,8 @@ class TestMeme < Minitest::Test
|
|
|
52
52
|
before do
|
|
53
53
|
# full setup
|
|
54
54
|
@arby = Heisencoin::Arbitrage.new
|
|
55
|
-
@ex1 = Heisencoin::Exchange.new({'name' =>'btcx', 'fee' => 0.
|
|
56
|
-
@ex2 = Heisencoin::Exchange.new({'name' =>'crytpsy', 'fee' => 0.
|
|
55
|
+
@ex1 = Heisencoin::Exchange.new({'name' =>'btcx', 'fee' => 0.002})
|
|
56
|
+
@ex2 = Heisencoin::Exchange.new({'name' =>'crytpsy', 'fee' => 0.003})
|
|
57
57
|
@arby.add_exchanges([@ex1, @ex2])
|
|
58
58
|
# ex1 has a 14.1 and 14.2 bid above ex2's 14 ask
|
|
59
59
|
depth = {"asks" => [ [16,1],
|