Skip to contents

[Stable]

Get a quote on a cryptocurrency pair from the available_exchanges() in various available_intervals() for any actively traded available_tickers().

Usage

get_quote(
 ticker,
 source   = 'binance',
 futures  = TRUE,
 interval = '1d',
 from     = NULL,
 to       = NULL
)

Arguments

ticker

A character-vector of length 1. See available_tickers() for available tickers.

source

A character-vector of length 1. binance by default. See available_exchanges() for available exchanges.

futures

A logical-vector of length 1. TRUE by default. Returns futures market if TRUE, spot market otherwise.

interval

A character-vector of length 1. 1d by default. See available_intervals() for available intervals.

from

An optional character-, date- or POSIXct-vector of length 1. NULL by default.

to

An optional character-, date- or POSIXct-vector of length 1. NULL by default.

Value

An xts-object containing,

index

<POSIXct> The time-index

open

<numeric> Opening price

high

<numeric> Highest price

low

<numeric> Lowest price

close

<numeric> Closing price

volume

<numeric> Trading volume

Sample output

#>                        open    high     low   close   volume
#> 2024-05-12 02:00:00 60809.2 61849.4 60557.3 61455.8 104043.9
#> 2024-05-13 02:00:00 61455.7 63440.0 60750.0 62912.1 261927.1
#> 2024-05-14 02:00:00 62912.2 63099.6 60950.0 61550.5 244345.3
#> 2024-05-15 02:00:00 61550.5 66440.0 61316.1 66175.4 365031.7
#> 2024-05-16 02:00:00 66175.4 66800.0 64567.0 65217.7 242455.3
#> 2024-05-17 02:00:00 65217.7 66478.5 65061.2 66218.8  66139.1

Details

On time-zones and dates

Values passed to from or to must be coercible by as.Date(), or as.POSIXct(), with a format of either "%Y-%m-%d" or "%Y-%m-%d %H:%M:%S". By default all dates are passed and returned with Sys.timezone().

On returns

If only from is provided 200 pips are returned up to Sys.time(). If only to is provided 200 pips up to the specified date is returned.

See also

Author

Serkan Korkmaz

Examples

if (FALSE) {
  # script start;

  # get quote on
  # BTCUSDT pair from
  # Binance in 30m
  # intervals from the
  # last 24 hours
  tail(
    BTC <- cryptoQuotes::get_quote(
      ticker   = 'BTCUSDT',
      source   = 'binance',
      interval = '30m',
      futures  = FALSE,
      from     = Sys.Date() - 1
    )
  )

  # script end;
}