Skip to content

Commit 0b3da62

Browse files
committed
Test binance_ticks()
1 parent b9ef2fc commit 0b3da62

2 files changed

Lines changed: 60 additions & 0 deletions

File tree

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
http_interactions:
2+
- request:
3+
method: get
4+
uri: https://api.binance.com/api/v1/aggTrades?symbol=ETHUSDT&limit=2
5+
body:
6+
encoding: ''
7+
string: ''
8+
headers:
9+
Accept: application/json, text/xml, application/xml, */*
10+
response:
11+
status:
12+
status_code: 200
13+
category: Success
14+
reason: OK
15+
message: 'Success: (200) OK'
16+
headers:
17+
content-type: application/json;charset=UTF-8
18+
content-length: '237'
19+
date: Fri, 17 Dec 2021 16:43:02 GMT
20+
server: nginx
21+
x-mbx-uuid: f18ad480-f11a-41f8-a01d-d5b47c6c865e
22+
x-mbx-used-weight: '1'
23+
x-mbx-used-weight-1m: '1'
24+
strict-transport-security: max-age=31536000; includeSubdomains
25+
x-frame-options: SAMEORIGIN
26+
x-xss-protection: 1; mode=block
27+
x-content-type-options: nosniff
28+
content-security-policy: default-src 'self'
29+
x-content-security-policy: default-src 'self'
30+
x-webkit-csp: default-src 'self'
31+
cache-control: no-cache, no-store, must-revalidate
32+
pragma: no-cache
33+
expires: '0'
34+
access-control-allow-origin: '*'
35+
access-control-allow-methods: GET, HEAD, OPTIONS
36+
x-cache: Miss from cloudfront
37+
via: 1.1 05aec04162b0fed6e9762cd1edd66a72.cloudfront.net (CloudFront)
38+
x-amz-cf-pop: SFO5-C1
39+
x-amz-cf-id: Ubkw3eaurWKWcgWjRmc-rGlqUnFn2eNzuazRiOk2YF-lD45O6zyhCg==
40+
body:
41+
encoding: UTF-8
42+
file: no
43+
string: '[{"a":579794207,"p":"3910.67000000","q":"0.91590000","f":710227286,"l":710227287,"T":1639759381993,"m":false,"M":true},{"a":579794208,"p":"3910.68000000","q":"0.09410000","f":710227288,"l":710227289,"T":1639759381993,"m":false,"M":true}]'
44+
recorded_at: 2021-12-17 16:43:02 GMT
45+
recorded_with: vcr/1.0.2, webmockr/0.8.0

tests/testthat/test-spot.R

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,18 @@ test_that("Klines on Spot", {
5555
)
5656
expect_equal(response$taker_buy_quote_asset_volume, 411011816)
5757
})
58+
59+
test_that("Ticks on Spot", {
60+
vcr::use_cassette("spot_ticks_ethusdt_1d_limit_2", {
61+
response <- binance_ticks("ETHUSDT", limit = 2)
62+
})
63+
64+
expect_equal(response$agg_trade_id, c(579794207, 579794208))
65+
expect_equal(response$price, c(3911, 3911), tolerance = 0.01)
66+
expect_equal(response$quantity, c(0.92, 0.09), tolerance = 0.01)
67+
expect_equal(response$first_trade_id, c(710227286, 710227288))
68+
expect_equal(response$last_trade_id, c(710227286, 710227288))
69+
expect_equal(response$time, as_time(c(1639759382, 1639759382)))
70+
expect_equal(response$buyer_maker, c(FALSE, FALSE))
71+
expect_equal(response$best_price_match, c(TRUE, TRUE))
72+
})

0 commit comments

Comments
 (0)