devilicious 1.0.1 → 1.0.2

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: 8b033872b603f7f7ae8ed218d4af4c41c4cb4903
4
- data.tar.gz: 67f519c8061f6769365e524ba9d82a894fc233a6
3
+ metadata.gz: 2491dff50a4e0583d61665b7904d25a75e8c9516
4
+ data.tar.gz: 2528228fb014c22a060faa7d7c503822c62ca95d
5
5
  SHA512:
6
- metadata.gz: bb542490f980f92fc73ec8c9ec5841ecdddbc0ee3b65d93d326d6256b23c6d9755068766df39ccc032b0a3cc42a5cd499124609e9419a2320415173c708d55f8
7
- data.tar.gz: 5b8f2cd2bdebf522ed81cfb4da2868bfd19895879d7b7796012f37323fd48dfb1149aed1a1d08607149b5eefa7ec4dee476a5bacb7c9a349055ffa11909ba868
6
+ metadata.gz: 67eef95a1a664197cbd753fdb59a1cc97c02568779bafcd54fcb7370e42636da06790be40eb5c2057db6b486b41d68079c26f8a6c3b1068a3d45cdcd41e88968
7
+ data.tar.gz: 8dd88dd01d6fa2ca5a4532ee2b566cf9a1a5948f1702ab106179eaac23d114c67dadca29d2fa8d0bd782a8eeb36e4c8096b55f21acd48639faffc6f304cf80e6
data/devilicious.gemspec CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "devilicious"
7
- spec.version = "1.0.1"
7
+ spec.version = "1.0.2"
8
8
  spec.authors = ["Cédric Félizard"]
9
9
  spec.email = ["cedric@felizard.fr"]
10
10
  spec.summary = %q{Multi-currency Bitcoin arbitrage bot}
@@ -27,8 +27,8 @@ module Devilicious
27
27
  markets.each do |market_2|
28
28
  next if market_1 == market_2
29
29
 
30
- if market_2.order_book.nil?
31
- Log.debug "Order book for #{market_2} not available yet, skipping"
30
+ if market_1.order_book.nil? || market_2.order_book.nil?
31
+ Log.debug "Order book(s) not available, skipping"
32
32
  next
33
33
  end
34
34
 
@@ -117,7 +117,7 @@ module Devilicious
117
117
  best_offer_unlimited_volume
118
118
  end.volume
119
119
 
120
- return if best_offer_limited_volume.profit <= 0
120
+ return if best_offer_limited_volume.profit < Devilicious.config.min_profit
121
121
 
122
122
  best_offer_limited_volume.best_volume = best_volume
123
123
 
@@ -13,6 +13,7 @@ module Devilicious
13
13
  config.beep_profit_threshold = BigDecimal.new("-1") # negative means disabled
14
14
  config.default_fiat_currency = "EUR" # ideally the most used currency so we do as little conversions as possible
15
15
  config.market_refresh_rate = 30 # order books expire delay in seconds
16
+ config.min_profit = 1 # in `default_fiat_currency` currency
16
17
 
17
18
  opt_parser = OptionParser.new do |opts|
18
19
  opts.banner = "Usage: devilicious [config]"
@@ -7,10 +7,11 @@ module Devilicious
7
7
  @best_trades[pair] = opportunity
8
8
 
9
9
  Log.info "", timestamp: false
10
- Log.info "PAIR \tPROFIT \tVOLUME \tBUY \tSELL", timestamp: false
10
+ Log.info "PAIR \tPROFIT \tVOLUME \tBUY \tSELL \tPERCENT", timestamp: false
11
11
  @best_trades.sort_by { |_, opportunity| opportunity.profit }.each do |pair, opportunity|
12
12
  pair = pair.dup << " " * [30 - pair.size, 0].max # padding
13
- Log.info [pair, opportunity.profit, opportunity.volume.to_f, opportunity.ask_offer.price, opportunity.bid_offer.price].join(" \t"), timestamp: false
13
+ percent = sprintf("%.2f%%", opportunity.profit / opportunity.ask_offer.price * 100)
14
+ Log.info [pair, opportunity.profit, opportunity.volume.to_f, opportunity.ask_offer.price, opportunity.bid_offer.price, percent].join(" \t"), timestamp: false
14
15
  end
15
16
  end
16
17
  end
@@ -12,7 +12,7 @@ module Devilicious
12
12
  end
