0xjmp / binance-ruby Goto Github PK
View Code? Open in Web Editor NEWRuby gem for the Binance API.
License: MIT License
Ruby gem for the Binance API.
License: MIT License
With BINANCE_TEST_NET_ENABLE=true
On this test code
require 'rubygems'
require 'bundler/setup'
require 'binance-ruby'
Binance::Api.all_coins_info!
My Gemfile
source 'https://rubygems.org'
gem 'binance-ruby'
I am getting the following errors:
Traceback (most recent call last):
5: from test.rb:10:in `<main>'
4: from /Users/roman/Projects/binance/ruby/vendor/gems/ruby/2.7.0/gems/binance-ruby-1.3.6/lib/binance/api.rb:7:in `all_coins_info!'
3: from /Users/roman/Projects/binance/ruby/vendor/gems/ruby/2.7.0/gems/binance-ruby-1.3.6/lib/binance/api/request.rb:31:in `send!'
2: from /Users/roman/Projects/binance/ruby/vendor/gems/ruby/2.7.0/gems/binance-ruby-1.3.6/lib/binance/api/request.rb:45:in `process!'
1: from /Users/roman/.asdf/installs/ruby/2.7.1/lib/ruby/2.7.0/json/common.rb:156:in `parse'
/Users/roman/.asdf/installs/ruby/2.7.1/lib/ruby/2.7.0/json/common.rb:156:in `parse': 783: unexpected token at '' (JSON::ParserError)
4: from test.rb:10:in `<main>'
3: from /Users/roman/Projects/binance/ruby/vendor/gems/ruby/2.7.0/gems/binance-ruby-1.3.6/lib/binance/api.rb:7:in `all_coins_info!'
2: from /Users/roman/Projects/binance/ruby/vendor/gems/ruby/2.7.0/gems/binance-ruby-1.3.6/lib/binance/api/request.rb:31:in `send!'
1: from /Users/roman/Projects/binance/ruby/vendor/gems/ruby/2.7.0/gems/binance-ruby-1.3.6/lib/binance/api/request.rb:44:in `process!'
/Users/roman/Projects/binance/ruby/vendor/gems/ruby/2.7.0/gems/binance-ruby-1.3.6/lib/binance/api/request.rb:48:in `rescue in process!': @783: unexpected token at '' 783: unexpected token at '' (Binance::Api::Error)
It happens on exactly this method (all_coins_info!
). Other methods I tested was working fine.
Any plan for supporting Data Streams websocket mehtods ?
In the source code I don't find the possibility to use the quoteOrderQty
when I create new order and I want to buy with market
type.
https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md#new-order--trade
It is normal?
I would like to buy a coin with my all current btc as fast as possible, I would like to know if we can do it with only 1 API call. The approach I'm using it we request to get the current price first, then calculate the quantity, then create an order based on that. Btw it will takes 2 API calls.
How can I achieve it by using only 1 API call, (the API to get current price will take about > 1sec).
BCH: Bcash. LOL
Bitcoin Cash is what still keeps me in crypto. We already saw all the BS/core lies showing up for what they were. BTC 1 MB block is the most stupid thing ever. Please do your own diligence and if you remove that stupid statement, I will use and contribute to your project.
Hi there, i'm stuck at the beginning of things, need a bit of a help.
new_order = Binance::Api::Order::create!(symbol: pair, side: 'BUY' , type: 'LIMIT', price: buyPrice, quantity: amount)
results
/usr/local/lib64/ruby/gems/2.3.0/gems/binance-ruby-0.1.9/lib/binance/api/request.rb:42:in `process!': (-1102) Mandatory parameter 'timeInForce' was not sent, was empty/null, or malformed. (Binance::Api::Error)
but
new_order = Binance::Api::Order::create!(symbol: pair, side: 'BUY' , type: 'LIMIT', price: buyPrice, quantity: amount, timeInForce: 'GTC')
results
/usr/local/lib64/ruby/gems/2.3.0/gems/binance-ruby-0.1.9/lib/binance/api/order.rb:35:in `create!': unknown keyword: timeInForce (ArgumentError)
Hitting an API format error when trying to grab balance information off an .info!
call. Will go poke at the code now to see if I can understand what's going on but wanted to raise it up here as well.
2: from /Users/jproudman/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/binance-ruby-0.2/lib/binance/api.rb:39:in `info!'
1: from /Users/jproudman/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/binance-ruby-0.2/lib/binance/api/request.rb:28:in `send!'
/Users/jproudman/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/binance-ruby-0.2/lib/binance/api/request.rb:42:in `process!': (-2014) API-key format invalid. (Binance::Api::Error)
hello Jake,
I'm trying to use binance-ruby. Running : pp Binance::Api::Account.info! I get an issue about reqest signing :
/var/lib/gems/2.3.0/gems/binance-ruby-0.1.4/lib/binance/api/request.rb:47:in `process!': Binance::Api::Error (-1100): Illegal characters found in parameter 'signature'; legal range is '^[A-Fa-f0-9]{64}$'. (Binance::Api::Error)
from /var/lib/gems/2.3.0/gems/binance-ruby-0.1.4/lib/binance/api/request.rb:33:in `send!'
from /var/lib/gems/2.3.0/gems/binance-ruby-0.1.4/lib/binance/api/account.rb:8:in `info!'
from binance-ruby.rb:19:in `<main>'
best regards, Marc.
module Binance
module Api
class Request
include HTTParty
#need for sub-account with email params
**query_string_normalizer proc { |query|
query.map do |key, value|
[value].flatten.map {|v| "#{key}=#{v}"}.join('&')
end.join('&')
}**
RSpec NameError with Rails 7.x.x
joshuawilkosz@joshua binance-ruby % bundle exec rspec spec/binance/websocket_spec.rb
An error occurred while loading ./spec/binance/websocket_spec.rb.
Failure/Error: require "active_support/core_ext/string"
NameError:
uninitialized constant ActiveSupport::XmlMini::IsolatedExecutionState
# /Users/joshuawilkosz/.rvm/gems/ruby-2.7.5/gems/activesupport-7.0.1/lib/active_support/xml_mini.rb:184:in `current_thread_backend'
# /Users/joshuawilkosz/.rvm/gems/ruby-2.7.5/gems/activesupport-7.0.1/lib/active_support/xml_mini.rb:103:in `backend='
# /Users/joshuawilkosz/.rvm/gems/ruby-2.7.5/gems/activesupport-7.0.1/lib/active_support/xml_mini.rb:201:in `<module:ActiveSupport>'
# /Users/joshuawilkosz/.rvm/gems/ruby-2.7.5/gems/activesupport-7.0.1/lib/active_support/xml_mini.rb:11:in `<top (required)>'
# /Users/joshuawilkosz/.rvm/gems/ruby-2.7.5/gems/activesupport-7.0.1/lib/active_support/core_ext/array/conversions.rb:3:in `require'
# /Users/joshuawilkosz/.rvm/gems/ruby-2.7.5/gems/activesupport-7.0.1/lib/active_support/core_ext/array/conversions.rb:3:in `<top (required)>'
# /Users/joshuawilkosz/.rvm/gems/ruby-2.7.5/gems/activesupport-7.0.1/lib/active_support/duration.rb:3:in `require'
# /Users/joshuawilkosz/.rvm/gems/ruby-2.7.5/gems/activesupport-7.0.1/lib/active_support/duration.rb:3:in `<top (required)>'
# /Users/joshuawilkosz/.rvm/gems/ruby-2.7.5/gems/activesupport-7.0.1/lib/active_support/core_ext/time/calculations.rb:3:in `require'
# /Users/joshuawilkosz/.rvm/gems/ruby-2.7.5/gems/activesupport-7.0.1/lib/active_support/core_ext/time/calculations.rb:3:in `<top (required)>'
# /Users/joshuawilkosz/.rvm/gems/ruby-2.7.5/gems/activesupport-7.0.1/lib/active_support/core_ext/string/conversions.rb:4:in `require'
# /Users/joshuawilkosz/.rvm/gems/ruby-2.7.5/gems/activesupport-7.0.1/lib/active_support/core_ext/string/conversions.rb:4:in `<top (required)>'
# /Users/joshuawilkosz/.rvm/gems/ruby-2.7.5/gems/activesupport-7.0.1/lib/active_support/core_ext/string.rb:3:in `require'
# /Users/joshuawilkosz/.rvm/gems/ruby-2.7.5/gems/activesupport-7.0.1/lib/active_support/core_ext/string.rb:3:in `<top (required)>'
# ./lib/binance-ruby.rb:1:in `require'
# ./lib/binance-ruby.rb:1:in `<top (required)>'
# ./spec/spec_helper.rb:19:in `require'
# ./spec/spec_helper.rb:19:in `<top (required)>'
# ./spec/binance/websocket_spec.rb:1:in `require'
# ./spec/binance/websocket_spec.rb:1:in `<top (required)>'
No examples found.
Finished in 0.00002 seconds (files took 0.17595 seconds to load)
0 examples, 0 failures, 1 error occurred outside of examples
I keep getting:
lib/binance/api/request.rb:50:in `process!': (-2014) API-key format invalid. (Binance::Api::Error::BadAPIKeyFormat)
#25 solves the issue please merge it!
Current workaround for me is bundle open binance-ruby
And changing line 13 of:
lib/binance/api/configuration.rb
From:
instance_api_key(type: type) || ENV["BINANCE_#{type.to_s.humanize.upcase}_API_KEY"] || ENV["BINANCE_API_KEY"]
To:
instance_api_key(type: type) || ENV["BINANCE_#{type.to_s.humanize.upcase}_API_KEY"] || instance_api_key || ENV["BINANCE_API_KEY"]
With the current approach, all requests return only the response body, that is, a JSON that is converted into a hash. That means it's not possible to know information about rate limiting, cache and more.
Here's an example: https://github.com/Jakenberg/binance-ruby/blob/master/lib/binance/api/account.rb#L26-L28
Would there be interest to instead return the HTTP object and let the client call response.body
, instead of prohibiting the client from accessing anything other than the HTTP body?
Hi,
Thanks for providing a great gem to interact with the Binance API.
Do you guys have any idea why I might be getting the response "{"code":-1104,"msg":"Not all sent parameters were read; read '6' parameter(s) but was sent '7'."}" on all the user requests that I've beent trying to make?
Thank you for your help.
I couldnt get it to work with ruby, but the python bindings worked perfectly.
This code dies on ruby but same exact thing with same keys/ip works fine with python:
require 'binance-ruby'
BINANCE_TLD = "US"
puts Binance::Api.ping!
puts Binance::Api::Account.info!
error: (-2015) Invalid API-key, IP, or permissions for action. (Binance::Api::Error)
im fairly certain it is not working under US tld.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.