coss_bot 0.1.7 → 0.1.8

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: c96eabe1a9e64f316795eacdb3f7ef85e6c6cf8205f84d526f1a189c5beab5fd
4
- data.tar.gz: 6583536c1ce262723c7c6fc599e158103474cfd1b5d18e908b8a4e6272e7c75d
3
+ metadata.gz: 35fbae371d58877c564cd39682e4dcc2b26324a6fc43db9b4c6955476df3d90b
4
+ data.tar.gz: 44c3307bdd315c1f46dd68ce71e5ec1f36ee862f262ac6420136c7033ae6c3a6
5
5
  SHA512:
6
- metadata.gz: 5df07f0bf8a54daf611010fa3007ba146658a01afbe950ee9fa82bd995b4cebed77549d0d1565458809e92524722cd70f092413cf2494ad55c349200f57195ab
7
- data.tar.gz: 0e430f64b6c9aec7fdcf6e47b7432cf8c5fe3e0db6bf9c0ea4620d58a5bd97f934194b2e60f08470046d4609ae6c8915caad076b9883cd1a4162c1cba0f3e47e
6
+ metadata.gz: e8e8552fa60f358fd62eebf6eab1a40721ef56675e2c3887d6d8d8957cf0fe105f09755cfacd1e6beec9e531894b489589510b8d21826159d164636f4cadac1f
7
+ data.tar.gz: 437f4eab1a8cc311c0b7e82195e284ba784a56499cb968d144ad3d3d9d5beafe17f89ba68336570d084be996774c77c4bb1375340b1d4243a2e89db960ec7378
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- coss_bot (0.1.7)
4
+ coss_bot (0.1.8)
5
5
  coss_api_ruby_wrapper (= 0.1.2)
6
6
 
7
7
  GEM
@@ -30,7 +30,7 @@ module CossBot
30
30
 
31
31
  error = {}
32
32
 
33
- if buy_response[:status].present? || sell_response[:status].present?
33
+ if !buy_response[:status].nil? || !sell_response[:status].nil?
34
34
  error[:message] = {
35
35
  buy: buy_response,
36
36
  sell: sell_response
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CossBot
4
+ class SellHighBuyLow < Basic
5
+ private
6
+
7
+ def tick
8
+ logger.info('=== Start of trading cycle ===')
9
+ balances = exchange.account_balances
10
+ if balances.is_a?(Hash) && balances[:status] && balances[:status].to_s != '200'
11
+ yield(nil, nil, balances)
12
+ return
13
+ end
14
+ currency_to_sell = pair.split('_').last
15
+ current_balance = balances.detect { |c| c['currency_code'] == currency_to_sell }['available'].to_f
16
+ pair_depth = exchange.pair_depth(pair)
17
+ current_price = pair_depth['bids'].first.first.to_f
18
+
19
+ if current_balance <= trade_limit.to_f
20
+ yield(nil, nil, { status: 0, message: 'Current balance <= trade limit' })
21
+ elsif current_balance <= current_price * lot_size
22
+ yield(nil, nil, { status: 0, message: 'Current balance <= current_price * lot_size' })
23
+ else
24
+ price_with_profit = (current_price - (current_price / 100 * profit.to_f)).round(6)
25
+ logger.info("Placing SELL order for #{current_price}. Lot size: #{lot_size}")
26
+ sell_response = exchange.place_limit_order(pair, current_price, 'SELL', lot_size)
27
+ logger.info("Placing BUY order for #{price_with_profit}. Lot size: #{lot_size}")
28
+ buy_response = exchange.place_limit_order(pair, price_with_profit, 'BUY', lot_size)
29
+ logger.info('=== End of trading cycle ===')
30
+
31
+ error = {}
32
+
33
+ if !buy_response[:status].nil? || !sell_response[:status].nil?
34
+ error[:message] = {
35
+ buy: buy_response,
36
+ sell: sell_response
37
+ }
38
+ error[:status] = 999
39
+ end
40
+
41
+ yield(buy_response, sell_response, error)
42
+ end
43
+ end
44
+ end
45
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CossBot
4
- VERSION = '0.1.7'
4
+ VERSION = '0.1.8'
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 'coss_bot/sell_high_buy_low'
6
7
  require 'benchmark'
7
8
  require 'logger'
8
9
  require 'coss_api_ruby_wrapper'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coss_bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Coss Community
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-12-24 00:00:00.000000000 Z
11
+ date: 2019-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: coss_api_ruby_wrapper
@@ -88,6 +88,7 @@ files:
88
88
  - lib/coss_bot.rb
89
89
  - lib/coss_bot/basic.rb
90
90
  - lib/coss_bot/buy_low_sell_high.rb
91
+ - lib/coss_bot/sell_high_buy_low.rb
91
92
  - lib/coss_bot/version.rb
92
93
  homepage: https://github.com/coss-community/coss_bot
93
94
  licenses: