Coder Social home page Coder Social logo

kraken_client's People

Contributors

cyril avatar elliottbernstein avatar ramontayag avatar shideneyu avatar tsikov avatar vumanhcuongit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

kraken_client's Issues

Hashie is back

Hello, thank you for your good work.

When I try using version 1.2 I get:

gems/kraken_client-1.2/lib/kraken_client/application.rb:7:in `require': cannot load such file -- hashie (LoadError)
	from /usr/local/lib/ruby/gems/2.4.0/gems/kraken_client-1.2/lib/kraken_client/application.rb:7:in `<top (required)>'
	from /usr/local/lib/ruby/gems/2.4.0/gems/kraken_client-1.2/lib/kraken_client.rb:4:in `require_relative'
	from /usr/local/lib/ruby/gems/2.4.0/gems/kraken_client-1.2/lib/kraken_client.rb:4:in `block in <top (required)>'
	from /usr/local/lib/ruby/gems/2.4.0/gems/kraken_client-1.2/lib/kraken_client.rb:3:in `each'
	from /usr/local/lib/ruby/gems/2.4.0/gems/kraken_client-1.2/lib/kraken_client.rb:3:in `<top (required)>'
....

Doesn't load for Rails 4.2

These are the first few lines of my gemfile:

source 'https://rubygems.org'

gem 'kraken_client'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.6'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'

Run bundle install, says it installs, but then class can't be found:

borourke$ bundle exec rails c
Running via Spring preloader in process 79949
Loading development environment (Rails 4.2.6)
irb(main):001:0> KrakenClient.load({
irb(main):002:2*       api_key: XXXXXXXX,
irb(main):003:2*       api_secret: XXXXXX
irb(main):004:2>     })
NameError: uninitialized constant KrakenClient
    from (irb):1
    from /Users/borourke/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/commands/console.rb:110:in `start'
    from /Users/borourke/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/commands/console.rb:9:in `start'
    from /Users/borourke/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:68:in `console'
    from /Users/borourke/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
    from /Users/borourke/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/commands.rb:17:in `<top (required)>'
    from /Users/borourke/Projects/ktifu/bin/rails:9:in `<top (required)>'
    from /Users/borourke/.rbenv/versions/2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /Users/borourke/.rbenv/versions/2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from -e:1:in `<main>'
irb(main):005:0>

I can use the class in a script, but not in a gemfile/rails context. Would be really nice if it supported that.

Handling errors during API call

There seem to be some instances where the gem blows up because Hashie::Mash.new cannot handle the response returned. See this fork.

Are you aware of this? I don't mind making the change, but is there a test API server for Kraken?

