coinpare 0.0.0 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,28 +1,258 @@
1
- # Coinpare
1
+ <div align="center">
2
+ <img width="207" src="https://cdn.rawgit.com/piotrmurach/coinpare/master/assets/coinpare_logo_stacked.png" alt="coinpare logo" />
3
+ </div>
4
+ <br/>
2
5
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/coinpare`. To experiment with that code, run `bin/console` for an interactive prompt.
6
+ # Coinpare [![Gitter](https://badges.gitter.im/Join%20Chat.svg)][gitter]
4
7
 
5
- TODO: Delete this and the text above, and describe your gem
8
+ [![Gem Version](https://badge.fury.io/rb/coinpare.svg)][gem]
9
+ [![Build Status](https://secure.travis-ci.org/piotrmurach/coinpare.svg?branch=master)][travis]
10
+ [![Maintainability](https://api.codeclimate.com/v1/badges/1072406ba7e951e355e4/maintainability)][codeclimate]
11
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/1072406ba7e951e355e4/test_coverage)][coverage]
12
+ [![Inline docs](http://inch-ci.org/github/piotrmurach/coinpare.svg?branch=master)][inchpages]
13
+
14
+ [gitter]: https://gitter.im/piotrmurach/coinpare
15
+ [gem]: http://badge.fury.io/rb/coinpare
16
+ [travis]: http://travis-ci.org/piotrmurach/coinpare
17
+ [codeclimate]: https://codeclimate.com/github/piotrmurach/coinpare/maintainability
18
+ [coverage]: https://codeclimate.com/github/piotrmurach/coinpare/test_coverage
19
+ [inchpages]: http://inch-ci.org/github/piotrmurach/coinpare
20
+
21
+ > Compare cryptocurrency trading data across multiple exchanges and blockchains in the comfort of your terminal
22
+
23
+ A screenshot is worth a thousand words:
24
+
25
+ ![CoinsView](https://github.com/piotrmurach/coinpare/raw/master/assets/coinpare_coins.png)
6
26
 
7
27
  ## Installation
8
28
 
9
- Add this line to your application's Gemfile:
29
+ This project uses Ruby, before installing the `coinpare` tool, you'll need to ensure Ruby is installed on your machine.
30
+
31
+ In your terminal execute `ruby` command with `-v` option:
32
+
33
+ ```
34
+ $ ruby -v
35
+ ```
36
+
37
+ If you have version of Ruby greater than `2.0.0` then you're good to go.
38
+
39
+ Otherwise, please follow [Installing Ruby](https://www.ruby-lang.org/en/documentation/installation/#apt) to pick best installation method for your operating system.
40
+
41
+ Once Ruby is installed, install the `coinpare` gem:
10
42
 
11
- ```ruby
12
- gem 'coinpare'
43
+ ```
44
+ $ gem install coinpare
13
45
  ```
14
46
 
15
- And then execute:
47
+ And then execute `coinpare` to see all available options:
16
48
 
17
- $ bundle
49
+ ```
50
+ $ coinpare
51
+ ```
18
52
 
19
- Or install it yourself as:
53
+ ## Features
20
54
 
21
- $ gem install coinpare
55
+ * Compare chosen or top coins trading info(price, vol, open, high, low etc)
56
+ * Compare top markets by a trading coin pair
57
+ * Create your custom portfolio and track your holdings
58
+ * Auto refresh cryptocurrencies info with a configurable time interval
22
59
 
23
60
  ## Usage
24
61
 
