gtmtech-crypto 0.0.8 → 0.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: 5afd9afeeee2a816f846d8b605e7b5cf723eedc4
4
- data.tar.gz: 15309f5c7d554a39d6e4ac59ddefc1dc61239875
3
+ metadata.gz: f46c9c9aef20bd2c10db09c32bd54babe62b648a
4
+ data.tar.gz: f4c2dfa08b79ad6c8344af05088479745c85e835
5
5
  SHA512:
6
- metadata.gz: 8f0eeb75050a948182edee7cbd4ab255d1ee11b93505a8956d782e9f0e9621d0786905c4e12e09e64e4035d1169a0b0df1bd8a76990756bee8e9e847817f528f
7
- data.tar.gz: 56ee761e325f1bfeaf1a76e2d49d49732a24761e400fac348b99843cb12835174300da5c63a18f9d93c9658513bd1fe0ee238cac257643cb72c3a1896acdf1d3
6
+ metadata.gz: c92f1bf92055336e8ba92ddd0f78373eff333a41a50146998eac08f9dd4da4176abe56be65456a645458217b59f935012b08e57abfbd9cde7f19058292495953
7
+ data.tar.gz: 689cc7b71547047088ff6960c192a7a15daac222b112253d7ef6a7293a4f532dc5d12016918ea4ae0fcd052a3fc03c908e831b8b0239214bcb5cf45050391582
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |gem|
6
6
  gem.name = "gtmtech-crypto"
7
- gem.version = "0.0.8"
7
+ gem.version = "0.1.0"
8
8
  gem.description = "Simple tool for accounting of cryptocurrencies"
9
9
  gem.summary = "Simple tool for accounting of cryptocurrencies"
10
10
  gem.author = "Geoff Meakin"
@@ -1,7 +1,7 @@
1
1
  module Gtmtech
2
2
  module Crypto
3
3
 
4
- VERSION = "0.0.8"
4
+ VERSION = "0.1.0"
5
5
  DESCRIPTION = "crypto is a cli tool for simple accounting of cryptocurrencies"
6
6
 
7
7
  end
@@ -69,12 +69,17 @@ module Gtmtech
69
69
 
70
70
  def self.list_transactions
71
71
  puts "Transactions for profile \"#{ENV['CRYPTO_PROFILE'] || 'main'}\":"
72
- printf("%-36s %-20s %-15s %-15s %-15s %-15s\n", "id", "date", "src account", "src amount", "dest account", "dest amount")
73
- puts "-" * 120
72
+ printf("%-36s %-20s %-15s %-15s %-15s %-15s %-30s\n", "id", "date", "src account", "src amount", "dest account", "dest amount", "ratio src/dest")
73
+ puts "-" * 150
74
74
  @@document[ "transactions" ].each do |id, txn|
75
- printf("%-36s %-20s %-15s %-15s %-15s %-15s\n", id, txn["date"], "#{txn["source_account"]}.#{txn["source_currency"]}", txn["source_amount"], "#{txn["dest_account"]}.#{txn["dest_currency"]}", txn["dest_amount"])
75
+ ratio = ""
76
+ if txn["source_currency"] != txn["dest_currency"]
77
+ ratio = Utils.decimal_divide( txn["source_amount"], txn["dest_amount"] )
78
+ end
79
+ printf("%-36s %-20s %-15s %-15s %-15s %-15s %-30s\n", id, txn["date"], "#{txn["source_account"]}.#{txn["source_currency"]}", txn["source_amount"], "#{txn["dest_account"]}.#{txn["dest_currency"]}", txn["dest_amount"], ratio)
80
+ ratio = ""
76
81
  if txn["fees_account"]
77
- printf("%-36s %-20s %-15s %-15s %-15s %-15s\n", id, txn["date"], "#{txn["fees_account"]}.#{txn["fees_currency"]}", txn["fees_amount"], "fees.#{txn["fees_currency"]}", txn["fees_amount"])
82
+ printf("%-36s %-20s %-15s %-15s %-15s %-15s %-30s\n", id, txn["date"], "#{txn["fees_account"]}.#{txn["fees_currency"]}", txn["fees_amount"], "fees.#{txn["fees_currency"]}", txn["fees_amount"], ratio)
78
83
  end
79
84
  end
80
85
  end
@@ -83,10 +88,10 @@ module Gtmtech
83
88
  @@document[ "transactions" ].delete( id )
84
89
  end
85
90
 
86
- def self.reconcile_transactions
91
+ def self.reconcile_transactions conversions
87
92
  self.list_transactions
88
93
  puts ""
89
- printf("%-20s %-10s %-20s\n", "account", "currency", "amount")
94
+ printf("%-20s %-10s %-20s %-30s\n", "account", "currency", "amount", "GBP equivalent")
90
95
  puts "-" * 120
91
96
  fees = {}
