Skip to content

Commit eba0f52

Browse files
committed
chore: updates readme
1 parent b1c72c3 commit eba0f52

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ gem 'rest-client', '2.1.0'
1010
group :test do
1111
gem 'rubocop', '1.60.2'
1212
gem 'test-unit', '3.6.2'
13-
end
13+
end

README.md

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ This sdk makes use of the [api version 2](https://api.exchange.cryptomkt.com/v2)
2121
## rest client
2222

2323
```ruby
24-
require "cryptomarket"
24+
require "cryptomarket-sdk"
2525

2626
# instance a client
2727
api_key='AB32B3201'
@@ -62,15 +62,15 @@ order = client.create_spot_order(
6262

6363
## Websocket Clients
6464

65-
there are three websocket clients, `MarketDataClient`, the `SpotTradingClient` and the `WalletManagementClient`. The `MarketDataClient` is public, while the others require authentication to be used.
65+
Ahere are three websocket clients, the `MarketDataClient`, the `TradingClient` and the `WalletClient`. The `MarketDataClient` is public, while the others require authentication to be used.
6666

6767
All websocket methods take Procs for their callbacks. These procs take two argument, the first is a possible error in the call (such as missing arguments), and the result data of the method.
6868

6969
Subscriptions also take in a Proc of two parameters, the notification data, and the notification type. The notification type is of type Args::NotificationType, and is either SNAPSHOT, NOTIFICATION or DATA, corresponding to the strings 'snapshot', 'update' and 'data'
7070

7171
The documentation of a specific subscriptions explains with of this types of notification uses.
7272

73-
### MarketDataClient
73+
### Websocket Market Data Client
7474

7575
There are no unsubscriptions methods for the `MarketDataClient`. To stop recieving messages is recomended to close the `MarketDataClient`.
7676

@@ -122,7 +122,9 @@ client.subscribe_to_ticker(
122122
)
123123
```
124124

125-
### SpotTradingClient
125+
### Websocket Trading Client
126+
127+
Subscription callback to spot trading balances takes only one argument, a list of balances (see example below)
126128

127129
```ruby
128130
# instance a client with a 15 seconds window
@@ -136,7 +138,7 @@ client.connect
136138
client.close
137139

138140
# subscribe to order reports
139-
client.subscribeToReports(
141+
client.subscribe_to_reports(
140142
callback:Proc.new {|notification, type|
141143
if type == Args::NotificationType::UPDATE
142144
puts "a lonely report in a list"
@@ -150,6 +152,12 @@ client.subscribeToReports(
150152
# unsubscribe from order reports
151153
client.unsubscribe_to_reports
152154

155+
@wsclient.subscribe_to_spot_balance(
156+
callback: ->(balances) {puts balances},
157+
result_callback: ->(_) {},
158+
mode: 'updates'
159+
)
160+
153161
client_order_id = Time.now.to_i.to_s
154162

155163
# create an order
@@ -166,7 +174,9 @@ client.cancel_spot_order(client_order_id)
166174

167175
```
168176

169-
### WalletManagementClient
177+
### Websocket Wallet Management Client
178+
179+
Subscription callback to transactions takes only one argument, a transaction (see example below)
170180

171181
```ruby
172182
# instance a client with a default window of 10 seconds
@@ -177,11 +187,14 @@ defer client.close
177187

178188
# subscribe to wallet transactions
179189
def callback(transaction):
180-
print(transaction)
190+
->(transaction) { puts(transaction) }
191+
181192
client.subscribe_to_transactions(callback)
182193

183194
# unsubscribe from wallet transactions
184-
err = client.unsubscribe_to_transactions()
195+
client.unsubscribe_to_transactions(lambda { |is_success|
196+
puts('successful unsubscription') if is_success
197+
})
185198

186199
# get wallet balances
187200
client.get_wallet_balances(->(balances){ puts balances})
@@ -218,7 +231,7 @@ end
218231

219232
wsclient = Cryptomarket::Websocket::TradingClient.new api_key:api_key, api_secret:api_secret
220233

221-
# websocket errors are passed as the first argument to the callback
234+
# websocket errors are passed as the first argument to the callback. valid for all non subscription methods
222235
my_callback = Proc.new {|err, data|
223236
if not err.nil?
224237
puts err # deal with error

0 commit comments

Comments
 (0)