25
- TODO: Write usage instructions here
62
+ To use all available commands, run the folling in your terminal:
63
+
64
+ ```bash
65
+ $ coinpare
66
+ ```
67
+
68
+ You will be presented with the following interface:
69
+
70
+ ![Interface](https://github.com/piotrmurach/coinpare/raw/master/assets/coinpare_interface.png)
71
+
72
+ ## View coins
73
+
74
+ You can see top 10 trading info (price, volume, open, high, low etc) of any cyptocurrency in any other currency by executing the following in your terminal:
75
+
76
+ ```bash
77
+ $ coinpare coins
78
+ ```
79
+
80
+ By default, `USD` is used as the base currency price conversion. You can change this by passing `--base` or `-b` flag:
81
+
82
+ ```bash
83
+ $ coinpare coins --base BTC
84
+ ```
85
+
86
+ If you wish to see more currencies use `--top` flag:
87
+
88
+ ```bash
89
+ $ coinpare coins --top 30
90
+ ```
91
+
92
+ Alternatively, you can specify exactly the coins you're interested in by naming them separated by space:
93
+
94
+ ```bash
95
+ $ coinpare coins ETH BCH LTC --base btc
96
+ ```
97
+
98
+ You can also change the default exchange `CCCAGG` using the `--exchange` or `-e` flag:
99
+
100
+ ```bash
101
+ $ coinpare coins BTC ETH --exchange coinbase
102
+ ```
103
+
104
+ See [view markets](#view-markets) for more information on available exchanges.
105
+
106
+ Finally, if you want to auto refresh data use `--watch` or `-w` flag:
107
+
108
+ ```bash
109
+ $ coinpare coins --watch
110
+ $ coinpare coins -w
111
+ ```
112
+
113
+ You can watch for changes on your preferred cryptocurrencies:
114
+
115
+ ```bash
116
+ $ coinpare coins BTC ETH LTC ZEC --watch
117
+ ```
118
+
119
+ By default 5 seconds interval is used which you can change by providing a new value after `--watch` flag:
120
+
121
+ ```bash
122
+ $ coinpare coins --watch 20 # every 20 seconds
123
+ ```
124
+
125
+ To finish watching for changes hold down `Ctrl+C` key combination.
126
+
127
+ ## View markets
128
+
129
+ You can get top markets by volume for any currency pair. By default 10 top exchanges for the BTC and USD pair by their total volume across all markets in the last 24 hours are displayed.
130
+
131
+ ```bash
132
+ $ coinpare markets
133
+ ```
134
+
135
+ is equivalent to:
136
+
137
+ ```bash
138
+ $ coinpare markets BTC --base USD
139
+ ```
140
+
141
+ An example output:
142
+
143
+ ![MarketsView](https://github.com/piotrmurach/coinpare/raw/master/assets/coinpare_markets.png)
144
+
145
+ To change the pair do:
146
+
147
+ ```bash
148
+ $ coinpare markets ETH -b BTC
149
+ ```
150
+
151
+ You can specify the number of displayed exchanges with `--top` or `-t` flag:
152
+
153
+ ```bash
154
+ $ coinpare markets --top 30
155
+ ```
156
+
157
+ To watch for changes use the `--watch` or `-w` flag:
158
+
159
+ ```bash
160
+ $ coinpare markets --watch
161
+ $ coinpare markets -w
162
+ ```
163
+
164
+ To finish watching for changes hold down `Ctrl+C` key combination.
165
+
166
+ ## Create portfolio
167
+
168
+ There is an easy way for you to keep track of all your investments using the `holdings` command.
169
+ When run for the first time, you will be presented with a prompt that will guide you through the portfolio setup and allow you to add as many holdings as you wish.
170
+
171
+ ```bash
172
+ $ coinpare holdings
173
+ ```
174
+
175
+ The prompt may look:
176
+
177
+ ![CreateHoldings](https://github.com/piotrmurach/coinpare/raw/master/assets/coinpare_create_holdings.png)
178
+
179
+ All your holdings information will be persisted in your user home directory in a file called `coinpare.toml`. You can edit this file directly using your configured editor by passing the `--edit` flag:
180
+
181
+ ```bash
182
+ $ coinpare holdings --edit
183
+ ```
184
+
185
+ An example configuration file may look:
186
+
187
+ ```
188
+ [[holdings]]
189
+ amount = 1.0
190
+ name = "BTC"
191
+ price = 9000.0
192
+
193
+ [[holdings]]
194
+ amount = 5.0
195
+ name = "LTC"
196
+ price = 100.0
197
+
198
+ [[holdings]]
199
+ amount = 2.3
200
+ name = "BTC"
201
+ price = 5000.0
202
+
203
+ [[holdings]]
204
+ amount = 1000.0
205
+ name = "TRX"
206
+ price = 2.0
207
+
208
+ [settings]
209
+ base = "USD"
210
+ color = true
211
+ exchange = "CCCAGG"
212
+ ```
213
+
214
+ Once configured, any subsequent execution of `holdings` command will display current prices and totals. For example, the beforementioned configuration file may produce the following result:
215
+
216
+ ![ViewHoldings](https://github.com/piotrmurach/coinpare/raw/master/assets/coinpare_holdings.png)
217
+
218
+ Similar to other commands, if you want to auto refresh data use `--watch` or `-w` flag:
219
+
220
+ ```bash
221
+ $ coinpare holdings --watch
222
+ $ coinpare holdings -w
223
+ ```
224
+
225
+ To finish watching for changes hold down `Ctrl+C` key combination.
226
+
227
+ ### Add/remove coins
228
+
229
+ **Coinpare** allows you to easily add and remove individual coins to and from your holdings portfolio.
230
+
231
+ To add a coin to your current portfolio use `--add` flag
232
+
233
+ ```bash
234
+ $ coinpare holdings --add
235
+ ```
236
+
237
+ For example, the following screenshot shows adding an `ETH` coin:
238
+
239
+ ![AddHoldings](https://github.com/piotrmurach/coinpare/raw/master/assets/coinpare_holdings_add.png)
240
+
241
+ To remove one or more coins from your current portfolio use `--remove` flag:
242
+
243
+ ```bash
244
+ $ coinpare holdings --remove
245
+ ```
246
+
247
+ You will be presented with a multi select menu that contains all current holdings similar to the one below:
248
+
249
+ ![RemoveHoldings](https://github.com/piotrmurach/coinpare/raw/master/assets/coinpare_holdings_remove.png)
250
+
251
+ Finally, if you wish to clear all your holdings and start again use `--clear` flag:
252
+
253
+ ```bash
254
+ $ coinpare holdings --clear
255
+ ```
26
256
 
27
257
  ## Development
28
258
 
@@ -32,12 +262,16 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
32
262
 
33
263
  ## Contributing
34
264
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/coinpare. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
265
+ Bug reports and pull requests are welcome on GitHub at https://github.com/piotrmurach/coinpare. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
266
+
267
+ ## Code of Conduct
36
268
 
37
- ## License
269
+ Everyone interacting in the Coinpare project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/piotrmurach/coinpare/blob/master/CODE_OF_CONDUCT.md).
38
270
 
39
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
271
+ ## Credits
40
272
 
41
- ## Code of Conduct
273
+ All the data is obtained from [CryptoCompare](https://www.cryptocompare.com/api).
274
+
275
+ ## Copyright
42
276
 
43
- Everyone interacting in the Coinpare project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/coinpare/blob/master/CODE_OF_CONDUCT.md).
277
+ Copyright (c) 2018 Piotr Murach. See [GNU Affero General Public License v3.0](LICENSE.txt) for further details.
data/Rakefile CHANGED
@@ -3,4 +3,7 @@ require "rspec/core/rake_task"
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task :default => :spec
6
+ desc 'Run all specs'
7
+ task ci: %w[ spec ]
8
+
9
+ task default: :spec
data/coinpare.gemspec CHANGED
@@ -1,26 +1,42 @@
1
-
2
1
  lib = File.expand_path("../lib", __FILE__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require "coinpare/version"
5
4
 
6
5
  Gem::Specification.new do |spec|
7
6
  spec.name = "coinpare"
7
+ spec.license = "AGPL-3.0"
8
8
  spec.version = Coinpare::VERSION
9
9
  spec.authors = ["Piotr Murach"]
10
- spec.email = []
10
+ spec.email = [""]
11
11
 
12
- spec.summary = %q{Write a short summary, because RubyGems requires one.}
13
- spec.description = %q{Write a longer description or delete this line.}
14
- spec.license = "MIT"
12
+ spec.summary = %q{Compare cryptocurrency trading data across multiple exchanges and blockchains.}
13
+ spec.description = %q{Compare cryptocurrency trading data across multiple exchanges and blockchains.}
14
+ spec.homepage = "https://github.com/piotrmurach/coinpare"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
- f.match(%r{^(test|spec|features)/})
17
+ f.match(%r{^(test|spec|features|assets)/})
18
18
  end
19
19
  spec.bindir = "exe"
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ["lib"]
22
22
 
23
+ spec.add_dependency "tty-color", "~> 0.4.2"
24
+ spec.add_dependency "tty-config", "~> 0.2.0"
25
+ spec.add_dependency "tty-cursor", "~> 0.5.0"
26
+ spec.add_dependency "tty-editor", "~> 0.4.0"
27
+ spec.add_dependency "tty-font", "~> 0.2.0"
28
+ spec.add_dependency "tty-pager", "~> 0.11.0"
29
+ spec.add_dependency "tty-prompt", "~> 0.16.1"
30
+ spec.add_dependency "tty-spinner", "~> 0.8.0"
31
+ spec.add_dependency "tty-table", "~> 0.10.0"
32
+ spec.add_dependency "pastel", "~> 0.7.2"
33
+ spec.add_dependency "thor", "~> 0.20.0"
34
+ spec.add_dependency "toml", "~> 0.2.0"
35
+ spec.add_dependency "timers", "~> 4.1.2"
36
+
23
37
  spec.add_development_dependency "bundler", "~> 1.16"
24
38
  spec.add_development_dependency "rake", "~> 10.0"
25
39
  spec.add_development_dependency "rspec", "~> 3.0"
40
+ spec.add_development_dependency "webmock", "~> 3.3"
41
+ spec.add_development_dependency "timecop", "~> 0.9.1"
26
42
  end
data/exe/coinpare ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ lib_path = File.expand_path('../lib', __dir__)
5
+ $:.unshift(lib_path) if !$:.include?(lib_path)
6
+ require 'coinpare/cli'
7
+
8
+ Signal.trap('INT') do
9
+ warn("\n#{caller.join("\n")}: interrupted")
10
+ exit(1)
11
+ end
12
+
13
+ begin
14
+ Coinpare::CLI.start
15
+ rescue Coinpare::CLI::Error => err
16
+ puts "ERROR: #{err.message}"
17
+ exit 1
18
+ end
data/lib/coinpare.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  require "coinpare/version"
2
2
 
3
3
  module Coinpare
4
- # Your code goes here...
5
4
  end
@@ -0,0 +1,148 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'thor'
4
+ require 'pastel'
5
+ require 'tty-font'
6
+
7
+ module Coinpare
8
+ # Handle the application command line parsing
9
+ # and the dispatch to various command objects
10
+ #
11
+ # @api public
12
+ class CLI < Thor
13
+ # Error raised by this runner
14
+ Error = Class.new(StandardError)
15
+
16
+ def help(*args)
17
+ font = TTY::Font.new(:standard)
18
+ pastel = Pastel.new(enabled: !options['no-color'])
19
+ puts pastel.yellow(font.write("Coinpare"))
20
+ super
21
+ end
22
+
23
+ class_option :"no-color", type: :boolean, default: false,
24
+ desc: 'Disable colorization in output'
25
+
26
+ desc 'coins NAMES...', 'Get all the current trading data for the coin names...'
27
+ long_desc <<-DESC
28
+ Get all the current trading info (price, vol, open, high, low etc)
29
+ of any list of cryptocurrencies in any other currency that you need.
30
+
31
+ By default 10 top coins by their total volume across all markets in
32
+ the last 24 hours.
33
+
34
+ Example:
35
+
36
+ > $ coinpare coins BTC ETH --base USD
37
+
38
+ Example:
39
+
40
+ > $ coinpare coins BTC ETH --exchange coinbase
41
+ DESC
42
+ method_option :base, aliases: '-b', type: :string, default: "USD",
43
+ desc: 'The currency symbol to convert into',
44
+ banner: 'CURRENCY'
45
+ method_option :columns, aliases: '-c', type: :array,
46
+ desc: 'Specify columns to display',
47
+ banner: '0 1 2'
48
+ method_option :exchange, aliases: '-e', type: :string, default: "CCCAGG",
49
+ desc: 'Name of exchange',
50
+ banner: 'name'
51
+ method_option :help, aliases: '-h', type: :boolean,
52
+ desc: 'Display usage information'
53
+ method_option :top, aliases: '-t', type: :numeric, default: 10, banner: 'N',
54
+ desc: "The number of top coins by total volume accross all markets in 24 hours"
55
+ method_option :watch, aliases: '-w', banner: 'N',
56
+ desc: 'Automatically refresh data every n seconds, default 5 sec'
57
+ def coins(*names)
58
+ if options[:help]
59
+ invoke :help, ['coins']
60
+ else
61
+ require_relative 'commands/coins'
62
+ Coinpare::Commands::Coins.new(names, options).execute
63
+ end
64
+ end
65
+
66
+ desc 'holdings', 'Keep track of all your cryptocurrency investments'
67
+ long_desc <<-DESC
68
+ Get the current trading prices and their change in value and percentage
69
+ for all your cryptocurrency investments.
70
+
71
+ Example:
72
+
73
+ > $ coinpare holdings
74
+
75
+ Example
76
+
77
+ > $ coinpare holdings --exchange coinbase --base USD
78
+ DESC
79
+ method_option :add, type: :boolean,
80
+ desc: "Add a new coin without altering any existhing holdings"
81
+ method_option :base, aliases: '-b', type: :string,
82
+ desc: 'The currency symbol to convert into',
83
+ banner: 'CURRENCY'
84
+ method_option :clear, type: :boolean, default: false,
85
+ desc: 'Remove all coins from your existing holdings'
86
+ method_option :edit, type: :string, banner: 'editor',
87
+ desc: 'Open the holdings configuration file for editing in EDITOR, or the default editor if not specified.'
88
+ method_option :exchange, aliases: '-e', type: :string,
89
+ desc: 'Name of exchange', banner: 'NAME'
90
+ method_option :help, aliases: '-h', type: :boolean,
91
+ desc: 'Display usage information'
92
+ method_option :remove, type: :boolean,
93
+ desc: "Remove the given coin(s) from holdings"
94
+ method_option :watch, aliases: '-w', banner: 'N',
95
+ desc: 'Automatically refresh data every n seconds, default 5 sec'
96
+ def holdings(*)
97
+ if options[:help]
98
+ invoke :help, ['holdings']
99
+ else
100
+ require_relative 'commands/holdings'
101
+ Coinpare::Commands::Holdings.new(options).execute
102
+ end
103
+ end
104
+
105
+ desc 'markets [NAME]', 'Get top markets by volume for a currency pair'
106
+ long_desc <<-DESC
107
+ Get top markets by volume for a currency pair.
108
+
109
+ By default 10 top markets by their total volume across all markets in
110
+ the last 24 hours.
111
+
112
+ Example:
113
+
114
+ > $ coinpare markets BTC --base USD
115
+
116
+ Example:
117
+
118
+ > $ coinpare markets ETH -b BTC
119
+ DESC
120
+ method_option :base, aliases: '-b', type: :string, default: "USD",
121
+ desc: 'The currency symbol to convert into',
122
+ banner: 'CURRENCY'
123
+ method_option :columns, aliases: '-c', type: :array,
124
+ desc: 'Specify columns to display',
125
+ banner: '0 1 2'
126
+ method_option :help, aliases: '-h', type: :boolean,
127
+ desc: 'Display usage information'
128
+ method_option :top, aliases: '-t', type: :numeric, default: 10,
129
+ desc: "The number of top exchanges by total volume in 24 hours"
130
+ method_option :watch, aliases: '-w', banner: 'N',
131
+ desc: 'Automatically refresh data every n seconds, default 5 sec'
132
+ def markets(name = 'BTC')
133
+ if options[:help]
134
+ invoke :help, ['markets']
135
+ else
136
+ require_relative 'commands/markets'
137
+ Coinpare::Commands::Markets.new(name, options).execute
138
+ end
139
+ end
140
+
141
+ desc 'version', 'coinpare version'
142
+ def version
143
+ require_relative 'version'
144
+ puts "v#{Coinpare::VERSION}"
145
+ end
146
+ map %w(--version -v) => :version
147
+ end
148
+ end