Cancel order results in NoMethodError: undefined method `keys' for <order id>:String

The documentation example shows passing an order id to #cancel_order:
client.private.cancel("SOME-ORDER-ID")

This raises the error in the title. I figured I needed to pass txid: "SOME-ORDER-ID", which worked, but did return the following warning message, due to the success response from the API of #<Hashie::Mash count=1>:

"You are setting a key that conflicts with a built-in method Hashie::Mash#count defined in Enumerable. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method."

I'm not sure how much of an issue this is as the cancel worked when passing txid: "SOME-ORDER-ID"

find: No such file or directory

My codeline "require 'kraken_client'" fails:

$ ./test.rb 
/Users/torti/.rbenv/versions/2.2.4/lib/ruby/2.2.0/find.rb:42:in `block in find': No such file or directory (Errno::ENOENT)
    from /Users/torti/.rbenv/versions/2.2.4/lib/ruby/2.2.0/find.rb:42:in `collect!'
    from /Users/torti/.rbenv/versions/2.2.4/lib/ruby/2.2.0/find.rb:42:in `find'
    from /Users/torti/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/kraken_client-0.2.1/lib/kraken_client.rb:4:in `each'
    from /Users/torti/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/kraken_client-0.2.1/lib/kraken_client.rb:4:in `select'
    from /Users/torti/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/kraken_client-0.2.1/lib/kraken_client.rb:4:in `<top (required)>'
    from /Users/torti/.rbenv/versions/2.2.4/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `require'
    from /Users/torti/.rbenv/versions/2.2.4/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `rescue in require'
    from /Users/torti/.rbenv/versions/2.2.4/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:39:in `require'
    from /Users/torti/src/bc/mytrader/market/kraken.rb:1:in `<top (required)>'
    from /Users/torti/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/require_all-1.3.3/lib/require_all.rb:108:in `require'
    from /Users/torti/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/require_all-1.3.3/lib/require_all.rb:108:in `block in require_all'
    from /Users/torti/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/require_all-1.3.3/lib/require_all.rb:106:in `each'
    from /Users/torti/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/require_all-1.3.3/lib/require_all.rb:106:in `require_all'
    from /Users/torti/src/bc/mytrader/main.rb:9:in `init'
    from ./test.rb:4:in `<main>'

So I guess there's a problem with find in your kraken_client.rb produces this issue:

Find.find('./lib').select { |p| /.*\.rb$/ =~ p }.each do |path|
  require_relative("../" + path)
end

I haven't seen such code in other ruby libraries. They all require their files explicitly, e.g.:

require 'configurable.rb'
require 'configuration.rb'
require 'exceptions.rb'
require 'version.rb'
require 'kraken_client/requests/base.rb'
require 'kraken_client/requests/get.rb'
require 'kraken_client/requests/limiter.rb'
require 'kraken_client/requests/post.rb'
require 'kraken_client/application.rb'

I don't know if that's all... but at least I don't get an error anymore when I "require 'kraken_client'". That way you also can remove your dependency of the find gem.

Status Missing from Kraken Response

Hello,
I'm getting an exception trying to connect to kraken. Looks like your gem is expecting status in the response, but httparty isn't providing that.

irb
2.2.5 :001 > require 'kraken_client'
2.2.5 :002 > client = KrakenClient.load
=> #<KrakenClient::Application:0x007fdceb085870 @config=#<KrakenClient::Configuration:0x007fdceb084dd0 @api_key=nil, @api_secret=nil, @base_uri="https://api.kraken.com", @api_version=0, @Limiter=true, @tier=2, @limiter_interface=#<KrakenClient::Requests::Limiter:0x007fdceb084da8 @config=#<KrakenClient::Configuration:0x007fdceb084dd0 ...>, @previous_timestamps=2017-12-23 10:31:23 -0700, @counter=10, @current_count=10>>>

2.2.5 :003 > time = client.public.server_time
response - {"error":[],"result":{"unixtime":1514050288,"rfc1123":"Sat, 23 Dec 17 17:31:28 +0000"}}"
Exception - NoMethodError: undefined method status' for #<HTTParty::Response:0x007fdcec0aa2f0> from /Users/ian/.rvm/gems/ruby-2.2.5/gems/httparty-0.15.6/lib/httparty/response.rb:93:in method_missing'
from /Users/ian/.rvm/gems/ruby-2.2.5/gems/kraken_client-1.3.0/lib/kraken_client/endpoints/public.rb:9:in `perform'_

Kraken fetch rates bitcoin to usd

how i can call this and fetch it
Hi i am using other server for show rates and show my app something like this http://prntscr.com/frwu2l
now i need to fetch from kraken and save it my database

    data = ::CSAPI.getRate
    data = fetch_rates
    binding.pry

    data['items'].keys.each do |item|
      from = Currency.find_by_code(item.split('/')[0].to_sym)
      to = Currency.find_by_code(item.split('/')[1].to_sym)
      rate = data['items'][item]

      if from && to
        reverse_rate = (BigDecimal('1.00000000') / BigDecimal("#{rate}")).truncate(8)

        ExchangeRate.create(from: from, to: to, rate: rate)
        ExchangeRate.create(from: to, to: from, rate: reverse_rate)
      end
        # if Currency.find_by_code(:npc)
        #   ExchangeRate.create from: to, to: Currency.find_by_code(:npc), rate: rate
        #   ExchangeRate.create from: Currency.find_by_code(:npc), to: to, rate: reverse_rate
        # end
    end

    if recurrent
      self.class.set(wait: Rails.env.production? ? 1.minute : 30.minutes).perform_later
    end
  end```

in kraken somthign like this 
```client = KrakenClient.load
spread = client.public.spread('XXBTZUSD')
=> {"XXBTZUSD"=>
  [[1499256446, "2555.20000", "2555.20000"],
   [1499256447, "2553.43900", "2555.20000"],
   [1499256450, "2555.20000", "2555.20000"],
   [1499256451, "2553.43900", "2555.20000"],
   [1499256452, "2553.44000", "2555.20000"],
   [1499256457, "2553.43900", "2555.20000"],
   [1499256464, "2553.44000", "2555.20000"],```

but i dont understand which one here is doller and usd 

trade history

In documentation you wrote
trades = client.private.trade_history
shouldn't it be
trades = client.private.trades_history
?

Public.rb should check for `response.code` and not `response.status`

The public client is checking for response.status so that it can raise an error if the status is not 200. It should be checking for response.code instead.

Error: httparty-0.15.6/lib/httparty/response.rb:93:in method_missing': undefined method status' for #<HTTParty::Response:0x0000000120ca00> (NoMethodError)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.