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 +4 -4
- data/History.md +4 -0
- data/README.md +7 -3
- data/bin/rapflag +1 -1
- data/lib/rapflag/bitfinex.rb +13 -7
- data/lib/rapflag/config.rb +9 -5
- data/lib/rapflag/poloniex.rb +0 -0
- data/lib/rapflag/version.rb +1 -1
- data/spec/spec_helper.rb +5 -0
- 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: 72ac31a1ed8f02d2602c12a87d0ca55a79b00d67
|
4
|
+
data.tar.gz: c6e7abce5e56208207a88a2d98b585555f25cdae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e72b855a3bf4f541f72abd75dbdb3ef2a3150fdd2e71ffced58c22b41d4fc19c51af6cf817e1421308f2ce56405020c4a0d77861d9ee85ccc6fd3c7715455217
|
7
|
+
data.tar.gz: 00c95b069c5eb24d6ec2eb50e958bdb40aba1cd341ae238be597b0d8c573788f1c7fa9b1de2099f32c2510647081042888083daa942886295bda673c216adc97
|
data/History.md
CHANGED
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
|
-
|
18
|
-
|
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
|
data/lib/rapflag/bitfinex.rb
CHANGED
@@ -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 =
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
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 "
|
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
|
data/lib/rapflag/config.rb
CHANGED
@@ -16,12 +16,16 @@ module RAPFLAG
|
|
16
16
|
break
|
17
17
|
end
|
18
18
|
end
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
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
|
-
|
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
|
data/lib/rapflag/poloniex.rb
CHANGED
File without changes
|
data/lib/rapflag/version.rb
CHANGED
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.
|
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
|
+
date: 2017-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ypoloniex
|