Skip to content

agent462/chinashop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The start of a btcchina library. The btcchina api is currently very basic so don't expect any magic.

If you are feeling generous, throw me some btc: 13rhHcFx8AWej5F1VYAudHc1SupJMTJKZU

Usage

require 'chinashop'

ChinaShop.configure do |config|
  config.key = 'your-key-here'
  config.secret = 'your-secret-here'
end

puts ChinaShop.ticker.high
puts ChinaShop.account.balance.btc

Configuration

Apply a key and secret to use the account and trading features.

ChinaShop.configure do |config|
  config.key = 'your-key-here'
  config.secret = 'your-secret-here'
end

Ticker

Returns the ticker information. Accessed via ChinaShop.ticker. The following methods are available:

  • all
  • high
  • low
  • buy
  • sell
  • last
  • vol
puts ChinaShop.ticker.high

Account

Returns the user account information. Configuration is required. Accessed via ChinaShop.account. The following methods are available:

  • all
  • username
  • balance
  • frozen
  • deposit_address
puts ChinaShop.account.balance.btc

Market Depth

Returns the Market Depth. Accessed via ChinaShop.market_depth. The following methods are available:

  • all
  • bids
  • asks
ChinaShop.market_depth.bids

Buy

Places a Bid order for the btcchina exchange. Accessed via ChinaShop.buy. The following methods are available:

  • all
  • result
b = ChinaShop.buy(:price => 6030, :amount => 0.009)
puts b.result

Sell

Places a Ask order for the btcchina exchange. Accessed via ChinaShop.sell. The following methods are available:

  • all
  • result
s = ChinaShop.sell(:price => 6030, :amount => 0.009)
puts s.result

Orders

Lists all the open orders. Accessed via ChinaShop.orders. The following methods are available:

  • all
puts ChinaShop.orders.all

Order

Get a single order. Accessed via ChinaShop.order. The following methods are available:

  • all
  • id
  • type
  • price
  • currency
  • amount
  • amount_original
  • date
  • status
puts ChinaShop.order(823841).status

Transactions

Lists recent transactions. Accessed via ChinaShop.transactions. The following methods are available:

  • all
puts ChinaShop.transactions.all

Deposits

Lists recent deposits. Accessed via ChinaShop.deposits. The following methods are available:

  • all
puts ChinaShop.deposits.all

Trades

Returns the last 24 hours of trades. Accessed via ChinaShop.trades. Please beware that excessive use could lead to btcchina IP blocking you.

puts ChinaShop.trades

Trade History

Passing in no value will return the last 100 trades. Passing in a trade id will return 100 trades starting from that id. Accessed via ChinaShop.trade_history. Please beware that excessive use could lead to btcchina IP blocking you.

puts ChinaShop.trade_history
puts ChinaShop.trade_history(50000)

Order Book

Returns the current order book. Accessed via ChinaShop.order_book. Please beware that excessive use could lead to btcchina IP blocking you.

puts ChinaShop.order_book

License and Author

Author:: Bryan Brandau agent462@gmail.com

Copyright:: 2013, Bryan Brandau

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

About

A btcchina ruby library for easily interacting with their api.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages