coss_bot 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9895fbea285208da3bbbe43ebfb6fa29c5c2d25243b58f820cc17013bf2e8d48
4
- data.tar.gz: 27be62d97660d1ad97ea6807d77b2c1ce56d2593fa9858882c1c3547618b4961
3
+ metadata.gz: c85e32211ac8fd1a7c3d1f8baafeba6a841423b868a3fb98e4ed91fae93aeb00
4
+ data.tar.gz: 1afa1f2048c150ecb1e84fa535627a2068bc86a8d16368b62db55190cad07d70
5
5
  SHA512:
6
- metadata.gz: d3df14dd565d5cd8bffe50da61051746554aecd4c15b29de82c00b8e4c301f10a6a432125d9322245cdd6fb8e66730e696812aac169df0b31ef916a0e70bedfe
7
- data.tar.gz: b1cb23ba789ef0c689fd2d09ec7f703faa7ef89162468fca1a208adcce0bfb8f4b346d95ca3bde2321a19e67a300c84c3530a9fbf0aa0e4cb66fb91905a39385
6
+ metadata.gz: 5f2bc2c5727d184947560a6f2410266e82e38b81a39fdd5255547ea3fe07245f0bff95dc7aaa0c0e5a73cbec92c455c8b619b9ea41cb7d786426c7017ab6e8d5
7
+ data.tar.gz: ab694d3a8b7296621a4672efa6c1a0e193b797b57cd7b1bb02ef933ce450f7860d6708e3dec4eda9c3191b05d2bf0229ac86427ec001c2a3a67e0c19affc4325
data/Gemfile CHANGED
@@ -6,4 +6,4 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
6
 
7
7
  # Specify your gem's dependencies in coss_bot.gemspec
8
8
  gemspec
9
- gem 'coss_api_ruby_wrapper', '~> 0.1'
9
+ gem 'coss_api_ruby_wrapper', '0.1.1'
data/Gemfile.lock CHANGED
@@ -1,13 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- coss_bot (0.1.0)
5
- coss_api_ruby_wrapper (~> 0.1)
4
+ coss_bot (0.1.1)
5
+ coss_api_ruby_wrapper (= 0.1.1)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- coss_api_ruby_wrapper (0.1.0)
10
+ coss_api_ruby_wrapper (0.1.1)
11
11
  diff-lcs (1.3)
12
12
  rake (10.5.0)
13
13
  rspec (3.8.0)
@@ -29,7 +29,7 @@ PLATFORMS
29
29
 
30
30
  DEPENDENCIES
31
31
  bundler (~> 1.17)
32
- coss_api_ruby_wrapper (~> 0.1)
32
+ coss_api_ruby_wrapper (= 0.1.1)
33
33
  coss_bot!
34
34
  rake (~> 10.0)
35
35
  rspec (~> 3.0)
data/README.md CHANGED
@@ -27,8 +27,8 @@ bot.lot_size = 10 # 10 coss tokens will be bought/sold
27
27
  bot.profit = 0.1 # SELL order will be 0.1% higher than BUY order
28
28
  bot.pair = 'COSS_ETH' # Bot will work on COSS_ETH pair, buying COSS for ETH
29
29
  bot.trade_limit = 0.01 # trading cycle does not start if ETH limit is less than 0.1 ETH (ETH is chosen because it is a base pair in this case. If it would be BTC_USDT - it would be USDT)
30
- bot.call do |buy_price, sell_price|
31
- puts "Bought for #{buy_price}; Sold for #{sell_price}" # You can pass block to have access to price at which bot places BUY and SELL orders.
30
+ bot.call do |buy_order_id, sell_order_id|
31
+ puts "BUY order id: #{buy_order_id}; SELL order id: #{sell_order_id}" # You can pass block to save order ids.
32
32
  end
33
33
 
34
34
  ```
data/coss_bot.gemspec CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
24
  spec.require_paths = ['lib']
25
25
 
26
- spec.add_dependency 'coss_api_ruby_wrapper', '~> 0.1'
26
+ spec.add_dependency 'coss_api_ruby_wrapper', '0.1.1'
27
27
 
28
28
  spec.add_development_dependency 'bundler', '~> 1.17'
29
29
  spec.add_development_dependency 'rake', '~> 10.0'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module CossBot
2
4
  class Basic
3
5
  attr_reader :exchange
@@ -10,8 +12,9 @@ module CossBot
10
12
  def call(&block)
11
13
  validate_params!
12
14
  loop do
13
- tick(&block)
14
- sleep(interval)
15
+ time = Benchmark.measure { tick(&block) }.real
16
+ wait_time = time > interval ? 0 : interval - time
17
+ sleep(wait_time)
15
18
  end
16
19
  end
17
20
 
@@ -26,6 +29,5 @@ module CossBot
26
29
 
27
30
  raise ArgumentError, 'Some params are invalid'
28
31
  end
29
-
30
32
  end
31
33
  end
@@ -2,7 +2,6 @@
2
2
 
3
3
  module CossBot
4
4
  class BuyLowSellHigh < Basic
5
-
6
5
  private
7
6
 
8
7
  def tick
@@ -17,10 +16,10 @@ module CossBot
17
16
 
18
17
  price_with_profit = (current_price + (current_price / 100 * profit)).round(6)
19
18
  puts "Placing BUY order for #{current_price}. Lot size: #{lot_size}"
20
- exchange.place_limit_order(pair, current_price, 'BUY', lot_size)
19
+ buy_response = exchange.place_limit_order(pair, current_price, 'BUY', lot_size)
21
20
  puts "Placing SELL order for #{price_with_profit}. Lot size: #{lot_size}"
22
- exchange.place_limit_order(pair, price_with_profit, 'SELL', lot_size)
23
- yield(current_price, price_with_profit)
21
+ sell_response = exchange.place_limit_order(pair, price_with_profit, 'SELL', lot_size)
22
+ yield(buy_response['order_id'], sell_response['order_id'])
24
23
  puts '=== End of trading cycle ==='
25
24
  end
26
25
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CossBot
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
  end
data/lib/coss_bot.rb CHANGED
@@ -3,6 +3,7 @@
3
3
  require 'coss_bot/version'
4
4
  require 'coss_bot/basic'
5
5
  require 'coss_bot/buy_low_sell_high'
6
+ require 'benchmark'
6
7
 
7
8
  module CossBot
8
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coss_bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Viktor Vsk
@@ -14,16 +14,16 @@ dependencies:
14
14
  name: coss_api_ruby_wrapper
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: '0.1'
19
+ version: 0.1.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: '0.1'
26
+ version: 0.1.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement