bitex_bot 0.3.1 → 0.3.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.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/bitex_bot.gemspec +3 -4
- data/lib/bitex_bot/models/bitfinex_api_wrapper.rb +15 -0
- data/lib/bitex_bot/models/bitstamp_api_wrapper.rb +1 -1
- data/lib/bitex_bot/robot.rb +2 -2
- data/lib/bitex_bot/settings.rb +25 -8
- data/lib/bitex_bot/version.rb +1 -1
- data/lib/bitex_bot.rb +32 -2
- data/settings.rb.sample +97 -0
- data/spec/models/bitex_api_spec.rb +13 -0
- data/spec/models/bitfinex_api_wrapper_spec.rb +17 -0
- data/spec/models/bitstamp_api_wrapper_spec.rb +15 -0
- data/spec/models/itbit_api_wrapper_spec.rb +15 -0
- data/spec/models/robot_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -0
- metadata +34 -40
- data/settings.yml.sample +0 -107
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: efc6ef530a550fa1e3c3f2a52f414b1027b4eba6
         | 
| 4 | 
            +
              data.tar.gz: 82201c561520e8adbaf98472fd5a1ebb749f6157
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: d5086a469c090655a423994b5e915777090b94a99f3687bdeb48ee1df5c44c57dd0a5817f0de2a449b69ed92de518d3a95cb1e539ad0488f3f2745c1be978b75
         | 
| 7 | 
            +
              data.tar.gz: 1f497ce86c62a994969c9718f7f5239e943457349b961cf2a41599c698ae989b00e521f43df05f5974849e27efeeaa445160dd29f876c2235ddcfc7a1aa991df
         | 
    
        data/Gemfile
    CHANGED
    
    
    
        data/bitex_bot.gemspec
    CHANGED
    
    | @@ -21,9 +21,7 @@ Gem::Specification.new do |spec| | |
| 21 21 | 
             
              spec.test_files    = spec.files.grep(%r{^(test|spec|features)/})
         | 
| 22 22 | 
             
              spec.require_paths = ["lib"]
         | 
| 23 23 |  | 
| 24 | 
            -
              spec.add_dependency " | 
| 25 | 
            -
              spec.add_dependency "activerecord"
         | 
| 26 | 
            -
              spec.add_dependency "activesupport"
         | 
| 24 | 
            +
              spec.add_dependency "activerecord", "4.2"
         | 
| 27 25 | 
             
              spec.add_dependency "sqlite3"
         | 
| 28 26 | 
             
              spec.add_dependency "bitstamp"
         | 
| 29 27 | 
             
              spec.add_dependency "bitex", "0.3"
         | 
| @@ -32,7 +30,7 @@ Gem::Specification.new do |spec| | |
| 32 30 | 
             
              spec.add_dependency "mail"
         | 
| 33 31 | 
             
              spec.add_dependency "hashie"
         | 
| 34 32 |  | 
| 35 | 
            -
              spec.add_development_dependency "bundler" | 
| 33 | 
            +
              spec.add_development_dependency "bundler"
         | 
| 36 34 | 
             
              spec.add_development_dependency "byebug"
         | 
| 37 35 | 
             
              spec.add_development_dependency "rake"
         | 
| 38 36 | 
             
              spec.add_development_dependency "rspec"
         | 
| @@ -41,4 +39,5 @@ Gem::Specification.new do |spec| | |
| 41 39 | 
             
              spec.add_development_dependency "factory_girl"
         | 
| 42 40 | 
             
              spec.add_development_dependency "timecop"
         | 
| 43 41 | 
             
              spec.add_development_dependency "shoulda-matchers"
         | 
| 42 | 
            +
              spec.add_development_dependency "webmock"
         | 
| 44 43 | 
             
            end
         | 
| @@ -1,6 +1,20 @@ | |
| 1 1 | 
             
            require "bigdecimal"
         | 
| 2 2 | 
             
            require "bigdecimal/util"
         | 
| 3 3 |  | 
| 4 | 
            +
            module Bitfinex
         | 
| 5 | 
            +
              module WithUserAgent
         | 
| 6 | 
            +
                def new_rest_connection
         | 
| 7 | 
            +
                  super.tap do |conn|
         | 
| 8 | 
            +
                    conn.headers['User-Agent'] = BitexBot.user_agent
         | 
| 9 | 
            +
                  end
         | 
| 10 | 
            +
                end
         | 
| 11 | 
            +
              end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
              class Client
         | 
| 14 | 
            +
                prepend WithUserAgent
         | 
| 15 | 
            +
              end
         | 
| 16 | 
            +
            end
         | 
| 17 | 
            +
             | 
| 4 18 | 
             
            class BitfinexApiWrapper
         | 
| 5 19 | 
             
              def self.setup(settings)
         | 
| 6 20 | 
             
                Bitfinex::Client.configure do |conf|
         | 
