bitex_bot 0.2.2 → 0.2.3
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.
- data/bitex_bot.gemspec +2 -2
- data/lib/bitex_bot/models/bitstamp_api_wrapper.rb +12 -2
- data/lib/bitex_bot/models/opening_flow.rb +2 -2
- data/lib/bitex_bot/version.rb +1 -1
- data/spec/models/buy_opening_flow_spec.rb +1 -1
- data/spec/models/robot_spec.rb +3 -3
- data/spec/models/sell_opening_flow_spec.rb +1 -1
- data/spec/support/bitex_stubs.rb +2 -11
- metadata +6 -6
data/bitex_bot.gemspec
CHANGED
@@ -26,8 +26,8 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.add_dependency "activesupport"
|
27
27
|
spec.add_dependency "sqlite3"
|
28
28
|
spec.add_dependency "bitstamp"
|
29
|
-
spec.add_dependency "bitex", "0.1.
|
30
|
-
spec.add_dependency "itbit", "0.0.
|
29
|
+
spec.add_dependency "bitex", "0.1.9"
|
30
|
+
spec.add_dependency "itbit", "0.0.3"
|
31
31
|
spec.add_dependency "mail"
|
32
32
|
spec.add_dependency "hashie"
|
33
33
|
|
@@ -23,8 +23,18 @@ class BitstampApiWrapper
|
|
23
23
|
# 'asks' =>
|
24
24
|
# [['10', '2'], ['15', '3'], ['20', '1.5'], ['25', '3'], ['30', '3']]
|
25
25
|
# }
|
26
|
-
def self.order_book
|
27
|
-
|
26
|
+
def self.order_book(retries = 20)
|
27
|
+
begin
|
28
|
+
Bitstamp.order_book
|
29
|
+
rescue StandardError => e
|
30
|
+
if retries == 0
|
31
|
+
raise
|
32
|
+
else
|
33
|
+
Robot.logger.info("Bitstamp order_book failed, retrying #{retries} more times")
|
34
|
+
sleep 1
|
35
|
+
self.order_book(retries - 1)
|
36
|
+
end
|
37
|
+
end
|
28
38
|
end
|
29
39
|
|
30
40
|
# {"btc_balance"=> "10.0", "btc_reserved"=> "0", "btc_available"=> "10.0",
|
@@ -83,9 +83,9 @@ module BitexBot
|
|
83
83
|
def self.sync_open_positions
|
84
84
|
threshold = open_position_class
|
85
85
|
.order('created_at DESC').first.try(:created_at)
|
86
|
-
Bitex::
|
86
|
+
Bitex::Trade.all.collect do |transaction|
|
87
87
|
next unless transaction.is_a?(transaction_class)
|
88
|
-
next if threshold && transaction.created_at < (threshold -
|
88
|
+
next if threshold && transaction.created_at < (threshold - 30.minutes)
|
89
89
|
next if open_position_class.find_by_transaction_id(transaction.id)
|
90
90
|
next if transaction.specie != :btc
|
91
91
|
next unless flow = find_by_order_id(transaction_order_id(transaction))
|
data/lib/bitex_bot/version.rb
CHANGED
@@ -120,7 +120,7 @@ describe BitexBot::BuyOpeningFlow do
|
|
120
120
|
|
121
121
|
it 'does not register litecoin buys' do
|
122
122
|
flow.order_id.should == 12345
|
123
|
-
Bitex::
|
123
|
+
Bitex::Trade.stub(all: [build(:bitex_buy, id: 23456, specie: :ltc)])
|
124
124
|
expect do
|
125
125
|
BitexBot::BuyOpeningFlow.sync_open_positions.should be_empty
|
126
126
|
end.not_to change{ BitexBot::OpenBuy.count }
|
data/spec/models/robot_spec.rb
CHANGED
@@ -59,7 +59,7 @@ describe BitexBot::Robot do
|
|
59
59
|
end
|
60
60
|
|
61
61
|
it 'creates alternating opening flows' do
|
62
|
-
Bitex::
|
62
|
+
Bitex::Trade.stub(all: [])
|
63
63
|
bot.trade!
|
64
64
|
BitexBot::BuyOpeningFlow.active.count.should == 1
|
65
65
|
Timecop.travel 2.seconds.from_now
|
@@ -132,7 +132,7 @@ describe BitexBot::Robot do
|
|
132
132
|
end
|
133
133
|
|
134
134
|
it 'warns every 30 minutes when usd warn is reached' do
|
135
|
-
Bitex::
|
135
|
+
Bitex::Trade.stub(all: [])
|
136
136
|
other_bot = BitexBot::Robot.new
|
137
137
|
other_bot.store.usd_warning = 11000
|
138
138
|
other_bot.store.save!
|
@@ -150,7 +150,7 @@ describe BitexBot::Robot do
|
|
150
150
|
end
|
151
151
|
|
152
152
|
it 'warns every 30 minutes when btc warn is reached' do
|
153
|
-
Bitex::
|
153
|
+
Bitex::Trade.stub(all: [])
|
154
154
|
other_bot = BitexBot::Robot.new
|
155
155
|
other_bot.store.btc_warning = 30
|
156
156
|
other_bot.store.save!
|
@@ -122,7 +122,7 @@ describe BitexBot::SellOpeningFlow do
|
|
122
122
|
|
123
123
|
it 'does not register litecoin buys' do
|
124
124
|
flow.order_id.should == 12345
|
125
|
-
Bitex::
|
125
|
+
Bitex::Trade.stub(all: [build(:bitex_sell, id: 23456, specie: :ltc)])
|
126
126
|
expect do
|
127
127
|
BitexBot::SellOpeningFlow.sync_open_positions.should be_empty
|
128
128
|
end.not_to change{ BitexBot::OpenSell.count }
|
data/spec/support/bitex_stubs.rb
CHANGED
@@ -57,17 +57,8 @@ module BitexStubs
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def stub_bitex_transactions(*extra_transactions)
|
60
|
-
Bitex::
|
61
|
-
build(:bitex_buy),
|
62
|
-
build(:bitex_sell),
|
63
|
-
Bitex::SpecieWithdrawal
|
64
|
-
.from_json([6,Time.now.to_i,946685400,1,100.00000000,1,0]),
|
65
|
-
Bitex::UsdWithdrawal
|
66
|
-
.from_json([8,Time.now.to_i,946685400,100.00000000,1,0]),
|
67
|
-
Bitex::UsdDeposit
|
68
|
-
.from_json([7,Time.now.to_i,946685400,1000.00000000,1,1,0]),
|
69
|
-
Bitex::SpecieDeposit
|
70
|
-
.from_json([5,Time.now.to_i,946685400,1,100.00000000]),
|
60
|
+
Bitex::Trade.stub(all: extra_transactions + [
|
61
|
+
build(:bitex_buy), build(:bitex_sell)
|
71
62
|
])
|
72
63
|
end
|
73
64
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bitex_bot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-11-
|
13
|
+
date: 2014-11-29 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: settingslogic
|
@@ -99,7 +99,7 @@ dependencies:
|
|
99
99
|
requirements:
|
100
100
|
- - '='
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version: 0.1.
|
102
|
+
version: 0.1.9
|
103
103
|
type: :runtime
|
104
104
|
prerelease: false
|
105
105
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -107,7 +107,7 @@ dependencies:
|
|
107
107
|
requirements:
|
108
108
|
- - '='
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0.1.
|
110
|
+
version: 0.1.9
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: itbit
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -115,7 +115,7 @@ dependencies:
|
|
115
115
|
requirements:
|
116
116
|
- - '='
|
117
117
|
- !ruby/object:Gem::Version
|
118
|
-
version: 0.0.
|
118
|
+
version: 0.0.3
|
119
119
|
type: :runtime
|
120
120
|
prerelease: false
|
121
121
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -123,7 +123,7 @@ dependencies:
|
|
123
123
|
requirements:
|
124
124
|
- - '='
|
125
125
|
- !ruby/object:Gem::Version
|
126
|
-
version: 0.0.
|
126
|
+
version: 0.0.3
|
127
127
|
- !ruby/object:Gem::Dependency
|
128
128
|
name: mail
|
129
129
|
requirement: !ruby/object:Gem::Requirement
|