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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/coss_bot/buy_low_sell_high.rb +1 -1
- data/lib/coss_bot/sell_high_buy_low.rb +45 -0
- data/lib/coss_bot/version.rb +1 -1
- data/lib/coss_bot.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35fbae371d58877c564cd39682e4dcc2b26324a6fc43db9b4c6955476df3d90b
|
4
|
+
data.tar.gz: 44c3307bdd315c1f46dd68ce71e5ec1f36ee862f262ac6420136c7033ae6c3a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8e8552fa60f358fd62eebf6eab1a40721ef56675e2c3887d6d8d8957cf0fe105f09755cfacd1e6beec9e531894b489589510b8d21826159d164636f4cadac1f
|
7
|
+
data.tar.gz: 437f4eab1a8cc311c0b7e82195e284ba784a56499cb968d144ad3d3d9d5beafe17f89ba68336570d084be996774c77c4bb1375340b1d4243a2e89db960ec7378
|
data/Gemfile.lock
CHANGED
@@ -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
|
data/lib/coss_bot/version.rb
CHANGED
data/lib/coss_bot.rb
CHANGED
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.
|
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:
|
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:
|