Skip to content

Commit

Permalink
converts all hashes to 1.8.7 syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
hstove committed Dec 23, 2013
1 parent 1c8269c commit 016ad7e
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 37 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ gem 'ruby_gntp'
# gem 'awesome_print'
gem 'guard-rspec'
gem 'simplecov'
gem 'coveralls', require: false
gem 'coveralls', :require => false
gem "webmock"
gem 'vcr'
gem 'codeclimate-test-reporter'
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ RSpec::Core::RakeTask.new do |t|
# Put spec opts in a file named .rspec in root
end

task default: :spec
task :default => :spec
12 changes: 6 additions & 6 deletions lib/rbtc_arbitrage/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ module RbtcArbitrage
class CLI < Thor

desc "arbitrage", "Get information about the current arbitrage levels."
option :live, type: :boolean, default: false, desc: "Execute live trades."
option :cutoff, type: :numeric, default: 2, desc: "The minimum profit level required to execute a trade."
option :volume, type: :numeric, default: 0.01, desc: "The amount of bitcoins to trade per transaction."
option :verbose, type: :boolean, default: true, desc: "Whether you wish to log information."
option :buyer, type: :string, default: "bitstamp"
option :seller, type: :string, default: "mtgox"
option :live, :type => :boolean, :default => false, :desc => "Execute live trades."
option :cutoff, :type => :numeric, :default => 2, :desc => "The minimum profit level required to execute a trade."
option :volume, :type => :numeric, :default => 0.01, :desc => "The amount of bitcoins to trade per transaction."
option :verbose, :type => :boolean, :default => true, :desc => "Whether you wish to log information."
option :buyer, :type => :string, :default => "bitstamp"
option :seller, :type => :string, :default => "mtgox"
def trade
RbtcArbitrage::Trader.new(options).trade
end
Expand Down
12 changes: 6 additions & 6 deletions lib/rbtc_arbitrage/clients/bitstamp_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@ def exchange
def price action
return @price if @price
action = {
buy: :ask,
sell: :bid,
:buy => :ask,
:sell => :bid,
}[action]
@price = Bitstamp.ticker.send(action).to_f
end

def trade action
price(action) unless @price #memoize
multiple = {
buy: 1,
sell: -1,
:buy => 1,
:sell => -1,
}[action]
bitstamp_options = {
price: (@price + 0.001 * multiple),
amount: @options[:volume],
:price => (@price + 0.001 * multiple),
:amount => @options[:volume],
}
Bitstamp.orders.send(action, bitstamp_options)
end
Expand Down
10 changes: 5 additions & 5 deletions lib/rbtc_arbitrage/clients/btce_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ def trade action
@options[:logger].warn warning if @options[:verbose]
return false unless gets.chomp == "accept"
opts = {
type: action,
rate: price(action),
amount: @options[:volume],
pair: "btc_usd"
:type => action,
:rate => price(action),
:amount => @options[:volume],
:pair => "btc_usd"
}
interface.trade opts
end
Expand All @@ -54,7 +54,7 @@ def transfer client
end

def interface
opts = {key: ENV['BTCE_KEY'], secret: ENV['BTCE_SECRET']}
opts = {:key => ENV['BTCE_KEY'], :secret => ENV['BTCE_SECRET']}
@interface ||= Btce::TradeAPI.new(opts)
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/rbtc_arbitrage/clients/campbx_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def trade action
def price action
return @price if @price
action = {
buy: "Best Ask",
sell: "Best Bid",
:buy => "Best Ask",
:sell => "Best Bid",
}[action]
@price = interface.xticker[action].to_f
end
Expand Down
4 changes: 2 additions & 2 deletions lib/rbtc_arbitrage/clients/mtgox_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ def exchange
def price action
return @price if @price
action = {
buy: :sell,
sell: :buy,
:buy => :sell,
:sell => :buy,
}[action]
@price = MtGox.ticker.send(action)
end
Expand Down
6 changes: 3 additions & 3 deletions spec/clients/bitstamp_client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
it "trades on Bitstamp with #{action}" do
client.instance_variable_set("@price", 1)
trade_price = {
buy: 1.001,
sell: 0.999,
:buy => 1.001,
:sell => 0.999,
}[action]
bitstamp_options = {amount: 0.01, price: trade_price}
bitstamp_options = {:amount => 0.01, :price => trade_price}
Bitstamp.orders.should_receive(action).with(bitstamp_options)
client.trade(action)
end
Expand Down
4 changes: 2 additions & 2 deletions spec/clients/btce_client_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'spec_helper'

describe RbtcArbitrage::Clients::BtceClient do
let(:client) { RbtcArbitrage::Clients::BtceClient.new(verbose: false) }
let(:client) { RbtcArbitrage::Clients::BtceClient.new({:verbose => false}) }
let(:btce) { client.interface }

it { client.exchange.should == :btce }
Expand Down Expand Up @@ -71,7 +71,7 @@
client.stub(:gets) { 'accept' }

client.instance_variable_set(:@ticker, {"sell" => 10, "buy" => 11})
opts = {pair: "btc_usd", type: :sell, rate: 10, amount: 0.01}
opts = {:pair => "btc_usd", :type => :sell, :rate => 10, :amount => 0.01}
btce.should_receive(:trade).with(opts)
client.trade(:sell)

Expand Down
18 changes: 9 additions & 9 deletions spec/trader_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'spec_helper'
describe RbtcArbitrage::Trader do
let(:trader) { RbtcArbitrage::Trader.new(verbose: false) }
let(:trader) { RbtcArbitrage::Trader.new({:verbose => false}) }
describe "#validate_env" do

before :each do
Expand Down Expand Up @@ -63,13 +63,13 @@
describe "#initialize" do
let(:options) {
{
volume: 1,
cutoff: 1,
logger: nil,
verbose: false,
live: true,
seller: :bitstamp,
buyer: :mtgox,
:volume => 1,
:cutoff => 1,
:logger => nil,
:verbose => false,
:live => true,
:seller => :bitstamp,
:buyer => :mtgox,
}
}

Expand All @@ -96,7 +96,7 @@
end

context "when live" do
let(:trader) { RbtcArbitrage::Trader.new(verbose: false, cutoff: 100, live: true) }
let(:trader) { RbtcArbitrage::Trader.new({:verbose => false, :cutoff => 100, :live => true}) }

it "shouldn't raise security error", :vcr do
expect { trader.execute_trade }.not_to raise_error
Expand Down

0 comments on commit 016ad7e

Please sign in to comment.