bitflyer-cli 0.3.0 → 0.4.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 +1 -0
- data/bitflyer-cli.gemspec +1 -1
- data/lib/bitflyer/cli/command/stop_by_range_command.rb +31 -0
- data/lib/bitflyer/cli.rb +12 -5
- 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: 4517d41ea9957027f8f65b7d83fda6ab832e4e00
|
4
|
+
data.tar.gz: 1ea5b15973f8967710962f809ef1bc2cb366b20d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2779b5949da62b10123265e86da3ce6d1553605fa1c185c9ff3a8fd48f6ddadadb36f90c6cf6160949e45ff3b92a078d0a023e4126bdc16c70575ef1b6b105cc
|
7
|
+
data.tar.gz: 3b1765df4786e3075b978853bb0d8f53f138216fe577055276160eebea7a27b2bff4aa6da3b25222e5ff900be32243ea767c8963504c46c2e5b26ffe03770cb7
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -29,6 +29,7 @@ Commands:
|
|
29
29
|
bitflyer help [COMMAND] # Describe available commands or one specific command
|
30
30
|
bitflyer order_by_best -a=amount -t=buy/sell # create limit order by best price in the board
|
31
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 stop_by_range r, --range=price range # create stop order by range based on current position
|
32
33
|
bitflyer summary # show current balance information
|
33
34
|
```
|
34
35
|
|
data/bitflyer-cli.gemspec
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'bitflyer/cli/has_http_client'
|
2
|
+
require 'bitflyer/cli/model/position'
|
3
|
+
|
4
|
+
class StopByRangeCommand
|
5
|
+
include HasHTTPClient
|
6
|
+
|
7
|
+
def run(options)
|
8
|
+
position = Position.new(http_private_client.positions)
|
9
|
+
return puts "You don't have any position now." if position.size == 0
|
10
|
+
|
11
|
+
side = position.average > 0 ? 'SELL' : 'BUY'
|
12
|
+
price = position.average.abs + options.range * (side == 'BUY' ? 1.0 : -1.0)
|
13
|
+
|
14
|
+
response = http_private_client.send_parent_order(
|
15
|
+
order_method: 'SIMPLE',
|
16
|
+
parameters: [{
|
17
|
+
product_code: 'FX_BTC_JPY',
|
18
|
+
condition_type: 'STOP',
|
19
|
+
side: side,
|
20
|
+
trigger_price: price,
|
21
|
+
size: position.size.to_f
|
22
|
+
}]
|
23
|
+
)
|
24
|
+
|
25
|
+
if response['parent_order_acceptance_id'].nil?
|
26
|
+
puts 'An error has occurred' + response.to_s
|
27
|
+
else
|
28
|
+
puts "Set limit order #{side} / #{price} / #{position.size.to_f}"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/bitflyer/cli.rb
CHANGED
@@ -3,15 +3,11 @@ require 'bitflyer/cli/command/cancel_all_command'
|
|
3
3
|
require 'bitflyer/cli/command/counter_trade_command'
|
4
4
|
require 'bitflyer/cli/command/order_by_best_command'
|
5
5
|
require 'bitflyer/cli/command/order_by_twap_command'
|
6
|
+
require 'bitflyer/cli/command/stop_by_range_command'
|
6
7
|
require 'bitflyer/cli/command/summary_command'
|
7
8
|
|
8
9
|
module Bitflyer
|
9
10
|
class CLI < Thor
|
10
|
-
desc 'summary', 'show current balance information'
|
11
|
-
def summary
|
12
|
-
SummaryCommand.new.run
|
13
|
-
end
|
14
|
-
|
15
11
|
desc 'cancel_all', 'cancel all of orders'
|
16
12
|
def cancel_all
|
17
13
|
CancelAllCommand.new.run
|
@@ -37,5 +33,16 @@ module Bitflyer
|
|
37
33
|
def order_by_twap
|
38
34
|
OrderByTWAPCommand.new.run(options)
|
39
35
|
end
|
36
|
+
|
37
|
+
desc 'stop_by_range', 'create stop order by range based on current position'
|
38
|
+
method_option :range, aliases: 'r', type: :numeric, banner: 'price range', required: true
|
39
|
+
def stop_by_range
|
40
|
+
StopByRangeCommand.new.run(options)
|
41
|
+
end
|
42
|
+
|
43
|
+
desc 'summary', 'show current balance information'
|
44
|
+
def summary
|
45
|
+
SummaryCommand.new.run
|
46
|
+
end
|
40
47
|
end
|
41
48
|
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.4.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-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -116,6 +116,7 @@ files:
|
|
116
116
|
- lib/bitflyer/cli/command/counter_trade_command.rb
|
117
117
|
- lib/bitflyer/cli/command/order_by_best_command.rb
|
118
118
|
- lib/bitflyer/cli/command/order_by_twap_command.rb
|
119
|
+
- lib/bitflyer/cli/command/stop_by_range_command.rb
|
119
120
|
- lib/bitflyer/cli/command/summary_command.rb
|
120
121
|
- lib/bitflyer/cli/ext/string.rb
|
121
122
|
- lib/bitflyer/cli/has_http_client.rb
|