mycoins 0.3.4 → 0.3.5
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
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/mycoins.rb +43 -12
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd59d18937ce9fc62449408978b57aa3d7a099f2
|
4
|
+
data.tar.gz: 7f180dd3ed3f2a909abfacf039e56c17957d954a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 396925dc7f5288544eb79dc0ec5f964322624f7c82e77e4ded10ca5b20086c8343805468c404c614d674e8a33fe9730f2e94efc77f4da4691f12735c91936957
|
7
|
+
data.tar.gz: c45831af7f6479299ba68a5709a8c35cc1405937d0e171bfc0865cc894d0c07d548c6718abe18e66168be6bc477f534d45bd44a103dccc2e24bc5a4f7d590b9e
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/mycoins.rb
CHANGED
@@ -14,7 +14,7 @@ class MyCoins
|
|
14
14
|
def initialize(source, date: nil, debug: false,
|
15
15
|
mycurrency: 'USD', filepath: 'mycoins', colored: true)
|
16
16
|
|
17
|
-
@debug, @filepath, @
|
17
|
+
@debug, @filepath, @colored = debug, filepath, colored
|
18
18
|
|
19
19
|
@jer = JustExchangeRates.new(base: 'USD')
|
20
20
|
|
@@ -69,6 +69,45 @@ class MyCoins
|
|
69
69
|
File.write filepath, to_xml
|
70
70
|
|
71
71
|
end
|
72
|
+
|
73
|
+
def to_dx()
|
74
|
+
|
75
|
+
r = build_portfolio(@dx.title)
|
76
|
+
dx = Dynarex.new
|
77
|
+
dx.import r.records
|
78
|
+
|
79
|
+
h = r.to_h
|
80
|
+
h.delete :records
|
81
|
+
dx.summary.merge!(h)
|
82
|
+
|
83
|
+
dx
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
def to_openstruct()
|
88
|
+
build_portfolio(@dx.title)
|
89
|
+
end
|
90
|
+
|
91
|
+
def to_percentages()
|
92
|
+
|
93
|
+
all = self.to_dx.to_a
|
94
|
+
val = ('value_' + @mycurrency.downcase).to_sym
|
95
|
+
|
96
|
+
a = all.map {|x| x[val].to_f }
|
97
|
+
sum = a.inject(&:+)
|
98
|
+
|
99
|
+
a2 = all.map do |x|
|
100
|
+
[x[:title].sub(/\s+\[[^\]]\]+/,''), (x[val].to_f).round(2)]
|
101
|
+
end.group_by(&:first).to_a
|
102
|
+
|
103
|
+
a3 = a2.map do |x|
|
104
|
+
[x.first, ((x[1].inject(0) {|r,y| r + y[1].to_f} / sum.to_f) * 100)\
|
105
|
+
.round(2)]
|
106
|
+
end
|
107
|
+
|
108
|
+
a3.sort_by(&:last).reverse.to_h
|
109
|
+
|
110
|
+
end
|
72
111
|
|
73
112
|
def to_s()
|
74
113
|
@ccf.to_s
|
@@ -99,15 +138,7 @@ class MyCoins
|
|
99
138
|
|
100
139
|
def to_xml()
|
101
140
|
|
102
|
-
|
103
|
-
dx = Dynarex.new
|
104
|
-
dx.import r.records
|
105
|
-
|
106
|
-
h = r.to_h
|
107
|
-
h.delete :records
|
108
|
-
dx.summary.merge!(h)
|
109
|
-
|
110
|
-
dx.to_xml pretty: true
|
141
|
+
self.to_dx().to_xml pretty: true
|
111
142
|
|
112
143
|
end
|
113
144
|
|
@@ -153,7 +184,7 @@ class MyCoins
|
|
153
184
|
pct_gross_profit: pct_gross_profit,
|
154
185
|
pct_losses: pct_losses,
|
155
186
|
net_profit: sum(a, :roi).round(2),
|
156
|
-
pct_net_profit: pct_gross_profit + pct_losses
|
187
|
+
pct_net_profit: (pct_gross_profit + pct_losses).round(2)
|
157
188
|
}
|
158
189
|
|
159
190
|
@portfolio = OpenStruct.new(h)
|
@@ -284,7 +315,7 @@ class MyCoins
|
|
284
315
|
[c(r.gross_profit), @mycurrency, c(r.pct_gross_profit.to_s + "%")]
|
285
316
|
out << "\nLosses: %.2f %s (%.2f%%)" % [r.losses, @mycurrency, r.pct_losses]
|
286
317
|
out << "\n\nNet profit: %s %s (%s)" % [c(r.net_profit), @mycurrency,
|
287
|
-
|
318
|
+
c(r.pct_net_profit.to_s + "%")]
|
288
319
|
out << "\nCurrent value: %.2f %s (%s BTC)" % [r.value, @mycurrency,
|
289
320
|
r.btc_value]
|
290
321
|
out
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mycoins
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
sCz5KsiHA9vj8OfrxhYrEb+ML4+J28Umdki7V1vgnQWmnI+Ok2SWlkScgzcmGXF6
|
31
31
|
TJ4=
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2018-
|
33
|
+
date: 2018-04-30 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: dynarex
|
metadata.gz.sig
CHANGED
Binary file
|