R/snapshot_futures_data_position.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 SnapshotFuturesDataPosition
#'
#' @description SnapshotFuturesDataPosition Class
#'
#' @format An \code{R6Class} generator object
#'
#' @field entryPrice  character 
#'
#' @field markPrice  character 
#'
#' @field positionAmt  character 
#'
#' @field symbol  character 
#'
#' @field unRealizedProfit  character 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
SnapshotFuturesDataPosition <- R6::R6Class(
  'SnapshotFuturesDataPosition',
  public = list(
    `entryPrice` = NULL,
    `markPrice` = NULL,
    `positionAmt` = NULL,
    `symbol` = NULL,
    `unRealizedProfit` = NULL,
    initialize = function(
        `entryPrice`, `markPrice`, `positionAmt`, `symbol`, `unRealizedProfit`, ...
    ) {
      local.optional.var <- list(...)
      if (!missing(`entryPrice`)) {
        stopifnot(is.character(`entryPrice`), length(`entryPrice`) == 1)
        self$`entryPrice` <- `entryPrice`
      }
      if (!missing(`markPrice`)) {
        stopifnot(is.character(`markPrice`), length(`markPrice`) == 1)
        self$`markPrice` <- `markPrice`
      }
      if (!missing(`positionAmt`)) {
        stopifnot(is.character(`positionAmt`), length(`positionAmt`) == 1)
        self$`positionAmt` <- `positionAmt`
      }
      if (!missing(`symbol`)) {
        stopifnot(is.character(`symbol`), length(`symbol`) == 1)
        self$`symbol` <- `symbol`
      }
      if (!missing(`unRealizedProfit`)) {
        stopifnot(is.character(`unRealizedProfit`), length(`unRealizedProfit`) == 1)
        self$`unRealizedProfit` <- `unRealizedProfit`
      }
    },
    toJSON = function() {
      SnapshotFuturesDataPositionObject <- list()
      if (!is.null(self$`entryPrice`)) {
        SnapshotFuturesDataPositionObject[['entryPrice']] <-
          self$`entryPrice`
      }
      if (!is.null(self$`markPrice`)) {
        SnapshotFuturesDataPositionObject[['markPrice']] <-
          self$`markPrice`
      }
      if (!is.null(self$`positionAmt`)) {
        SnapshotFuturesDataPositionObject[['positionAmt']] <-
          self$`positionAmt`
      }
      if (!is.null(self$`symbol`)) {
        SnapshotFuturesDataPositionObject[['symbol']] <-
          self$`symbol`
      }
      if (!is.null(self$`unRealizedProfit`)) {
        SnapshotFuturesDataPositionObject[['unRealizedProfit']] <-
          self$`unRealizedProfit`
      }

      SnapshotFuturesDataPositionObject
    },
    fromJSON = function(SnapshotFuturesDataPositionJson) {
      SnapshotFuturesDataPositionObject <- jsonlite::fromJSON(SnapshotFuturesDataPositionJson)
      if (!is.null(SnapshotFuturesDataPositionObject$`entryPrice`)) {
        self$`entryPrice` <- SnapshotFuturesDataPositionObject$`entryPrice`
      }
      if (!is.null(SnapshotFuturesDataPositionObject$`markPrice`)) {
        self$`markPrice` <- SnapshotFuturesDataPositionObject$`markPrice`
      }
      if (!is.null(SnapshotFuturesDataPositionObject$`positionAmt`)) {
        self$`positionAmt` <- SnapshotFuturesDataPositionObject$`positionAmt`
      }
      if (!is.null(SnapshotFuturesDataPositionObject$`symbol`)) {
        self$`symbol` <- SnapshotFuturesDataPositionObject$`symbol`
      }
      if (!is.null(SnapshotFuturesDataPositionObject$`unRealizedProfit`)) {
        self$`unRealizedProfit` <- SnapshotFuturesDataPositionObject$`unRealizedProfit`
      }
      self
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`entryPrice`)) {
        sprintf(
        '"entryPrice":
          "%s"
                ',
        self$`entryPrice`
        )},
        if (!is.null(self$`markPrice`)) {
        sprintf(
        '"markPrice":
          "%s"
                ',
        self$`markPrice`
        )},
        if (!is.null(self$`positionAmt`)) {
        sprintf(
        '"positionAmt":
          "%s"
                ',
        self$`positionAmt`
        )},
        if (!is.null(self$`symbol`)) {
        sprintf(
        '"symbol":
          "%s"
                ',
        self$`symbol`
        )},
        if (!is.null(self$`unRealizedProfit`)) {
        sprintf(
        '"unRealizedProfit":
          "%s"
                ',
        self$`unRealizedProfit`
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(SnapshotFuturesDataPositionJson) {
      SnapshotFuturesDataPositionObject <- jsonlite::fromJSON(SnapshotFuturesDataPositionJson)
      self$`entryPrice` <- SnapshotFuturesDataPositionObject$`entryPrice`
      self$`markPrice` <- SnapshotFuturesDataPositionObject$`markPrice`
      self$`positionAmt` <- SnapshotFuturesDataPositionObject$`positionAmt`
      self$`symbol` <- SnapshotFuturesDataPositionObject$`symbol`
      self$`unRealizedProfit` <- SnapshotFuturesDataPositionObject$`unRealizedProfit`
      self
    }
  )
)
grahamjwhite/binanceRapi documentation built on Nov. 22, 2022, 9:37 p.m.