Module cmc.utils.models

Module for converting cmc-py return values to Pydantic models.

Expand source code
#!/usr/bin/env python

"""Module for converting `cmc-py` return values to Pydantic models."""

from datetime import datetime
from typing import Optional, Tuple
from pydantic import BaseModel


class CryptoCurrencyData(BaseModel):
    name: str
    symbol: str
    rank: str
    price: str
    price_percent: Tuple[str, ...]
    price_change: str
    low_24h: str
    high_24h: str
    market_cap: str
    fully_diluted_market_cap: str
    volume_24h: str
    volume_by_market_cap: str
    circulating_supply: str
    circulating_supply_percent: str
    max_supply: Optional[str]
    total_supply: Optional[str]
    cmc_url: str
    timestamp: datetime


class MostVisitedData(BaseModel):
    name: str
    symbol: str
    cmc_name: str
    url: str
    price: str
    percent_24h: Tuple[str, ...]
    percent_7d: Tuple[str, ...]
    percent_30d: Tuple[str, ...]
    market_cap: str
    volume_24h: str
    timestamp: datetime


class TopGainersData(BaseModel):
    name: str
    symbol: str
    rank: str
    cmc_name: str
    url: str
    price: str
    percentage: str
    volume_24h: str
    timestamp: datetime


class TopLosersData(BaseModel):
    name: str
    symbol: str
    rank: str
    cmc_name: str
    url: str
    price: str
    percentage: str
    volume_24h: str
    timestamp: datetime


class TrendingData(BaseModel):
    name: str
    symbol: str
    cmc_name: str
    url: str
    price: str
    percent_24h: Tuple[str, ...]
    percent_7d: Tuple[str, ...]
    percent_30d: Tuple[str, ...]
    market_cap: str
    volume_24h: str
    timestamp: datetime


class PricePredictionData(BaseModel):
    name: str
    symbol: str
    cmc_name: str
    url: str
    accuracy: str
    price: str
    price_date: str
    estimation_median: str
    estimation_average: str
    total_estimate: str
    timestamp: datetime


class RankingData(BaseModel):
    name: str
    symbol: str
    cmc_name: str
    url: str
    timestamp: datetime


class RecentlyAddedData(BaseModel):
    name: str
    symbol: str
    cmc_name: str
    url: str
    price: str
    percent_1h: Tuple[str, ...]
    percent_24h: Tuple[str, ...]
    fully_diluted_market_cap: str
    volume_24h: str
    blockchain: str
    added: str
    timestamp: datetime


class ExchangeData(BaseModel):
    name: str
    volume_24h: Tuple[str, ...]
    website: str
    cmc_url: str
    timestamp: datetime


class DerivativesData(BaseModel):
    name: str
    cmc_link: str
    cmc_name: str
    url: str
    timestamp: datetime


class DexData(BaseModel):
    name: str
    cmc_link: str
    cmc_name: str
    url: str
    timestamp: datetime


class LendingData(BaseModel):
    name: str
    cmc_link: str
    cmc_name: str
    url: str
    timestamp: datetime


class SpotData(BaseModel):
    name: str
    cmc_link: str
    cmc_name: str
    url: str
    timestamp: datetime


class NFTRankingData(BaseModel):
    name: str
    timestamp: datetime


class UpcomingSaleData(BaseModel):
    name: str
    blockchain: str
    info: str
    discord: str
    twitter: str
    website: str
    sale_on: str
    pre_sale: Optional[str]
    sale: str
    timestamp: datetime

Classes

class CryptoCurrencyData (**data: Any)

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

Expand source code
class CryptoCurrencyData(BaseModel):
    name: str
    symbol: str
    rank: str
    price: str
    price_percent: Tuple[str, ...]
    price_change: str
    low_24h: str
    high_24h: str
    market_cap: str
    fully_diluted_market_cap: str
    volume_24h: str
    volume_by_market_cap: str
    circulating_supply: str
    circulating_supply_percent: str
    max_supply: Optional[str]
    total_supply: Optional[str]
    cmc_url: str
    timestamp: datetime