92
97
  currencies = {}
@@ -125,14 +130,18 @@ module Gtmtech
125
130
  currencies[ currency ] = "0.0"
126
131
  end
127
132
  currencies[ currency ] = Utils.decimal_add( currencies[ currency ], decimal )
128
- printf( "%-20s %-10s %-20s\n", name, currency, decimal )
133
+ gbp_equiv = "?"
134
+ gbp_equiv = Utils.decimal_multiply( decimal, conversions[ currency ] ) if conversions.key? currency
135
+ printf( "%-20s %-10s %-20s %-30s\n", name, currency, decimal, gbp_equiv )
129
136
  end
130
137
  end
131
138
  fees.keys.sort.each do |currency|
132
139
  unless currencies.key? currency
133
140
  currencies[ currency ] = "0.0"
134
141
  end
135
- printf( "%-20s %-10s %-20s\n", "**FEES**", currency, fees[ currency ] )
142
+ gbp_equiv = "?"
143
+ gbp_equiv = Utils.decimal_multiply( fees[ currency ], conversions[ currency ] ) if conversions.key? currency
144
+ printf( "%-20s %-10s %-20s %-30s\n", "**FEES**", currency, fees[ currency ], gbp_equiv)
136
145
  end
137
146
 
138
147
  puts ""
@@ -143,11 +152,28 @@ module Gtmtech
143
152
  printf( "%-10s %-20s\n", currency, Utils.decimal_add( currencies[ currency ], currency_fees ) )
144
153
  end
145
154
 
155
+ gbp_total = "0.0"
156
+ gbp_known = true
146
157
  puts ""
147
- printf( "%-10s %-20s\n", "currency", "totals" )
158
+ printf( "%-10s %-20s %-20s\n", "currency", "totals", "GBP equivalent" )
148
159
  puts "-" * 120
149
160
  currencies.keys.sort.each do |currency|
150
- printf( "%-10s %-20s\n", currency, currencies[ currency ] )
161
+ amount = currencies[ currency ]
162
+ if conversions.key? currency
163
+ gbp_equiv = Utils.decimal_multiply( amount, conversions[ currency ] )
164
+ printf( "%-10s %-20s %-20s\n", currency, currencies[ currency ], gbp_equiv )
165
+ gbp_total = Utils.decimal_add( gbp_total, gbp_equiv )
166
+ else
167
+ printf( "%-10s %-20s %-20s\n", currency, currencies[ currency ], "?" )
168
+ gbp_known = false
169
+ end
170
+ end
171
+
172
+ puts ""
173
+ if gbp_known
174
+ puts "GBP profit/loss (equivalent): #{gbp_total}"
175
+ else
176
+ puts "GBP profit/loss (equivalent): unknown - specify conversions on command-line"
151
177
  end
152
178
  end
153
179
 
@@ -12,11 +12,13 @@ module Gtmtech
12
12
 
13
13
  def self.usage
14
14
  <<-EOS
15
- Usage (crypto #{self.prettyname})
15
+ Usage (crypto #{self.prettyname}) [BTC=<current btc price> ETH=<current eth price> .... etc ...]
16
16
 
17
17
  crypto #{self.prettyname}
18
18
  - reconcile all transactions
19
19
 
20
+ If you specify the current price (in GBP) of each coin, the summary will become more illuminating
21
+
20
22
  Options:
21
23
  EOS
22
24
  end
@@ -25,13 +27,20 @@ EOS
25
27
  []
26
28
  end
27
29
 
28
- def self.reconcile
30
+ def self.reconcile values
29
31
  Data.load
30
- Data.reconcile_transactions
32
+ Data.reconcile_transactions values
31
33
  end
32
34
 
33
35
  def self.execute
34
- self.reconcile
36
+ values = {}
37
+ while ARGV.length > 0
38
+ current_valuation = ARGV.shift
39
+ currency = current_valuation.split("=")[0]
40
+ gbp_equiv = current_valuation.split("=")[1]
41
+ values[ currency ] = gbp_equiv
42
+ end
43
+ self.reconcile values
35
44
  end
36
45
 
37
46
  end
@@ -67,6 +67,14 @@ module Gtmtech
67
67
  ( BigDecimal( decimal1 ) - BigDecimal( decimal2 ) ).to_s("F")
68
68
  end
69
69
 
70
+ def self.decimal_multiply decimal1, decimal2
71
+ ( BigDecimal( decimal1 ) * BigDecimal( decimal2 ) ).truncate(8).to_s("F")
72
+ end
73
+
74
+ def self.decimal_divide decimal1, decimal2
75
+ ( BigDecimal( decimal1 ) / BigDecimal( decimal2 ) ).truncate(8).to_s("F")
76
+ end
77
+
70
78
  end
71
79
  end
72
80
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gtmtech-crypto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geoff Meakin