mycoins 0.2.3 → 0.2.4
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/lib/mycoins.rb +12 -9
 - data.tar.gz.sig +0 -0
 - 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: a1efe36d3e0e78d37ba9d8e94ba52cc347ff66dc
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 325e8c74caca5ef03df0870426ac707061028583
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 2b7426d402a069a60d445078870dd384c77315caa383556371372ad49720b533e32381d790ac8bc3b32574151a0365cfc473186dfadf5ad487dfb065b054f547
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: a60262e526a64cc3e76defbb1911ba0a94cfa5b0d0a05c3bb27f042cd7cc5a109a2d290fc935fa15d1d50a72e63834309d56e26f87729c8af91e712bbbbb3c36
         
     | 
    
        checksums.yaml.gz.sig
    CHANGED
    
    | 
         Binary file 
     | 
    
        data/lib/mycoins.rb
    CHANGED
    
    | 
         @@ -24,6 +24,8 @@ class MyCoins 
     | 
|
| 
       24 
24 
     | 
    
         | 
| 
       25 
25 
     | 
    
         
             
                  @dx = Dynarex.new
         
     | 
| 
       26 
26 
     | 
    
         
             
                  @dx.import s
         
     | 
| 
      
 27 
     | 
    
         
            +
                  
         
     | 
| 
      
 28 
     | 
    
         
            +
                  puts @dx.to_xml pretty: true
         
     | 
| 
       27 
29 
     | 
    
         | 
| 
       28 
30 
     | 
    
         
             
                end
         
     | 
| 
       29 
31 
     | 
    
         | 
| 
         @@ -36,7 +38,7 @@ class MyCoins 
     | 
|
| 
       36 
38 
     | 
    
         | 
| 
       37 
39 
     | 
    
         
             
                mycoins = @dx.all.inject([]) do |r, mycoin|
         
     | 
| 
       38 
40 
     | 
    
         | 
| 
       39 
     | 
    
         
            -
                  found = c.find mycoin.title
         
     | 
| 
      
 41 
     | 
    
         
            +
                  found = c.find mycoin.title.gsub(/\s+\[[^\]]+\]/,'')
         
     | 
| 
       40 
42 
     | 
    
         
             
                  found ? r << found.symbol : r
         
     | 
| 
       41 
43 
     | 
    
         | 
| 
       42 
44 
     | 
    
         
             
                end
         
     | 
| 
         @@ -63,7 +65,7 @@ class MyCoins 
     | 
|
| 
       63 
65 
     | 
    
         
             
              #
         
     | 
| 
       64 
66 
     | 
    
         
             
              def price(coin_name, qty, btc: nil, date: nil)
         
     | 
| 
       65 
67 
     | 
    
         
             
                coin = @ccf.find(coin_name)
         
     | 
| 
       66 
     | 
    
         
            -
                "%.2f %s" % [(coin.price_usd.to_f * qty) * @jer.rate(@mycurrency), 
         
     | 
| 
      
 68 
     | 
    
         
            +
                "%.2f %s" % [(coin.price_usd.to_f * qty.to_f) * @jer.rate(@mycurrency), 
         
     | 
| 
       67 
69 
     | 
    
         
             
                             @mycurrency]
         
     | 
| 
       68 
70 
     | 
    
         
             
              end
         
     | 
| 
       69 
71 
     | 
    
         | 
| 
         @@ -78,7 +80,8 @@ class MyCoins 
     | 
|
| 
       78 
80 
     | 
    
         | 
| 
       79 
81 
     | 
    
         
             
                r = build_portfolio(@dx.title)
         
     | 
| 
       80 
82 
     | 
    
         
             
                dx = Dynarex.new    
         
     | 
| 
       81 
     | 
    
         
            -
                 
     | 
| 
      
 83 
     | 
    
         
            +
                puts 'r.records: ' + r.records.inspect
         
     | 
| 
      
 84 
     | 
    
         
            +
                dx.import r.records    
         
     | 
| 
       82 
85 
     | 
    
         | 
| 
       83 
86 
     | 
    
         
             
                h = r.to_h
         
     | 
| 
       84 
87 
     | 
    
         
             
                h.delete :records
         
     | 
| 
         @@ -110,7 +113,7 @@ class MyCoins 
     | 
|
| 
       110 
113 
     | 
    
         
             
                  records: a,
         
     | 
| 
       111 
114 
     | 
    
         
             
                  datetime: Time.now.strftime("%d/%m/%Y at %H:%M%p"),
         
     | 
| 
       112 
115 
     | 
    
         
             
                  invested: invested,
         
     | 
| 
       113 
     | 
    
         
            -
                   
     | 
| 
      
 116 
     | 
    
         
            +
                  value: sum(a, ('value_' + @mycurrency.downcase).to_sym),      
         
     | 
| 
       114 
117 
     | 
    
         
             
                  gross_profit: gross_profit.round(2), losses: losses.round(2),
         
     | 
| 
       115 
118 
     | 
    
         
             
                  pct_gross_profit: (100 / (invested / gross_profit)).round(2),
         
     | 
| 
       116 
119 
     | 
    
         
             
                  pct_losses: (100 / (invested / losses)).round(2),
         
     | 
| 
         @@ -127,7 +130,7 @@ class MyCoins 
     | 
|
| 
       127 
130 
     | 
    
         
             
                @dx.all.inject([]) do |r, x|
         
     | 
| 
       128 
131 
     | 
    
         | 
| 
       129 
132 
     | 
    
         
             
                  puts 'x: ' + x.inspect if @debug
         
     | 
| 
       130 
     | 
    
         
            -
                  coin = @ccf.find(x.title)
         
     | 
| 
      
 133 
     | 
    
         
            +
                  coin = @ccf.find(x.title.gsub(/\s+\[[^\]]+\]/,''))
         
     | 