Ancestors

  • pydantic.main.BaseModel
  • pydantic.utils.Representation

Class variables

var circulating_supply : str
var circulating_supply_percent : str
var cmc_url : str
var fully_diluted_market_cap : str
var high_24h : str
var low_24h : str
var market_cap : str
var max_supply : Optional[str]
var name : str
var price : str
var price_change : str
var price_percent : Tuple[str, ...]
var rank : str
var symbol : str
var timestamp : datetime.datetime
var total_supply : Optional[str]
var volume_24h : str
var volume_by_market_cap : str
class DerivativesData (**data: Any)

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

Expand source code
class DerivativesData(BaseModel):
    name: str
    cmc_link: str
    cmc_name: str
    url: str
    timestamp: datetime

Ancestors

  • pydantic.main.BaseModel
  • pydantic.utils.Representation

Class variables

var cmc_name : str
var name : str
var timestamp : datetime.datetime
var url : str
class DexData (**data: Any)

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

Expand source code
class DexData(BaseModel):
    name: str
    cmc_link: str
    cmc_name: str
    url: str
    timestamp: datetime

Ancestors

  • pydantic.main.BaseModel
  • pydantic.utils.Representation

Class variables

var cmc_name : str
var name : str
var timestamp : datetime.datetime
var url : str
class ExchangeData (**data: Any)

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

Expand source code
class ExchangeData(BaseModel):
    name: str
    volume_24h: Tuple[str, ...]
    website: str
    cmc_url: str
    timestamp: datetime

Ancestors

  • pydantic.main.BaseModel
  • pydantic.utils.Representation

Class variables

var cmc_url : str
var name : str
var timestamp : datetime.datetime
var volume_24h : Tuple[str, ...]
var website : str
class LendingData (**data: Any)

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

Expand source code
class LendingData(BaseModel):
    name: str
    cmc_link: str
    cmc_name: str
    url: str
    timestamp: datetime

Ancestors

  • pydantic.main.BaseModel
  • pydantic.utils.Representation

Class variables

var cmc_name : str
var name : str
var timestamp : datetime.datetime
var url : str
class MostVisitedData (**data: Any)

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

Expand source code
class MostVisitedData(BaseModel):
    name: str
    symbol: str
    cmc_name: str
    url: str
    price: str
    percent_24h: Tuple[str, ...]
    percent_7d: Tuple[str, ...]
    percent_30d: Tuple[str, ...]
    market_cap: str
    volume_24h: str
    timestamp: datetime

Ancestors

  • pydantic.main.BaseModel
  • pydantic.utils.Representation

Class variables

var cmc_name : str
var market_cap : str
var name : str
var percent_24h : Tuple[str, ...]
var percent_30d : Tuple[str, ...]
var percent_7d : Tuple[str, ...]
var price : str
var symbol : str
var timestamp : datetime.datetime
var url : str
var volume_24h : str
class NFTRankingData (**data: Any)

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

Expand source code
class NFTRankingData(BaseModel):
    name: str
    timestamp: datetime

Ancestors

  • pydantic.main.BaseModel
  • pydantic.utils.Representation

Class variables

var name : str
var timestamp : datetime.datetime
class PricePredictionData (**data: Any)

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

Expand source code
class PricePredictionData(BaseModel):
    name: str
    symbol: str
    cmc_name: str
    url: str
    accuracy: str
    price: str
    price_date: str
    estimation_median: str
    estimation_average: str
    total_estimate: str
    timestamp: datetime

Ancestors

  • pydantic.main.BaseModel
  • pydantic.utils.Representation

Class variables

var accuracy : str
var cmc_name : str
var estimation_average : str
var estimation_median : str
var name : str
var price : str
var price_date : str
var symbol : str
var timestamp : datetime.datetime
var total_estimate : str
var url : str
class RankingData (**data: Any)

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

