Skip to contents

Converts a UNIX timestamp from KuCoin's server into a POSIXct object in UTC, based on the specified time unit.

Usage

time_convert_from_kucoin(time_value, unit = c("ms", "ns", "s"))

Arguments

time_value

Numeric value representing the UNIX timestamp.

unit

Character string specifying the input time unit: "ms" for milliseconds (default), "ns" for nanoseconds, or "s" for seconds.

Value

POSIXct object representing the timestamp in UTC.

Details

Workflow Overview

  1. Input Validation: Ensures time_value is numeric, aborting if not.

  2. Unit Matching: Validates unit against allowed options ("ms", "ns", "s") using match.arg().

  3. Time Conversion: Converts the timestamp to seconds based on the unit and then to POSIXct using lubridate::as_datetime().

API Endpoint

Not applicable (helper function for timestamp conversion).

Usage

Utilised to transform KuCoin API timestamps into R's POSIXct format for analysis or visualisation.

Official Documentation

Not directly tied to a specific endpoint; see KuCoin API timestamp usage guidelines.

Examples

if (FALSE) { # \dontrun{
# Convert a millisecond timestamp
time_convert_from_kucoin(time_value = 1698777600000, unit = "ms")
# Returns POSIXct equivalent of 2023-10-31 16:00:00 UTC

# Convert a nanosecond timestamp
time_convert_from_kucoin(time_value = 1698777600000000000, unit = "ns")
# Returns POSIXct equivalent of 2023-10-31 16:00:00 UTC
} # }