bitflyer-cli 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +8 -6
- data/bitflyer-cli.gemspec +1 -1
- data/lib/bitflyer/cli.rb +19 -9
- data/lib/bitflyer/cli/command/order_by_best_command.rb +0 -5
- data/lib/bitflyer/cli/command/order_by_twap_command.rb +34 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f49c29d95f8bcc96146e2a9cfb1f27d0c3689f66
|
4
|
+
data.tar.gz: e2cfaeabf096e224082e0cb8ce0d215ac1e1c0cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 165d8081b1758dc85fce8fdaad7e6a8bf171bcd75482946e872ad13b9abb91627d646aec04ae6da623755264c582f4ff05df899507265f73e03a57d2014222a5
|
7
|
+
data.tar.gz: 7dda475c8d12eebebc9dc3c7373ad66220fa85eeac5c768530078402f8db88e2443be3cce061b3dd3cff332e2456e79b66c9ae322f75fa9f99f931965562cc94
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -16,18 +16,20 @@ gem install bitflyer-cli
|
|
16
16
|
Set the `BITFLYER_API_TOKEN` and `BITFLYER_API_SECRET` environment variable.
|
17
17
|
|
18
18
|
```sh
|
19
|
-
export BITFLYER_API_TOKEN=your-
|
20
|
-
export BITFLYER_API_SECRET=your-
|
19
|
+
export BITFLYER_API_TOKEN=your-bitflyer-api-token
|
20
|
+
export BITFLYER_API_SECRET=your-bitflyer-api-secret
|
21
21
|
```
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
25
|
```
|
26
26
|
Commands:
|
27
|
-
bitflyer
|
28
|
-
bitflyer
|
29
|
-
bitflyer
|
30
|
-
bitflyer
|
27
|
+
bitflyer cancel_all # cancel all of orders
|
28
|
+
bitflyer counter_trade # clear all positions
|
29
|
+
bitflyer help [COMMAND] # Describe available commands or one specific command
|
30
|
+
bitflyer order_by_best -a=amount -t=buy/sell # create limit order by best price in the board
|
31
|
+
bitflyer order_by_twap -a=amount -i=second -n=N -t=buy/sell # trade specified amount N times at specified intervals (TWAP algorithm).
|
32
|
+
bitflyer summary # show current balance information
|
31
33
|
```
|
32
34
|
|
33
35
|
## Contributing
|
data/bitflyer-cli.gemspec
CHANGED
data/lib/bitflyer/cli.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
require 'thor'
|
2
2
|
require 'bitflyer/cli/command/cancel_all_command'
|
3
3
|
require 'bitflyer/cli/command/counter_trade_command'
|
4
|
-
require 'bitflyer/cli/command/summary_command'
|
5
4
|
require 'bitflyer/cli/command/order_by_best_command'
|
5
|
+
require 'bitflyer/cli/command/order_by_twap_command'
|
6
|
+
require 'bitflyer/cli/command/summary_command'
|
6
7
|
|
7
8
|
module Bitflyer
|
8
9
|
class CLI < Thor
|
@@ -11,11 +12,9 @@ module Bitflyer
|
|
11
12
|
SummaryCommand.new.run
|
12
13
|
end
|
13
14
|
|
14
|
-
desc '
|
15
|
-
|
16
|
-
|
17
|
-
def order_by_best
|
18
|
-
OrderByBestCommand.new.run(options)
|
15
|
+
desc 'cancel_all', 'cancel all of orders'
|
16
|
+
def cancel_all
|
17
|
+
CancelAllCommand.new.run
|
19
18
|
end
|
20
19
|
|
21
20
|
desc 'counter_trade', 'clear all positions'
|
@@ -23,9 +22,20 @@ module Bitflyer
|
|
23
22
|
CounterTradeCommand.new.run
|
24
23
|
end
|
25
24
|
|
26
|
-
desc '
|
27
|
-
|
28
|
-
|
25
|
+
desc 'order_by_best', 'create limit order by best price in the board'
|
26
|
+
method_option :amount, aliases: 'a', type: :numeric, banner: 'amount', required: true
|
27
|
+
method_option :type, aliases: 't', type: :string, banner: 'buy/sell', required: true
|
28
|
+
def order_by_best
|
29
|
+
OrderByBestCommand.new.run(options)
|
30
|
+
end
|
31
|
+
|
32
|
+
desc 'order_by_twap', 'order by using TWAP algorithm'
|
33
|
+
method_option :amount, aliases: 'a', type: :numeric, banner: 'amount', required: true
|
34
|
+
method_option :type, aliases: 't', type: :string, banner: 'buy/sell', required: true
|
35
|
+
method_option :number_of_times, aliases: 'n', type: :numeric, banner: 'N', required: true
|
36
|
+
method_option :interval, aliases: 'i', type: :numeric, banner: 'second', required: true
|
37
|
+
def order_by_twap
|
38
|
+
OrderByTWAPCommand.new.run(options)
|
29
39
|
end
|
30
40
|
end
|
31
41
|
end
|
@@ -6,11 +6,6 @@ class OrderByBestCommand
|
|
6
6
|
def run(options)
|
7
7
|
amount = options.amount
|
8
8
|
type = options.type
|
9
|
-
if amount == nil || type == nil
|
10
|
-
puts 'You need set amount by -a and type by -t'
|
11
|
-
puts 'ex: bitflyer order_by_best -a 10 -t buy'
|
12
|
-
return
|
13
|
-
end
|
14
9
|
|
15
10
|
ticker = http_public_client.ticker('FX_BTC_JPY')
|
16
11
|
price = type == 'buy' ? ticker['best_bid'] : ticker['best_ask']
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'bitflyer/cli/has_http_client'
|
2
|
+
|
3
|
+
class OrderByTWAPCommand
|
4
|
+
include HasHTTPClient
|
5
|
+
|
6
|
+
def run(options)
|
7
|
+
type = options.type
|
8
|
+
amount = options.amount
|
9
|
+
number = options.number_of_times
|
10
|
+
interval = options.interval
|
11
|
+
|
12
|
+
number.to_i.times do |_|
|
13
|
+
order(type, amount)
|
14
|
+
sleep interval
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def order(type, amount)
|
21
|
+
response = http_private_client.send_child_order(
|
22
|
+
product_code: 'FX_BTC_JPY',
|
23
|
+
child_order_type: 'MARKET',
|
24
|
+
side: type.upcase,
|
25
|
+
size: amount
|
26
|
+
)
|
27
|
+
|
28
|
+
if response['child_order_acceptance_id'].nil?
|
29
|
+
puts "An error has occurred\n" + response.to_s
|
30
|
+
else
|
31
|
+
puts response.to_s
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bitflyer-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuji Ueki
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -115,6 +115,7 @@ files:
|
|
115
115
|
- lib/bitflyer/cli/command/cancel_all_command.rb
|
116
116
|
- lib/bitflyer/cli/command/counter_trade_command.rb
|
117
117
|
- lib/bitflyer/cli/command/order_by_best_command.rb
|
118
|
+
- lib/bitflyer/cli/command/order_by_twap_command.rb
|
118
119
|
- lib/bitflyer/cli/command/summary_command.rb
|
119
120
|
- lib/bitflyer/cli/ext/string.rb
|
120
121
|
- lib/bitflyer/cli/has_http_client.rb
|