rapflag 0.0.6 → 0.0.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1ffaa4c17111d1c37c02118a096dff0930a93819
4
- data.tar.gz: 2787ec4a5db18aee84c1947aeb2c5cfeac173a08
3
+ metadata.gz: 72ac31a1ed8f02d2602c12a87d0ca55a79b00d67
4
+ data.tar.gz: c6e7abce5e56208207a88a2d98b585555f25cdae
5
5
  SHA512:
6
- metadata.gz: ae3137d9aee15c69368d7d61d98effb9d8c383ad4cd338a4e63bdeb33264348af3de3d57b5a4175bc09c9250b18efecc798de10eab82c53eae4a4c74f064a336
7
- data.tar.gz: 893844bbc5508ce8effda45098b1de91baaae9834ebb86d7359926662d901d248e5adbacbdfabe37cda8880429575151535d1757b85887a7faab220521191f4a
6
+ metadata.gz: e72b855a3bf4f541f72abd75dbdb3ef2a3150fdd2e71ffced58c22b41d4fc19c51af6cf817e1421308f2ce56405020c4a0d77861d9ee85ccc6fd3c7715455217
7
+ data.tar.gz: 00c95b069c5eb24d6ec2eb50e958bdb40aba1cd341ae238be597b0d8c573788f1c7fa9b1de2099f32c2510647081042888083daa942886295bda673c216adc97
data/History.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.0.7 of 2017.04.17
2
+
3
+ * Wait (possibly several times) when we hit the rate limiter of the bitfinex REST API
4
+
1
5
  # 0.0.6 of 2017.04.11
2
6
 
3
7
  * Download complete lending history not only he default of 500 items
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # rapflag
2
- Bitfinex Exporter for your Taxman.
2
+ Bitfinex and Poloniex Exporter for your Taxman.
3
3
 
4
4
  ### set your key, desired currencies in
5
5
  ```
@@ -12,10 +12,14 @@ currencies: [ 'USD', 'BTC', 'BFX']
12
12
  api_key: ''
13
13
  secret: ''
14
14
  ```
15
+ comment out "currencies" if you want to export all currencies.
15
16
  ### run as follows
16
17
  ```
17
- ruby rapflag.rb
18
- ruby rapflag.rb -c (clean option to show daily income and daily value of your wallet)
18
+ Options:
19
+ -c, --clean Create Bitfinex summary of transactions by day
20
+ -p, --poloniex Use Poloniex API instead of Bitfinex API
21
+ -d, --dump Use Poloniex API and dump history into CSV files
22
+ -h, --help Show this message
19
23
  ```
20
24
  Enjoy your reports. More to come. Feedback always welcome.
21
25
 
data/bin/rapflag CHANGED
@@ -13,7 +13,7 @@ rescue LoadError
13
13
  end
14
14
 
15
15
  Opts = Trollop::options do
16
- opt :clean, "Create summary of transactions by day"
16
+ opt :clean, "Create Bitfinex summary of transactions by day"
17
17
  opt :poloniex, "Use Poloniex API instead of Bitfinex API"
18
18
  opt :dump, "Use Poloniex API and dump history into CSV files"
19
19
  end
@@ -52,25 +52,31 @@ module RAPFLAG
52
52
 
53
53
  def fetch_csv_history
54
54
  @history = []
55
+ delay_in_seconds = 30
55
56
  check_config
56
57
  client = ::Bitfinex::Client.new
57
58
  timestamp = Time.now.to_i + 1
58
59
  while true
59
60
  begin
60
- partial = client.history(@currency, { :limit => 500, :until => timestamp, :wallet => @wallet})
61
- break unless partial && partial.size > 0
62
- if partial.is_a?(Hash)
63
- puts "Got #{partial['error']} while fetching #{@wallet} #{@currency} until #{Time.at(timestamp)}"
64
- exit 3
61
+ partial = nil
62
+ while true
63
+ partial = client.history(@currency, { :limit => 1000, :until => timestamp, :wallet => @wallet})
64
+ if partial.is_a?(Hash) && (partial.size > 0) && partial['error'].eql?('ERR_RATE_LIMIT')
65
+ puts "Got #{partial['error']} while fetching #{@wallet} #{@currency} #{client.history} items"
66
+ puts " Will wait #{delay_in_seconds} seconds before retrying"
67
+ sleep(delay_in_seconds)
68
+ end
69
+ break if partial && partial.is_a?(Array)
65
70
  end
71
+ break if partial.size <= 1
66
72
  first_time = Time.at(partial.first['timestamp'].to_i).strftime(DATE_TIME_FORMAT)
67
73
  last_time = Time.at(partial.last['timestamp'].to_i).strftime(DATE_TIME_FORMAT)
68
- puts "Feched #{partial.size} @history entries #{first_time} -> #{last_time}" if $VERBOSE
74
+ puts "Fetched #{partial.size} @history entries #{first_time} -> #{last_time}" if $VERBOSE
69
75
  timestamp = (partial.last['timestamp'].to_i - 1)
70
76
  @history = @history | partial
71
- break if partial.size <= 1
72
77
  rescue => error
73
78
  puts "error #{error}"
79
+ puts " backtrace: #{error.backtrace[0..10].join("\n")}"
74
80
  end
75
81
  end
76
82
  puts "Feched #{@history.size} history entries" if $VERBOSE
@@ -16,12 +16,16 @@ module RAPFLAG
16
16
  break
17
17
  end
18
18
  end
19
- unless config_file && File.exist?(config_file)
20
- puts "You must first add. Use one of the following places #{files_to_test}"
21
- exit 2
22
- end
19
+ if defined?(RSpec)
20
+ Config = Hash.new
21
+ else
22
+ unless config_file && File.exist?(config_file)
23
+ puts "You must first add a config.yml. Use one of the following places #{files_to_test}"
24
+ exit 2
25
+ end
23
26
 
24
- Config= YAML.load_file(config_file)
27
+ Config= YAML.load_file(config_file)
28
+ end
25
29
  Config['currencies'] ||= ['BTC', 'BFX', 'XMR', 'ZEC']
26
30
  Config['currencies'] << 'USD' unless Config['currencies'].index('USD')
27
31
  end
File without changes
@@ -1,4 +1,4 @@
1
1
  module RAPFLAG
2
2
  Wallets = ['trading', 'exchange', 'deposit']
3
- VERSION='0.0.6'
3
+ VERSION='0.0.7'
4
4
  end
data/spec/spec_helper.rb CHANGED
@@ -8,6 +8,11 @@ require 'rapflag/config'
8
8
  require 'bitfinex-api-rb'
9
9
  require 'poloniex'
10
10
 
11
+ RAPFLAG::Config['poloniex_api_key'] = 'dummy poloniex_api_key'
12
+ RAPFLAG::Config['poloniex_secret'] = 'dummy poloniex_secret'
13
+ RAPFLAG::Config['api_key'] = 'dummy bitfinex api_key'
14
+ RAPFLAG::Config['secret'] = 'dummy bitfinex secret'
15
+
11
16
  module RAPFLAG
12
17
  # create dummy config for spec tests
13
18
  Bitfinex::Client.configure do |conf|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rapflag
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zeno R.R. Davatz, Niklaus Giger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-11 00:00:00.000000000 Z
11
+ date: 2017-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ypoloniex