Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file lib/binance/ruby/api
. To experiment with that code, run bin/console
for an interactive prompt.
Add this line to your application's Gemfile:
gem 'binance-ruby-api'
And then execute:
$ bundle
Or install it yourself as:
$ gem install binance-ruby-api
# system status
Binance::System.status
# market information
Binance::Market.ping
Binance::Market.server_time
Binance::Market.exchange_info
Binance::Market.orderbook(symbol: 'BTCUSDT', limit: 200)
Binance::Market.aggTrades(symbol: 'BTCUSDT', params: { limit: 10 })
Binance::Market.klines(symbol: 'BTCUSDT', interval: '1h', params: {limit: 100})
Binance::Market.ticker # get ticker for all symbols
Binance::Market.ticker(symbol: 'BTCUSDT')
Binance::Market.ticker_price
Binance::Market.ticker_price(symbol:'BTCUSDT')
Binance::Market.orderbook_ticker(symbol:'BTCUSDT')
Binance::Market.orderbook_ticker
ENV['BINANCE_PUBLIC_API_KEY'] = 'xxxxxx'
# historical trades require public api key
Binance::Market.historical_trades(symbol: 'BTCUSDT', limit: 5, from_id: 222256836)
# user information
ENV['BINANCE_PUBLIC_API_KEY'] = 'xxxxxx'
ENV['BINANCE_PRIVATE_API_KEY'] = 'yyyyy'
# showing all coins information
Binance::Account.all_coins
Binance::Account.asset_details
##### Future Testnet #####
Binance::Future::Testnet::Market.ping
Binance::Future::Testnet::Market.server_time
Binance::Future::Testnet::Market.depth(symbol: 'BTCUSDT', limit: 5)
Binance::Future::Testnet::Market.depth(symbol: 'BTCUSDT', limit: 5)
Binance::Future::Testnet::Market.trades(symbol: 'BTCUSDT', limit: 5)
Binance::Future::Testnet::Market.aggTrades(symbol: 'BTCUSDT', limit: 5)
# historical trades need api key
ENV['BINANCE_PUBLIC_API_KEY'] = 'xxxx'
Binance::Future::Testnet::Market.historicalTrades(symbol: 'BTCUSDT', limit: 5)
## User Data
Binance::Future::Testnet::Order.open_orders(symbol: 'BTCUSDT')
# test order, no real order placed
Binance::Future::Testnet::Order.test(
symbol: 'BTCUSDT',
side:'SELL',
type:'LIMIT',
quantity: 0.1,
params: {
timeInForce: 'GTC',
price: 8200
}
)
# place real order
Binance::Future::Testnet::Order.place_order(
symbol: 'BTCUSDT',
side:'SELL',
type:'LIMIT',
quantity: 0.1,
params: {
timeInForce: 'GTC',
price: 8200
}
)
# query by order id
Binance::Future::Testnet::Order.query(
symbol: 'BTCUSDT',
params: {
orderId: '1128382585'
}
)
# query by client order id
Binance::Future::Testnet::Order.query(
symbol: 'BTCUSDT',
params: {
origClientOrderId: 'xxxxxxx'
}
)
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/binance-ruby-api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the Binance::Ruby::Api project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.