# coding: utf-8

"""
    Bluefin API

    Bluefin API

    The version of the OpenAPI document: 1.0.0
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


from __future__ import annotations
import pprint
import re  # noqa: F401
import json

from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List
from typing import Optional, Set
from typing_extensions import Self

class CandlestickUpdate(BaseModel):
    """
    Represents a candlestick for a specific market and interval.
    """ # noqa: E501
    market_address: StrictStr = Field(description="The identifier of the market for this candlestick.", alias="marketAddress")
    start_time: StrictInt = Field(description="The start time of the candlestick in milliseconds since epoch.", alias="startTime")
    end_time: StrictInt = Field(description="The end time of the candlestick in milliseconds since epoch.", alias="endTime")
    interval: StrictStr = Field(description="The interval of the candlestick (e.g., 1m, 5m, 1h).")
    open_price_e9: StrictStr = Field(description="The opening price of the candlestick.", alias="openPriceE9")
    close_price_e9: StrictStr = Field(description="The closing price of the candlestick.", alias="closePriceE9")
    high_price_e9: StrictStr = Field(description="The highest price during the candlestick interval.", alias="highPriceE9")
    low_price_e9: StrictStr = Field(description="The lowest price during the candlestick interval.", alias="lowPriceE9")
    volume_e9: StrictStr = Field(description="The total trading volume during the candlestick interval.", alias="volumeE9")
    quote_volume_e9: StrictStr = Field(description="The total quote volume traded during the candlestick interval.", alias="quoteVolumeE9")
    num_trades: StrictInt = Field(description="The number of trades that occurred during the candlestick interval.", alias="numTrades")
    __properties: ClassVar[List[str]] = ["marketAddress", "startTime", "endTime", "interval", "openPriceE9", "closePriceE9", "highPriceE9", "lowPriceE9", "volumeE9", "quoteVolumeE9", "numTrades"]

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )


    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.model_dump(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of CandlestickUpdate from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self) -> Dict[str, Any]:
        """Return the dictionary representation of the model using alias.

        This has the following differences from calling pydantic's
        `self.model_dump(by_alias=True)`:

        * `None` is only added to the output dict for nullable fields that
          were set at model initialization. Other fields with value `None`
          are ignored.
        """
        excluded_fields: Set[str] = set([
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of CandlestickUpdate from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        _obj = cls.model_validate({
            "marketAddress": obj.get("marketAddress"),
            "startTime": obj.get("startTime"),
            "endTime": obj.get("endTime"),
            "interval": obj.get("interval"),
            "openPriceE9": obj.get("openPriceE9"),
            "closePriceE9": obj.get("closePriceE9"),
            "highPriceE9": obj.get("highPriceE9"),
            "lowPriceE9": obj.get("lowPriceE9"),
            "volumeE9": obj.get("volumeE9"),
            "quoteVolumeE9": obj.get("quoteVolumeE9"),
            "numTrades": obj.get("numTrades")
        })
        return _obj