| @@ -13,6 +27,7 @@ class BitfinexApiWrapper | |
| 13 27 | 
             
                begin
         | 
| 14 28 | 
             
                  block.call
         | 
| 15 29 | 
             
                rescue StandardError, Bitfinex::ClientError => e
         | 
| 30 | 
            +
                  raise e if BitexBot::Robot.test_mode
         | 
| 16 31 | 
             
                  BitexBot::Robot.logger.info("Bitfinex #{action} failed. Retrying in 5 seconds.")
         | 
| 17 32 | 
             
                  sleep 5
         | 
| 18 33 | 
             
                  retry
         | 
    
        data/lib/bitex_bot/robot.rb
    CHANGED
    
    | @@ -225,8 +225,8 @@ module BitexBot | |
| 225 225 | 
             
                      subject 'Notice from your robot trader'
         | 
| 226 226 | 
             
                      body message
         | 
| 227 227 | 
             
                    end
         | 
| 228 | 
            -
                    mail.delivery_method(Settings.mailer. | 
| 229 | 
            -
                      Settings.mailer.options. | 
| 228 | 
            +
                    mail.delivery_method(Settings.mailer.delivery_method.to_sym,
         | 
| 229 | 
            +
                      Settings.mailer.options.to_hash)
         | 
| 230 230 | 
             
                    mail.deliver!
         | 
| 231 231 | 
             
                  end
         | 
| 232 232 | 
             
                end
         | 
    
        data/lib/bitex_bot/settings.rb
    CHANGED
    
    | @@ -1,21 +1,38 @@ | |
| 1 | 
            -
            require ' | 
| 1 | 
            +
            require 'hashie'
         | 
| 2 2 |  | 
| 3 3 | 
             
            module BitexBot
         | 
| 4 | 
            -
              class  | 
| 5 | 
            -
                def  | 
| 6 | 
            -
                   | 
| 4 | 
            +
              class FileSettings < ::Hashie::Clash
         | 
| 5 | 
            +
                def method_missing(name, *args)
         | 
| 6 | 
            +
                  return super unless args.size == 1 && args.none?
         | 
| 7 | 
            +
                  self[name] = args.first
         | 
| 8 | 
            +
                end
         | 
| 9 | 
            +
              end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
              class SettingsClass < ::Hashie::Mash
         | 
| 12 | 
            +
                include ::Hashie::Extensions::Mash::SymbolizeKeys
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                def load_default
         | 
| 15 | 
            +
                  path = ARGV[0] || 'bitex_bot_settings.rb'
         | 
| 7 16 | 
             
                  unless FileTest.exists?(path)
         | 
| 8 | 
            -
                    sample_path = File.expand_path('../../../settings. | 
| 17 | 
            +
                    sample_path = File.expand_path('../../../settings.rb.sample', __FILE__)
         | 
| 9 18 | 
             
                    FileUtils.cp(sample_path, path)
         | 
| 10 19 | 
             
                    puts "No settings found, I've created a new one with sample "\
         | 
| 11 20 | 
             
                      "values at #{path}. Please go ahead and edit it before running this again."
         | 
| 12 21 | 
             
                    exit 1
         | 
| 13 22 | 
             
                  end
         | 
| 14 | 
            -
                   | 
| 23 | 
            +
                  load_settings(path)
         | 
| 15 24 | 
             
                end
         | 
| 16 25 |  | 
| 17 | 
            -
                def  | 
| 18 | 
            -
                   | 
| 26 | 
            +
                def load_test
         | 
| 27 | 
            +
                  load_settings File.expand_path('../../../settings.rb.sample', __FILE__)
         | 
| 28 | 
            +
                end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                def load_settings(path)
         | 
| 31 | 
            +
                  file_settings = FileSettings.new
         | 
| 32 | 
            +
                  file_settings.instance_eval(File.read(path), path, 1)
         | 
| 33 | 
            +
                  merge!(file_settings)
         | 
| 19 34 | 
             
                end
         | 
| 20 35 | 
             
              end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
              Settings = SettingsClass.new
         | 
| 21 38 | 
             
            end
         | 
    
        data/lib/bitex_bot/version.rb
    CHANGED
    
    
    
        data/lib/bitex_bot.rb
    CHANGED
    
    | @@ -1,8 +1,6 @@ | |
| 1 1 | 
             
            require "bitex_bot/version"
         | 
| 2 2 | 
             
            require 'hashie'
         | 
| 3 | 
            -
            require "active_support"
         | 
| 4 3 | 
             
            require "active_record"
         | 
| 5 | 
            -
            require "active_model"
         | 
| 6 4 | 
             
            require "mail"
         | 
| 7 5 | 
             
            require "logger"
         | 
| 8 6 | 
             
            require "bitex"
         | 
| @@ -17,4 +15,36 @@ Dir[File.dirname(__FILE__) + '/bitex_bot/models/*.rb'].each {|file| require file | |
| 17 15 | 
             
            require "bitex_bot/robot"
         | 
| 18 16 |  | 
| 19 17 | 
             
            module BitexBot
         | 
| 18 | 
            +
              def self.user_agent
         | 
| 19 | 
            +
                "Bitexbot/#{VERSION} (https://github.com/bitex-la/bitex-bot)"
         | 
| 20 | 
            +
              end
         | 
| 21 | 
            +
            end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            module Bitex
         | 
| 24 | 
            +
              module WithUserAgent
         | 
| 25 | 
            +
                def grab_curl
         | 
| 26 | 
            +
                  super.tap do |curl|
         | 
| 27 | 
            +
                    curl.headers['User-Agent'] = BitexBot.user_agent
         | 
| 28 | 
            +
                  end
         | 
| 29 | 
            +
                end
         | 
| 30 | 
            +
              end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
              class Api
         | 
| 33 | 
            +
                class << self
         | 
| 34 | 
            +
                  prepend WithUserAgent
         | 
| 35 | 
            +
                end
         | 
| 36 | 
            +
              end
         | 
| 37 | 
            +
            end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
            # Itbit and Bitstamp
         | 
| 40 | 
            +
            module RestClient
         | 
| 41 | 
            +
              module WithUserAgent
         | 
| 42 | 
            +
                def default_headers
         | 
| 43 | 
            +
                  super.merge(:user_agent => BitexBot.user_agent)
         | 
| 44 | 
            +
                end
         | 
| 45 | 
            +
              end
         | 
| 46 | 
            +
             | 
| 47 | 
            +
              class Request
         | 
| 48 | 
            +
                prepend WithUserAgent
         | 
| 49 | 
            +
              end
         | 
| 20 50 | 
             
            end
         | 
    
        data/settings.rb.sample
    ADDED
    
    | @@ -0,0 +1,97 @@ | |
| 1 | 
            +
            # File to write log to. The log is rotated every 10240000 bytes, 10 oldest
         | 
| 2 | 
            +
            # logs are kept around.
         | 
| 3 | 
            +
            # If you want to log to stdout you can set 'file' to nil or remove the key.
         | 
| 4 | 
            +
            # How much information to show in the log, valid values are debug, info, error
         | 
| 5 | 
            +
            log file: 'bitex_bot.log', level: :info
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            # Seconds to keep an order alive before recalculating the price and replacing it.
         | 
| 8 | 
            +
            # Given the way in which the robot tries to find the safest price to place an
         | 
| 9 | 
            +
            # order, if the time to live is too long the price is not going to be
         | 
| 10 | 
            +
            # competitive. About 20 seconds is a good number here.
         | 
| 11 | 
            +
            time_to_live 20
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            # Use sandbox environments instead of live environments
         | 
| 14 | 
            +
            # only available for bitex and itbit
         | 
| 15 | 
            +
            sandbox false
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            # Which market to use for taking (we're always makers on bitex)
         | 
| 18 | 
            +
            # 'itbit', 'bitstamp' or 'bitfinex'
         | 
| 19 | 
            +
            taker 'bitstamp'
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            # Settings for buying on bitex and selling on bitstamp.
         | 
| 22 | 
            +
            # amount_to_spend_per_order:
         | 
| 23 | 
            +
            #   Dollars to spend on each initial bitex bid.
         | 
| 24 | 
            +
            #   Should at least be 10.0 which is the current minimum order size on Bitex.
         | 
| 25 | 
            +
            #   if it's too large you're taking a higher risk if whatever happens and you
         | 
| 26 | 
            +
            #   cannot re sell it afterwards. Also, higher amounts result in your bitex
         | 
| 27 | 
            +
            #   bid price not being competitive.
         | 
| 28 | 
            +
            #   A number between 10.0 and 1000.0 is reccommended.
         | 
| 29 | 
            +
            # profit:
         | 
| 30 | 
            +
            #   Your profit when buying on bitex, 0.5 means 0.5%.
         | 
| 31 | 
            +
            #   After calculating the price at which bitcoins can be sold on bitstamp, the
         | 
| 32 | 
            +
            #   robot deduces your profit from that price, and places a bid on bitex paying
         | 
| 33 | 
            +
            #   a lower price.
         | 
| 34 | 
            +
            buying amount_to_spend_per_order: 10.0, profit: 0.5
         | 
| 35 | 
            +
             | 
| 36 | 
            +
            # Settings for selling on bitex and buying on bitstamp.
         | 
| 37 | 
            +
            # quantity_to_sell_per_order:
         | 
| 38 | 
            +
            #   Quantity to sell on each initial bitex Ask.
         | 
| 39 | 
            +
            #   It should be at least 10 USD worth of BTC at current market prices, a bit
         | 
| 40 | 
            +
            #   more just to be safe. Otherwise Bitex will reject your orders for being too
         | 
| 41 | 
            +
            #   small.
         | 
| 42 | 
            +
            #   If it's too large then you're taking a risk if whatever happens and you 
         | 
| 43 | 
            +
            #   If it's too small then the robot is pointless, and if it's too large you're
         | 
| 44 | 
            +
            #   taking a higher risk if whatever happens ad you cannot re buy afterwards.
         | 
| 45 | 
            +
            #   Also, higher amounts result in your bitex bid price not being competitive.
         | 
| 46 | 
            +
            #   A number between 0.05 and 2.0 is recommended.
         | 
| 47 | 
            +
            # profit:
         | 
| 48 | 
            +
            #   Your profit when selling on bitex, 0.5 means 0.5%.
         | 
| 49 | 
            +
            #   After calculating the price at which bitcoins can be bought on bitstamp,
         | 
| 50 | 
            +
            #   the robot deduces your profit from that price and places an ask on bitex
         | 
| 51 | 
            +
            #   charging a higher price.
         | 
| 52 | 
            +
            selling quantity_to_sell_per_order: 0.1, profit: 0.5
         | 
| 53 | 
            +
             | 
| 54 | 
            +
            # This is your bitex api key, it's passed in to the
         | 
| 55 | 
            +
            # bitex gem: https://github.com/bitex-la/bitex-ruby
         | 
| 56 | 
            +
            bitex 'your_bitex_api_key_which_should_be_kept_safe'
         | 
| 57 | 
            +
             | 
| 58 | 
            +
            # These are passed in to the bitstamp gem:
         | 
| 59 | 
            +
            # see https://github.com/kojnapp/bitstamp for more info.
         | 
| 60 | 
            +
            bitstamp api_key: 'YOUR_API_KEY',
         | 
| 61 | 
            +
              secret: 'YOUR_API_SECRET',
         | 
| 62 | 
            +
              client_id: 'YOUR_BITSTAMP_USERNAME'
         | 
| 63 | 
            +
             | 
| 64 | 
            +
            # These are passed in to the itbit gem:
         | 
| 65 | 
            +
            # see https://github.com/bitex-la/itbit for more info.
         | 
| 66 | 
            +
            itbit client_key: 'the-client-key',
         | 
| 67 | 
            +
              secret: 'the-secret',
         | 
| 68 | 
            +
              user_id: 'the-user-id',
         | 
| 69 | 
            +
              default_wallet_id: 'wallet-000'
         | 
| 70 | 
            +
             | 
| 71 | 
            +
            # These are passed in to the bitfinex gem:
         | 
| 72 | 
            +
            # see https://github.com/bitfinexcom/bitfinex-api-rb for more info.
         | 
| 73 | 
            +
            bitfinex api_key: 'your_api_key',
         | 
| 74 | 
            +
              api_secret: 'your_api_secret'
         | 
| 75 | 
            +
             | 
| 76 | 
            +
            # Settings for the ActiveRecord Database to use.
         | 
| 77 | 
            +
            # sqlite is just fine. Check this link for more options:
         | 
| 78 | 
            +
            # http://apidock.com/rails/ActiveRecord/Base/establish_connection/class
         | 
| 79 | 
            +
            database adapter: :sqlite3, database: 'bitex_bot.db'
         | 
| 80 | 
            +
             | 
| 81 | 
            +
            # The robot sends you emails whenever a problem occurs.
         | 
| 82 | 
            +
            # If you do not want to receive emails just remove this 'mailer'
         | 
| 83 | 
            +
            # key and everything under it.
         | 
| 84 | 
            +
            # It uses https://github.com/mikel/mail under the hood, so method
         | 
| 85 | 
            +
            # is any valid delivery_method for teh mail gem.
         | 
| 86 | 
            +
            # Options is the options hash passed in to delivery_method.
         | 
| 87 | 
            +
            mailer from: 'robot@example.com',
         | 
| 88 | 
            +
              to: 'you@example.com',
         | 
| 89 | 
            +
              delivery_method: :smtp,
         | 
| 90 | 
            +
              options: {
         | 
| 91 | 
            +
                address: "your_smtp_server_address.com",
         | 
| 92 | 
            +
                port: 587,
         | 
| 93 | 
            +
                authentication: "plain",
         | 
| 94 | 
            +
                enable_starttls_auto: true,
         | 
| 95 | 
            +
                user_name: 'your_user_name',
         | 
| 96 | 
            +
                password: 'your_smtp_password'
         | 
| 97 | 
            +
              }
         | 
| @@ -0,0 +1,13 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe 'BitexApi' do
         | 
| 4 | 
            +
              before(:each) do
         | 
| 5 | 
            +
                BitexBot::Robot.setup
         | 
| 6 | 
            +
              end
         | 
| 7 | 
            +
             | 
| 8 | 
            +
              it 'Sends User-Agent header' do
         | 
| 9 | 
            +
                stub_request(:get, "https://bitex.la/api-v1/rest/private/profile?api_key=your_bitex_api_key_which_should_be_kept_safe")
         | 
| 10 | 
            +
                  .with(headers: { 'User-Agent': BitexBot.user_agent })
         | 
| 11 | 
            +
                Bitex::Profile.get rescue nil # we don't care about the response
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
            end
         | 
| @@ -0,0 +1,17 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe BitfinexApiWrapper do
         | 
| 4 | 
            +
              before(:each) do
         | 
| 5 | 
            +
                BitexBot::Robot.stub(taker: 'bitfinex')
         | 
| 6 | 
            +
                BitexBot::Robot.stub(taker: BitfinexApiWrapper)
         | 
| 7 | 
            +
                BitexBot::Robot.setup
         | 
| 8 | 
            +
              end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
              it 'Sends User-Agent header' do
         | 
| 11 | 
            +
                stub_request(:post, "https://api.bitfinex.com/v1/balances")
         | 
| 12 | 
            +
                  .with(headers: { 'User-Agent': BitexBot.user_agent })
         | 
| 13 | 
            +
                stub_request(:post, "https://api.bitfinex.com/v1/account_infos")
         | 
| 14 | 
            +
                  .with(headers: { 'User-Agent': BitexBot.user_agent })
         | 
| 15 | 
            +
                BitfinexApiWrapper.balance rescue nil # we don't care about the response
         | 
| 16 | 
            +
              end
         | 
| 17 | 
            +
            end
         | 
| @@ -0,0 +1,15 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe BitstampApiWrapper do
         | 
| 4 | 
            +
              before(:each) do
         | 
| 5 | 
            +
                BitexBot::Robot.stub(taker: 'bitstamp')
         | 
| 6 | 
            +
                BitexBot::Robot.stub(taker: BitstampApiWrapper)
         | 
| 7 | 
            +
                BitexBot::Robot.setup
         | 
| 8 | 
            +
              end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
              it 'Sends User-Agent header' do
         | 
| 11 | 
            +
                stub_request(:post, "https://www.bitstamp.net/api/balance/")
         | 
| 12 | 
            +
                  .with(headers: { 'User-Agent': BitexBot.user_agent })
         | 
| 13 | 
            +
                BitstampApiWrapper.balance rescue nil # we don't care about the response
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
            end
         | 
| @@ -0,0 +1,15 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe ItbitApiWrapper do
         | 
| 4 | 
            +
              before(:each) do
         | 
| 5 | 
            +
                BitexBot::Robot.stub(taker: 'itbit')
         | 
| 6 | 
            +
                BitexBot::Robot.stub(taker: ItbitApiWrapper)
         | 
| 7 | 
            +
                BitexBot::Robot.setup
         | 
| 8 | 
            +
              end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
              it 'Sends User-Agent header' do
         | 
| 11 | 
            +
                stub_request(:get, "https://api.itbit.com/v1/wallets?userId=the-user-id")
         | 
| 12 | 
            +
                  .with(headers: { 'User-Agent': BitexBot.user_agent })
         | 
| 13 | 
            +
                ItbitApiWrapper.balance rescue nil # we don't care about the response
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
            end
         | 
    
        data/spec/models/robot_spec.rb
    CHANGED
    
    
    
        data/spec/spec_helper.rb
    CHANGED
    
    
    
        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.3. | 
| 4 | 
            +
              version: 0.3.3
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Nubis
         | 
| @@ -9,50 +9,22 @@ authors: | |
| 9 9 | 
             
            autorequire: 
         | 
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date:  | 
| 12 | 
            +
            date: 2017-09-21 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 | 
            -
            - !ruby/object:Gem::Dependency
         | 
| 15 | 
            -
              name: settingslogic
         | 
| 16 | 
            -
              requirement: !ruby/object:Gem::Requirement
         | 
| 17 | 
            -
                requirements:
         | 
| 18 | 
            -
                - - ">="
         | 
| 19 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 20 | 
            -
                    version: '0'
         | 
| 21 | 
            -
              type: :runtime
         | 
| 22 | 
            -
              prerelease: false
         | 
| 23 | 
            -
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 24 | 
            -
                requirements:
         | 
| 25 | 
            -
                - - ">="
         | 
| 26 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 27 | 
            -
                    version: '0'
         | 
| 28 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 29 15 | 
             
              name: activerecord
         | 
| 30 16 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 31 17 | 
             
                requirements:
         | 
| 32 | 
            -
                - -  | 
| 33 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 34 | 
            -
                    version: '0'
         | 
| 35 | 
            -
              type: :runtime
         | 
| 36 | 
            -
              prerelease: false
         | 
| 37 | 
            -
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 38 | 
            -
                requirements:
         | 
| 39 | 
            -
                - - ">="
         | 
| 40 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 41 | 
            -
                    version: '0'
         | 
| 42 | 
            -
            - !ruby/object:Gem::Dependency
         | 
| 43 | 
            -
              name: activesupport
         | 
| 44 | 
            -
              requirement: !ruby/object:Gem::Requirement
         | 
| 45 | 
            -
                requirements:
         | 
| 46 | 
            -
                - - ">="
         | 
| 18 | 
            +
                - - '='
         | 
| 47 19 | 
             
                  - !ruby/object:Gem::Version
         | 
| 48 | 
            -
                    version: ' | 
| 20 | 
            +
                    version: '4.2'
         | 
| 49 21 | 
             
              type: :runtime
         | 
| 50 22 | 
             
              prerelease: false
         | 
| 51 23 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 52 24 | 
             
                requirements:
         | 
| 53 | 
            -
                - -  | 
| 25 | 
            +
                - - '='
         | 
| 54 26 | 
             
                  - !ruby/object:Gem::Version
         | 
| 55 | 
            -
                    version: ' | 
| 27 | 
            +
                    version: '4.2'
         | 
| 56 28 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 57 29 | 
             
              name: sqlite3
         | 
| 58 30 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -155,16 +127,16 @@ dependencies: | |
| 155 127 | 
             
              name: bundler
         | 
| 156 128 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 157 129 | 
             
                requirements:
         | 
| 158 | 
            -
                - - " | 
| 130 | 
            +
                - - ">="
         | 
| 159 131 | 
             
                  - !ruby/object:Gem::Version
         | 
| 160 | 
            -
                    version: ' | 
| 132 | 
            +
                    version: '0'
         | 
| 161 133 | 
             
              type: :development
         | 
| 162 134 | 
             
              prerelease: false
         | 
| 163 135 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 164 136 | 
             
                requirements:
         | 
| 165 | 
            -
                - - " | 
| 137 | 
            +
                - - ">="
         | 
| 166 138 | 
             
                  - !ruby/object:Gem::Version
         | 
| 167 | 
            -
                    version: ' | 
| 139 | 
            +
                    version: '0'
         | 
| 168 140 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 169 141 | 
             
              name: byebug
         | 
| 170 142 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -277,6 +249,20 @@ dependencies: | |
| 277 249 | 
             
                - - ">="
         | 
| 278 250 | 
             
                  - !ruby/object:Gem::Version
         | 
| 279 251 | 
             
                    version: '0'
         | 
| 252 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 253 | 
            +
              name: webmock
         | 
| 254 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 255 | 
            +
                requirements:
         | 
| 256 | 
            +
                - - ">="
         | 
| 257 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 258 | 
            +
                    version: '0'
         | 
| 259 | 
            +
              type: :development
         | 
| 260 | 
            +
              prerelease: false
         | 
| 261 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 262 | 
            +
                requirements:
         | 
| 263 | 
            +
                - - ">="
         | 
| 264 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 265 | 
            +
                    version: '0'
         | 
| 280 266 | 
             
            description: |-
         | 
| 281 267 | 
             
              Both a trading robot and a library to build trading
         | 
| 282 268 | 
             
                                      robots. The bitex-bot lets you buy cheap on bitex and
         | 
| @@ -317,15 +303,19 @@ files: | |
| 317 303 | 
             
            - lib/bitex_bot/robot.rb
         | 
| 318 304 | 
             
            - lib/bitex_bot/settings.rb
         | 
| 319 305 | 
             
            - lib/bitex_bot/version.rb
         | 
| 320 | 
            -
            - settings. | 
| 306 | 
            +
            - settings.rb.sample
         | 
| 321 307 | 
             
            - spec/factories/bitex_buy.rb
         | 
| 322 308 | 
             
            - spec/factories/bitex_sell.rb
         | 
| 323 309 | 
             
            - spec/factories/buy_opening_flow.rb
         | 
| 324 310 | 
             
            - spec/factories/open_buy.rb
         | 
| 325 311 | 
             
            - spec/factories/open_sell.rb
         | 
| 326 312 | 
             
            - spec/factories/sell_opening_flow.rb
         | 
| 313 | 
            +
            - spec/models/bitex_api_spec.rb
         | 
| 314 | 
            +
            - spec/models/bitfinex_api_wrapper_spec.rb
         | 
| 315 | 
            +
            - spec/models/bitstamp_api_wrapper_spec.rb
         | 
| 327 316 | 
             
            - spec/models/buy_closing_flow_spec.rb
         | 
| 328 317 | 
             
            - spec/models/buy_opening_flow_spec.rb
         | 
| 318 | 
            +
            - spec/models/itbit_api_wrapper_spec.rb
         | 
| 329 319 | 
             
            - spec/models/order_book_simulator_spec.rb
         | 
| 330 320 | 
             
            - spec/models/robot_spec.rb
         | 
| 331 321 | 
             
            - spec/models/sell_closing_flow_spec.rb
         | 
| @@ -353,7 +343,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 353 343 | 
             
                  version: '0'
         | 
| 354 344 | 
             
            requirements: []
         | 
| 355 345 | 
             
            rubyforge_project: 
         | 
| 356 | 
            -
            rubygems_version: 2. | 
| 346 | 
            +
            rubygems_version: 2.6.11
         | 
| 357 347 | 
             
            signing_key: 
         | 
| 358 348 | 
             
            specification_version: 4
         | 
| 359 349 | 
             
            summary: A trading robot to do arbitrage between bitex.la and other exchanges!
         | 
| @@ -364,8 +354,12 @@ test_files: | |
| 364 354 | 
             
            - spec/factories/open_buy.rb
         | 
| 365 355 | 
             
            - spec/factories/open_sell.rb
         | 
| 366 356 | 
             
            - spec/factories/sell_opening_flow.rb
         | 
| 357 | 
            +
            - spec/models/bitex_api_spec.rb
         | 
| 358 | 
            +
            - spec/models/bitfinex_api_wrapper_spec.rb
         | 
| 359 | 
            +
            - spec/models/bitstamp_api_wrapper_spec.rb
         | 
| 367 360 | 
             
            - spec/models/buy_closing_flow_spec.rb
         | 
| 368 361 | 
             
            - spec/models/buy_opening_flow_spec.rb
         | 
| 362 | 
            +
            - spec/models/itbit_api_wrapper_spec.rb
         | 
| 369 363 | 
             
            - spec/models/order_book_simulator_spec.rb
         | 
| 370 364 | 
             
            - spec/models/robot_spec.rb
         | 
| 371 365 | 
             
            - spec/models/sell_closing_flow_spec.rb
         | 
    
        data/settings.yml.sample
    DELETED
    
    | @@ -1,107 +0,0 @@ | |
| 1 | 
            -
            log:
         | 
| 2 | 
            -
              # File to write log to. The log is rotated every 10240000 bytes, 10 oldest
         | 
| 3 | 
            -
              # logs are kept around.
         | 
| 4 | 
            -
              # If you want to log to stdout you can comment this line.
         | 
| 5 | 
            -
              file: bitex_bot.log
         | 
| 6 | 
            -
              # How much information to show in the log, valid values are debug, info, error
         | 
| 7 | 
            -
              level: info
         | 
| 8 | 
            -
             | 
| 9 | 
            -
            # Seconds to keep an order alive before recalculating the price and replacing it.
         | 
| 10 | 
            -
            # Given the way in which the robot tries to find the safest price to place an
         | 
| 11 | 
            -
            # order, if the time to live is too long the price is not going to be
         | 
| 12 | 
            -
            # competitive. About 20 seconds is a good number here.
         | 
| 13 | 
            -
            time_to_live: 20
         | 
| 14 | 
            -
             | 
| 15 | 
            -
            # Use sandbox environments instead of live environments
         | 
| 16 | 
            -
            # only available for bitex and itbit
         | 
| 17 | 
            -
            sandbox: false
         | 
| 18 | 
            -
             | 
| 19 | 
            -
            # Which market to use for taking (we're always makers on bitex)
         | 
| 20 | 
            -
            # itbit, bitstamp or bitfinex
         | 
| 21 | 
            -
            taker: bitstamp
         | 
| 22 | 
            -
             | 
| 23 | 
            -
            # Settings for buying on bitex and selling on bitstamp.
         | 
| 24 | 
            -
            buying:
         | 
| 25 | 
            -
              # Dollars to spend on each initial bitex bid.
         | 
| 26 | 
            -
              # Should at least be 10.0 which is the current minimum order size on Bitex.
         | 
| 27 | 
            -
              # if it's too large you're taking a higher risk if whatever happens and you
         | 
| 28 | 
            -
              # cannot re sell it afterwards. Also, higher amounts result in your bitex
         | 
| 29 | 
            -
              # bid price not being competitive.
         | 
| 30 | 
            -
              # A number between 10.0 and 1000.0 is reccommended.
         | 
| 31 | 
            -
              amount_to_spend_per_order: 10.0
         | 
| 32 | 
            -
              
         | 
| 33 | 
            -
              # Your profit when buying on bitex, 0.5 means 0.5%.
         | 
| 34 | 
            -
              # After calculating the price at which bitcoins can be sold on bitstamp, the
         | 
| 35 | 
            -
              # robot deduces your profit from that price, and places a bid on bitex paying
         | 
| 36 | 
            -
              # a lower price.
         | 
| 37 | 
            -
              profit: 0.5
         | 
| 38 | 
            -
             | 
| 39 | 
            -
            # Settings for selling on bitex and buying on bitstamp.
         | 
| 40 | 
            -
            selling:
         | 
| 41 | 
            -
              # Quantity to sell on each initial bitex Ask.
         | 
| 42 | 
            -
              # It should be at least 10 USD worth of BTC at current market prices, a bit
         | 
| 43 | 
            -
              # more just to be safe. Otherwise Bitex will reject your orders for being too
         | 
| 44 | 
            -
              # small.
         | 
| 45 | 
            -
              # If it's too large then you're taking a risk if whatever happens and you 
         | 
| 46 | 
            -
              # If it's too small then the robot is pointless, and if it's too large you're
         | 
| 47 | 
            -
              # taking a higher risk if whatever happens ad you cannot re buy afterwards.
         | 
| 48 | 
            -
              # Also, higher amounts result in your bitex bid price not being competitive.
         | 
| 49 | 
            -
              # A number between 0.05 and 2.0 is recommended.
         | 
| 50 | 
            -
              quantity_to_sell_per_order: 0.1
         | 
| 51 | 
            -
              
         | 
| 52 | 
            -
              # Your profit when selling on bitex, 0.5 means 0.5%.
         | 
| 53 | 
            -
              # After calculating the price at which bitcoins can be bought on bitstamp,
         | 
| 54 | 
            -
              # the robot deduces your profit from that price and places an ask on bitex
         | 
| 55 | 
            -
              # charging a higher price.
         | 
| 56 | 
            -
              profit: 0.5
         | 
| 57 | 
            -
             | 
| 58 | 
            -
            # This is your bitex api key, it's passed in to the
         | 
| 59 | 
            -
            # bitex gem: https://github.com/bitex-la/bitex-ruby
         | 
| 60 | 
            -
            bitex: your_bitex_api_key_which_should_be_kept_safe
         | 
| 61 | 
            -
             | 
| 62 | 
            -
            # These are passed in to the bitstamp gem:
         | 
| 63 | 
            -
            # see https://github.com/kojnapp/bitstamp for more info.
         | 
| 64 | 
            -
            bitstamp:
         | 
| 65 | 
            -
              key: YOUR_API_KEY
         | 
| 66 | 
            -
              secret: YOUR_API_SECRET
         | 
| 67 | 
            -
              client_id: YOUR_BITSTAMP_USERNAME
         | 
| 68 | 
            -
             | 
| 69 | 
            -
            # These are passed in to the itbit gem:
         | 
| 70 | 
            -
            # see https://github.com/bitex-la/itbit for more info.
         | 
| 71 | 
            -
            itbit:
         | 
| 72 | 
            -
              client_key: 'the-client-key'
         | 
| 73 | 
            -
              secret: 'the-secret'
         | 
| 74 | 
            -
              user_id: 'the-user-id'
         | 
| 75 | 
            -
              default_wallet_id: 'wallet-000'
         | 
| 76 | 
            -
             | 
| 77 | 
            -
            # These are passed in to the bitfinex gem:
         | 
| 78 | 
            -
            # see https://github.com/bitfinexcom/bitfinex-api-rb for more info.
         | 
| 79 | 
            -
            bitfinex:
         | 
| 80 | 
            -
              api_key: 'your_api_key'
         | 
| 81 | 
            -
              api_secret: 'your_api_secret'
         | 
| 82 | 
            -
             | 
| 83 | 
            -
             | 
| 84 | 
            -
            # Settings for the ActiveRecord Database to use.
         | 
| 85 | 
            -
            # sqlite is just fine. Check this link for more options:
         | 
| 86 | 
            -
            # http://apidock.com/rails/ActiveRecord/Base/establish_connection/class
         | 
| 87 | 
            -
            database:
         | 
| 88 | 
            -
              adapter: sqlite3
         | 
| 89 | 
            -
              database: bitex_bot.db 
         | 
| 90 | 
            -
             | 
| 91 | 
            -
            # The robot sends you emails whenever a problem occurs.
         | 
| 92 | 
            -
            # If you do not want to receive emails just remove this 'mailer'
         | 
| 93 | 
            -
            # key and everything under it.
         | 
| 94 | 
            -
            # It uses https://github.com/mikel/mail under the hood, so method
         | 
| 95 | 
            -
            # is any valid delivery_method for teh mail gem.
         | 
| 96 | 
            -
            # Options is the options hash passed in to delivery_method.
         | 
| 97 | 
            -
            mailer:
         | 
| 98 | 
            -
              from: 'robot@example.com'
         | 
| 99 | 
            -
              to: 'you@example.com'
         | 
| 100 | 
            -
              method: smtp
         | 
| 101 | 
            -
              options:
         | 
| 102 | 
            -
                address: "your_smtp_server_address.com"
         | 
| 103 | 
            -
                port: 587
         | 
| 104 | 
            -
                authentication: "plain"
         | 
| 105 | 
            -
                enable_starttls_auto: true
         | 
| 106 | 
            -
                user_name: 'your_user_name'
         | 
| 107 | 
            -
                password: 'your_smtp_password'
         |