13
13
 
14
14
  def refresh_order_book!
15
- json = get_json("https://anxpro.com/api/2/BTC#{fiat_currency}/money/depth/full")
15
+ json = get_json("https://anxpro.com/api/2/BTC#{fiat_currency}/money/depth/full") or return
16
16
 
17
17
  asks = format_asks_bids(json["data"]["asks"])
18
18
  bids = format_asks_bids(json["data"]["bids"])
@@ -18,14 +18,18 @@ module Devilicious
18
18
  private
19
19
 
20
20
  def get_html(url)
21
- retryable(tries: 5, sleep: 1) do
22
- open(url).read
21
+ begin
22
+ retryable(tries: 5, sleep: 1) do
23
+ open(url).read
24
+ end
25
+ rescue => e
26
+ Log.warn "#{self} error: #{e.inspect}"
23
27
  end
24
28
  end
25
29
 
26
30
  def get_json(url)
27
31
  html = get_html(url)
28
- JSON.parse(html)
32
+ JSON.parse(html) if html
29
33
  end
30
34
 
31
35
  def mark_as_refreshed
@@ -14,7 +14,7 @@ module Devilicious
14
14
  end
15
15
 
16
16
  def refresh_order_book!
17
- json = get_json("https://bitnz.com/api/0/orderbook")
17
+ json = get_json("https://bitnz.com/api/0/orderbook") or return
18
18
 
19
19
  asks = format_asks_bids(json["asks"])
20
20
  bids = format_asks_bids(json["bids"])
@@ -14,7 +14,7 @@ module Devilicious
14
14
  end
15
15
 
16
16
  def refresh_order_book!
17
- json = get_json("https://#{fiat_currency.downcase}.bitcurex.com/data/orderbook.json")
17
+ json = get_json("https://#{fiat_currency.downcase}.bitcurex.com/data/orderbook.json") or return
18
18
 
19
19
  asks = format_asks_bids(json["asks"])
20
20
  bids = format_asks_bids(json["bids"])
@@ -14,7 +14,7 @@ module Devilicious
14
14
  end
15
15
 
16
16
  def refresh_order_book!
17
- json = get_json("https://www.bitstamp.net/api/order_book/")
17
+ json = get_json("https://www.bitstamp.net/api/order_book/") or return
18
18
 
19
19
  asks = format_asks_bids(json["asks"])
20
20
  bids = format_asks_bids(json["bids"])
@@ -12,7 +12,7 @@ module Devilicious
12
12
  end
13
13
 
14
14
  def refresh_order_book!
15
- json = get_json("https://btc-e.com/api/2/btc_#{fiat_currency.downcase}/depth")
15
+ json = get_json("https://btc-e.com/api/2/btc_#{fiat_currency.downcase}/depth") or return
16
16
 
17
17
  asks = format_asks_bids(json["asks"])
18
18
  bids = format_asks_bids(json["bids"])
@@ -14,7 +14,7 @@ module Devilicious
14
14
  end
15
15
 
16
16
  def refresh_order_book!
17
- json = get_json("https://api.hitbtc.com/api/1/public/BTC#{fiat_currency}/orderbook")
17
+ json = get_json("https://api.hitbtc.com/api/1/public/BTC#{fiat_currency}/orderbook") or return
18
18
 
19
19
  asks = format_asks_bids(json["asks"])
20
20
  bids = format_asks_bids(json["bids"])
@@ -8,11 +8,11 @@ module Devilicious
8
8
  end
9
9
 
10
10
  def trade_fee
11
- BigDecimal.new("0.002").freeze # 0.2%
11
+ BigDecimal.new("0.0035").freeze # 0.35%
12
12
  end
13
13
 
14
14
  def refresh_order_book!
15
- json = get_json("https://api.kraken.com/0/public/Depth?pair=XBT#{fiat_currency}")
15
+ json = get_json("https://api.kraken.com/0/public/Depth?pair=XBT#{fiat_currency}") or return
16
16
 
17
17
  asks = format_asks_bids(json["result"]["XXBTZ#{fiat_currency}"]["asks"])
18
18
  bids = format_asks_bids(json["result"]["XXBTZ#{fiat_currency}"]["bids"])
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devilicious
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cédric Félizard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-30 00:00:00.000000000 Z
11
+ date: 2014-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: retryable