R/ticker.R

# Binance Public Spot API
#
# OpenAPI Specifications for the Binance Public Spot API  API documents:   - [https://github.com/binance/binance-spot-api-docs](https://github.com/binance/binance-spot-api-docs)   - [https://binance-docs.github.io/apidocs/spot/en](https://binance-docs.github.io/apidocs/spot/en)
#
# The version of the OpenAPI document: 1.0
# 
# Generated by: https://openapi-generator.tech

#' @docType class
#' @title Ticker
#'
#' @description Ticker Class
#'
#' @format An \code{R6Class} generator object
#'
#' @field symbol  character 
#'
#' @field priceChange  character 
#'
#' @field priceChangePercent  character 
#'
#' @field prevClosePrice  character 
#'
#' @field lastPrice  character 
#'
#' @field bidPrice  character 
#'
#' @field bidQty  character 
#'
#' @field askPrice  character 
#'
#' @field askQty  character 
#'
#' @field openPrice  character 
#'
#' @field highPrice  character 
#'
#' @field lowPrice  character 
#'
#' @field volume  character 
#'
#' @field quoteVolume  character 
#'
#' @field openTime  integer 
#'
#' @field closeTime  integer 
#'
#' @field firstId  integer 
#'
#' @field lastId  integer 
#'
#' @field count  integer 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
Ticker <- R6::R6Class(
  'Ticker',
  public = list(
    `symbol` = NULL,
    `priceChange` = NULL,
    `priceChangePercent` = NULL,
    `prevClosePrice` = NULL,
    `lastPrice` = NULL,
    `bidPrice` = NULL,
    `bidQty` = NULL,
    `askPrice` = NULL,
    `askQty` = NULL,
    `openPrice` = NULL,
    `highPrice` = NULL,
    `lowPrice` = NULL,
    `volume` = NULL,
    `quoteVolume` = NULL,
    `openTime` = NULL,
    `closeTime` = NULL,
    `firstId` = NULL,
    `lastId` = NULL,
    `count` = NULL,
    initialize = function(
        `symbol`, `priceChange`, `priceChangePercent`, `prevClosePrice`, `lastPrice`, `bidPrice`, `bidQty`, `askPrice`, `askQty`, `openPrice`, `highPrice`, `lowPrice`, `volume`, `quoteVolume`, `openTime`, `closeTime`, `firstId`, `lastId`, `count`, ...
    ) {
      local.optional.var <- list(...)
      if (!missing(`symbol`)) {
        stopifnot(is.character(`symbol`), length(`symbol`) == 1)
        self$`symbol` <- `symbol`
      }
      if (!missing(`priceChange`)) {
        stopifnot(is.character(`priceChange`), length(`priceChange`) == 1)
        self$`priceChange` <- `priceChange`
      }
      if (!missing(`priceChangePercent`)) {
        stopifnot(is.character(`priceChangePercent`), length(`priceChangePercent`) == 1)
        self$`priceChangePercent` <- `priceChangePercent`
      }
      if (!missing(`prevClosePrice`)) {
        stopifnot(is.character(`prevClosePrice`), length(`prevClosePrice`) == 1)
        self$`prevClosePrice` <- `prevClosePrice`
      }
      if (!missing(`lastPrice`)) {
        stopifnot(is.character(`lastPrice`), length(`lastPrice`) == 1)
        self$`lastPrice` <- `lastPrice`
      }
      if (!missing(`bidPrice`)) {
        stopifnot(is.character(`bidPrice`), length(`bidPrice`) == 1)
        self$`bidPrice` <- `bidPrice`
      }
      if (!missing(`bidQty`)) {
        stopifnot(is.character(`bidQty`), length(`bidQty`) == 1)
        self$`bidQty` <- `bidQty`
      }
      if (!missing(`askPrice`)) {
        stopifnot(is.character(`askPrice`), length(`askPrice`) == 1)
        self$`askPrice` <- `askPrice`
      }
      if (!missing(`askQty`)) {
        stopifnot(is.character(`askQty`), length(`askQty`) == 1)
        self$`askQty` <- `askQty`
      }
      if (!missing(`openPrice`)) {
        stopifnot(is.character(`openPrice`), length(`openPrice`) == 1)
        self$`openPrice` <- `openPrice`
      }
      if (!missing(`highPrice`)) {
        stopifnot(is.character(`highPrice`), length(`highPrice`) == 1)
        self$`highPrice` <- `highPrice`
      }
      if (!missing(`lowPrice`)) {
        stopifnot(is.character(`lowPrice`), length(`lowPrice`) == 1)
        self$`lowPrice` <- `lowPrice`
      }
      if (!missing(`volume`)) {
        stopifnot(is.character(`volume`), length(`volume`) == 1)
        self$`volume` <- `volume`
      }
      if (!missing(`quoteVolume`)) {
        stopifnot(is.character(`quoteVolume`), length(`quoteVolume`) == 1)
        self$`quoteVolume` <- `quoteVolume`
      }
      if (!missing(`openTime`)) {
        stopifnot(is.numeric(`openTime`), length(`openTime`) == 1)
        self$`openTime` <- `openTime`
      }
      if (!missing(`closeTime`)) {
        stopifnot(is.numeric(`closeTime`), length(`closeTime`) == 1)
        self$`closeTime` <- `closeTime`
      }
      if (!missing(`firstId`)) {
        stopifnot(is.numeric(`firstId`), length(`firstId`) == 1)
        self$`firstId` <- `firstId`
      }
      if (!missing(`lastId`)) {
        stopifnot(is.numeric(`lastId`), length(`lastId`) == 1)
        self$`lastId` <- `lastId`
      }
      if (!missing(`count`)) {
        stopifnot(is.numeric(`count`), length(`count`) == 1)
        self$`count` <- `count`
      }
    },
    toJSON = function() {
      TickerObject <- list()
      if (!is.null(self$`symbol`)) {
        TickerObject[['symbol']] <-
          self$`symbol`
      }
      if (!is.null(self$`priceChange`)) {
        TickerObject[['priceChange']] <-
          self$`priceChange`
      }
      if (!is.null(self$`priceChangePercent`)) {
        TickerObject[['priceChangePercent']] <-
          self$`priceChangePercent`
      }
      if (!is.null(self$`prevClosePrice`)) {
        TickerObject[['prevClosePrice']] <-
          self$`prevClosePrice`
      }
      if (!is.null(self$`lastPrice`)) {
        TickerObject[['lastPrice']] <-
          self$`lastPrice`
      }
      if (!is.null(self$`bidPrice`)) {
        TickerObject[['bidPrice']] <-
          self$`bidPrice`
      }
      if (!is.null(self$`bidQty`)) {
        TickerObject[['bidQty']] <-
          self$`bidQty`
      }
      if (!is.null(self$`askPrice`)) {
        TickerObject[['askPrice']] <-
          self$`askPrice`
      }
      if (!is.null(self$`askQty`)) {
        TickerObject[['askQty']] <-
          self$`askQty`
      }
      if (!is.null(self$`openPrice`)) {
        TickerObject[['openPrice']] <-
          self$`openPrice`
      }
      if (!is.null(self$`highPrice`)) {
        TickerObject[['highPrice']] <-
          self$`highPrice`
      }
      if (!is.null(self$`lowPrice`)) {
        TickerObject[['lowPrice']] <-
          self$`lowPrice`
      }
      if (!is.null(self$`volume`)) {
        TickerObject[['volume']] <-
          self$`volume`
      }
      if (!is.null(self$`quoteVolume`)) {
        TickerObject[['quoteVolume']] <-
          self$`quoteVolume`
      }
      if (!is.null(self$`openTime`)) {
        TickerObject[['openTime']] <-
          self$`openTime`
      }
      if (!is.null(self$`closeTime`)) {
        TickerObject[['closeTime']] <-
          self$`closeTime`
      }
      if (!is.null(self$`firstId`)) {
        TickerObject[['firstId']] <-
          self$`firstId`
      }
      if (!is.null(self$`lastId`)) {
        TickerObject[['lastId']] <-
          self$`lastId`
      }
      if (!is.null(self$`count`)) {
        TickerObject[['count']] <-
          self$`count`
      }

      TickerObject
    },
    fromJSON = function(TickerJson) {
      TickerObject <- jsonlite::fromJSON(TickerJson)
      if (!is.null(TickerObject$`symbol`)) {
        self$`symbol` <- TickerObject$`symbol`
      }
      if (!is.null(TickerObject$`priceChange`)) {
        self$`priceChange` <- TickerObject$`priceChange`
      }
      if (!is.null(TickerObject$`priceChangePercent`)) {
        self$`priceChangePercent` <- TickerObject$`priceChangePercent`
      }
      if (!is.null(TickerObject$`prevClosePrice`)) {
        self$`prevClosePrice` <- TickerObject$`prevClosePrice`
      }
      if (!is.null(TickerObject$`lastPrice`)) {
        self$`lastPrice` <- TickerObject$`lastPrice`
      }
      if (!is.null(TickerObject$`bidPrice`)) {
        self$`bidPrice` <- TickerObject$`bidPrice`
      }
      if (!is.null(TickerObject$`bidQty`)) {
        self$`bidQty` <- TickerObject$`bidQty`
      }
      if (!is.null(TickerObject$`askPrice`)) {
        self$`askPrice` <- TickerObject$`askPrice`
      }
      if (!is.null(TickerObject$`askQty`)) {
        self$`askQty` <- TickerObject$`askQty`
      }
      if (!is.null(TickerObject$`openPrice`)) {
        self$`openPrice` <- TickerObject$`openPrice`
      }
      if (!is.null(TickerObject$`highPrice`)) {
        self$`highPrice` <- TickerObject$`highPrice`
      }
      if (!is.null(TickerObject$`lowPrice`)) {
        self$`lowPrice` <- TickerObject$`lowPrice`
      }
      if (!is.null(TickerObject$`volume`)) {
        self$`volume` <- TickerObject$`volume`
      }
      if (!is.null(TickerObject$`quoteVolume`)) {
        self$`quoteVolume` <- TickerObject$`quoteVolume`
      }
      if (!is.null(TickerObject$`openTime`)) {
        self$`openTime` <- TickerObject$`openTime`
      }
      if (!is.null(TickerObject$`closeTime`)) {
        self$`closeTime` <- TickerObject$`closeTime`
      }
      if (!is.null(TickerObject$`firstId`)) {
        self$`firstId` <- TickerObject$`firstId`
      }
      if (!is.null(TickerObject$`lastId`)) {
        self$`lastId` <- TickerObject$`lastId`
      }
      if (!is.null(TickerObject$`count`)) {
        self$`count` <- TickerObject$`count`
      }
      self
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`symbol`)) {
        sprintf(
        '"symbol":
          "%s"
                ',
        self$`symbol`
        )},
        if (!is.null(self$`priceChange`)) {
        sprintf(
        '"priceChange":
          "%s"
                ',
        self$`priceChange`
        )},
        if (!is.null(self$`priceChangePercent`)) {
        sprintf(
        '"priceChangePercent":
          "%s"
                ',
        self$`priceChangePercent`
        )},
        if (!is.null(self$`prevClosePrice`)) {
        sprintf(
        '"prevClosePrice":
          "%s"
                ',
        self$`prevClosePrice`
        )},
        if (!is.null(self$`lastPrice`)) {
        sprintf(
        '"lastPrice":
          "%s"
                ',
        self$`lastPrice`
        )},
        if (!is.null(self$`bidPrice`)) {
        sprintf(
        '"bidPrice":
          "%s"
                ',
        self$`bidPrice`
        )},
        if (!is.null(self$`bidQty`)) {
        sprintf(
        '"bidQty":
          "%s"
                ',
        self$`bidQty`
        )},
        if (!is.null(self$`askPrice`)) {
        sprintf(
        '"askPrice":
          "%s"
                ',
        self$`askPrice`
        )},
        if (!is.null(self$`askQty`)) {
        sprintf(
        '"askQty":
          "%s"
                ',
        self$`askQty`
        )},
        if (!is.null(self$`openPrice`)) {
        sprintf(
        '"openPrice":
          "%s"
                ',
        self$`openPrice`
        )},
        if (!is.null(self$`highPrice`)) {
        sprintf(
        '"highPrice":
          "%s"
                ',
        self$`highPrice`
        )},
        if (!is.null(self$`lowPrice`)) {
        sprintf(
        '"lowPrice":
          "%s"
                ',
        self$`lowPrice`
        )},
        if (!is.null(self$`volume`)) {
        sprintf(
        '"volume":
          "%s"
                ',
        self$`volume`
        )},
        if (!is.null(self$`quoteVolume`)) {
        sprintf(
        '"quoteVolume":
          "%s"
                ',
        self$`quoteVolume`
        )},
        if (!is.null(self$`openTime`)) {
        sprintf(
        '"openTime":
          %d
                ',
        self$`openTime`
        )},
        if (!is.null(self$`closeTime`)) {
        sprintf(
        '"closeTime":
          %d
                ',
        self$`closeTime`
        )},
        if (!is.null(self$`firstId`)) {
        sprintf(
        '"firstId":
          %d
                ',
        self$`firstId`
        )},
        if (!is.null(self$`lastId`)) {
        sprintf(
        '"lastId":
          %d
                ',
        self$`lastId`
        )},
        if (!is.null(self$`count`)) {
        sprintf(
        '"count":
          %d
                ',
        self$`count`
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(TickerJson) {
      TickerObject <- jsonlite::fromJSON(TickerJson)
      self$`symbol` <- TickerObject$`symbol`
      self$`priceChange` <- TickerObject$`priceChange`
      self$`priceChangePercent` <- TickerObject$`priceChangePercent`
      self$`prevClosePrice` <- TickerObject$`prevClosePrice`
      self$`lastPrice` <- TickerObject$`lastPrice`
      self$`bidPrice` <- TickerObject$`bidPrice`
      self$`bidQty` <- TickerObject$`bidQty`
      self$`askPrice` <- TickerObject$`askPrice`
      self$`askQty` <- TickerObject$`askQty`
      self$`openPrice` <- TickerObject$`openPrice`
      self$`highPrice` <- TickerObject$`highPrice`
      self$`lowPrice` <- TickerObject$`lowPrice`
      self$`volume` <- TickerObject$`volume`
      self$`quoteVolume` <- TickerObject$`quoteVolume`
      self$`openTime` <- TickerObject$`openTime`
      self$`closeTime` <- TickerObject$`closeTime`
      self$`firstId` <- TickerObject$`firstId`
      self$`lastId` <- TickerObject$`lastId`
      self$`count` <- TickerObject$`count`
      self
    }
  )
)
grahamjwhite/binanceRapi documentation built on Nov. 22, 2022, 9:37 p.m.