Expand source code
class RankingData(BaseModel):
    name: str
    symbol: str
    cmc_name: str
    url: str
    timestamp: datetime

Ancestors

  • pydantic.main.BaseModel
  • pydantic.utils.Representation

Class variables

var cmc_name : str
var name : str
var symbol : str
var timestamp : datetime.datetime
var url : str
class RecentlyAddedData (**data: Any)

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

Expand source code
class RecentlyAddedData(BaseModel):
    name: str
    symbol: str
    cmc_name: str
    url: str
    price: str
    percent_1h: Tuple[str, ...]
    percent_24h: Tuple[str, ...]
    fully_diluted_market_cap: str
    volume_24h: str
    blockchain: str
    added: str
    timestamp: datetime

Ancestors

  • pydantic.main.BaseModel
  • pydantic.utils.Representation

Class variables

var added : str
var blockchain : str
var cmc_name : str
var fully_diluted_market_cap : str
var name : str
var percent_1h : Tuple[str, ...]
var percent_24h : Tuple[str, ...]
var price : str
var symbol : str
var timestamp : datetime.datetime
var url : str
var volume_24h : str
class SpotData (**data: Any)

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

Expand source code
class SpotData(BaseModel):
    name: str
    cmc_link: str
    cmc_name: str
    url: str
    timestamp: datetime

Ancestors

  • pydantic.main.BaseModel
  • pydantic.utils.Representation

Class variables

var cmc_name : str
var name : str
var timestamp : datetime.datetime
var url : str
class TopGainersData (**data: Any)

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

Expand source code
class TopGainersData(BaseModel):
    name: str
    symbol: str
    rank: str
    cmc_name: str
    url: str
    price: str
    percentage: str
    volume_24h: str
    timestamp: datetime

Ancestors

  • pydantic.main.BaseModel
  • pydantic.utils.Representation

Class variables

var cmc_name : str
var name : str
var percentage : str
var price : str
var rank : str
var symbol : str
var timestamp : datetime.datetime
var url : str
var volume_24h : str
class TopLosersData (**data: Any)

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

Expand source code
class TopLosersData(BaseModel):
    name: str
    symbol: str
    rank: str
    cmc_name: str
    url: str
    price: str
    percentage: str
    volume_24h: str
    timestamp: datetime

Ancestors

  • pydantic.main.BaseModel
  • pydantic.utils.Representation

Class variables

var cmc_name : str
var name : str
var percentage : str
var price : str
var rank : str
var symbol : str
var timestamp : datetime.datetime
var url : str
var volume_24h : str
class TrendingData (**data: Any)

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

Expand source code
class TrendingData(BaseModel):
    name: str
    symbol: str
    cmc_name: str
    url: str
    price: str
    percent_24h: Tuple[str, ...]
    percent_7d: Tuple[str, ...]
    percent_30d: Tuple[str, ...]
    market_cap: str
    volume_24h: str
    timestamp: datetime

Ancestors

  • pydantic.main.BaseModel
  • pydantic.utils.Representation

Class variables

var cmc_name : str
var market_cap : str
var name : str
var percent_24h : Tuple[str, ...]
var percent_30d : Tuple[str, ...]
var percent_7d : Tuple[str, ...]
var price : str
var symbol : str
var timestamp : datetime.datetime
var url : str
var volume_24h : str
class UpcomingSaleData (**data: Any)

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

Expand source code
class UpcomingSaleData(BaseModel):
    name: str
    blockchain: str
    info: str
    discord: str
    twitter: str
    website: str
    sale_on: str
    pre_sale: Optional[str]
    sale: str
    timestamp: datetime

Ancestors

  • pydantic.main.BaseModel
  • pydantic.utils.Representation

Class variables

var blockchain : str
var discord : str
var info : str
var name : str
var pre_sale : Optional[str]
var sale : str
var sale_on : str
var timestamp : datetime.datetime
var twitter : str
var website : str