| 
       131 
134 
     | 
    
         
             
                  usd_rate = coin.price_usd.to_f      
         
     | 
| 
       132 
135 
     | 
    
         | 
| 
       133 
136 
     | 
    
         
             
                  paid = ((x.qty.to_f * x.btc_price.to_f) * \
         
     | 
| 
         @@ -139,8 +142,8 @@ class MyCoins 
     | 
|
| 
       139 
142 
     | 
    
         
             
                  h = {
         
     | 
| 
       140 
143 
     | 
    
         
             
                    title: x.title,         
         
     | 
| 
       141 
144 
     | 
    
         
             
                    rank: coin.rank.to_i,
         
     | 
| 
       142 
     | 
    
         
            -
                    qty: x.qty,
         
     | 
| 
       143 
     | 
    
         
            -
                    btc_price: x.btc_price,
         
     | 
| 
      
 145 
     | 
    
         
            +
                    qty: "%.2f" % x.qty,
         
     | 
| 
      
 146 
     | 
    
         
            +
                    btc_price:  "%.4f" % x.btc_price,
         
     | 
| 
       144 
147 
     | 
    
         
             
                    paid: "%.2f" % paid,
         
     | 
| 
       145 
148 
     | 
    
         
             
                    value_usd: "%.2f" % value_usd
         
     | 
| 
       146 
149 
     | 
    
         
             
                  }
         
     | 
| 
         @@ -178,7 +181,7 @@ class MyCoins 
     | 
|
| 
       178 
181 
     | 
    
         
             
                coins = r.records.sort_by {|x| -x[order_by].to_f}.map {|x| x.values}
         
     | 
| 
       179 
182 
     | 
    
         
             
                coins.reverse! if order_by == :rank
         
     | 
| 
       180 
183 
     | 
    
         | 
| 
       181 
     | 
    
         
            -
                labels = %w(Rank  
     | 
| 
      
 184 
     | 
    
         
            +
                labels = %w(Name Rank Qty btc_price) \
         
     | 
| 
       182 
185 
     | 
    
         
             
                    + ["paid(#{@mycurrency}):", 'value(USD):']
         
     | 
| 
       183 
186 
     | 
    
         
             
                labels << "value(#{@mycurrency}):" if @mycurrency    
         
     | 
| 
       184 
187 
     | 
    
         
             
                labels += ['Profit:', 'Profit (%):']
         
     | 
| 
         @@ -191,11 +194,11 @@ class MyCoins 
     | 
|
| 
       191 
194 
     | 
    
         
             
                out << tf.display
         
     | 
| 
       192 
195 
     | 
    
         | 
| 
       193 
196 
     | 
    
         
             
                out << "\n\nInvested: %.2f %s" % [r.invested, @mycurrency]
         
     | 
| 
       194 
     | 
    
         
            -
                out << "\nRevenue: %.2f %s" % [r.revenue, @mycurrency]    
         
     | 
| 
       195 
197 
     | 
    
         
             
                out << "\n\nGross profit: %.2f %s (%%%.2f)" % \
         
     | 
| 
       196 
198 
     | 
    
         
             
                    [r.gross_profit, @mycurrency, r.pct_gross_profit]
         
     | 
| 
       197 
199 
     | 
    
         
             
                out << "\nLosses: %.2f %s (%%%.2f)" % [r.losses, @mycurrency, r.pct_losses]
         
     | 
| 
       198 
200 
     | 
    
         
             
                out << "\n\nNet profit: %.2f %s" % [r.net_profit, @mycurrency]
         
     | 
| 
      
 201 
     | 
    
         
            +
                out << "\nCurrent value: %.2f %s" % [r.value, @mycurrency]        
         
     | 
| 
       199 
202 
     | 
    
         
             
                out
         
     | 
| 
       200 
203 
     | 
    
         | 
| 
       201 
204 
     | 
    
         
             
              end
         
     | 
    
        data.tar.gz.sig
    CHANGED
    
    | 
         Binary file 
     | 
    
        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.2. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.2.4
         
     | 
| 
       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-01- 
     | 
| 
      
 33 
     | 
    
         
            +
            date: 2018-01-09 00:00:00.000000000 Z
         
     | 
| 
       34 
34 
     | 
    
         
             
            dependencies:
         
     | 
| 
       35 
35 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       36 
36 
     | 
    
         
             
              name: dynarex
         
     | 
    
        metadata.gz.sig
    CHANGED
    
    | 
         Binary file 
     |