# 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, StrictBool, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List
from bluefin_pro_api_client.models.market_status import MarketStatus
from typing import Optional, Set
from typing_extensions import Self

class Market(BaseModel):
    """
    Market
    """ # noqa: E501
    symbol: StrictStr = Field(description="Symbol of the market.")
    market_address: StrictStr = Field(description="Market address.", alias="marketAddress")
    status: MarketStatus
    base_asset_symbol: StrictStr = Field(description="Base asset symbol.", alias="baseAssetSymbol")
    base_asset_name: StrictStr = Field(description="Base asset name.", alias="baseAssetName")
    base_asset_decimals: StrictInt = Field(description="Precision of the base asset.", alias="baseAssetDecimals")
    step_size_e9: StrictStr = Field(description="Step size for the quantity (e9 format).", alias="stepSizeE9")
    tick_size_e9: StrictStr = Field(description="Price increment size (e9 format).", alias="tickSizeE9")
    min_order_quantity_e9: StrictStr = Field(description="Minimum order size (e9 format).", alias="minOrderQuantityE9")
    max_limit_order_quantity_e9: StrictStr = Field(description="Maximum limit order size (e9 format).", alias="maxLimitOrderQuantityE9")
    max_market_order_quantity_e9: StrictStr = Field(description="Maximum market order size (e9 format).", alias="maxMarketOrderQuantityE9")
    min_order_price_e9: StrictStr = Field(description="Minimum order price (e9 format).", alias="minOrderPriceE9")
    max_order_price_e9: StrictStr = Field(description="Maximum order price (e9 format).", alias="maxOrderPriceE9")
    maintenance_margin_ratio_e9: StrictStr = Field(description="Maintenance margin ratio (MMR, e9 format).", alias="maintenanceMarginRatioE9")
    initial_margin_ratio_e9: StrictStr = Field(description="Initial margin ratio (IMR), e9 format).", alias="initialMarginRatioE9")
    insurance_pool_ratio_e9: StrictStr = Field(description="Insurance pool ratio (e9 format).", alias="insurancePoolRatioE9")
    default_leverage_e9: StrictStr = Field(description="Default leverage (e9 format).", alias="defaultLeverageE9")
    max_notional_at_open_e9: List[StrictStr] = Field(description="Maximum notional value at current leverage. Index 0 is max notional value for leverage set to 1x, index 1 is for leverage 2x, etc...", alias="maxNotionalAtOpenE9")
    min_trade_quantity_e9: StrictStr = Field(description="Minimum trade quantity allowed (e9 format).", alias="minTradeQuantityE9")
    max_trade_quantity_e9: StrictStr = Field(description="Max trade quantity allowed (e9 format).", alias="maxTradeQuantityE9")
    min_trade_price_e9: StrictStr = Field(description="Minimum trade price allowed (e9 format).", alias="minTradePriceE9")
    max_trade_price_e9: StrictStr = Field(description="Maximum trade price allowed (e9 format).", alias="maxTradePriceE9")
    max_funding_rate_e9: StrictStr = Field(description="Maximum allowed funding rate (e9 format).", alias="maxFundingRateE9")
    default_maker_fee_e9: StrictStr = Field(description="Default maker fee (e9 format).", alias="defaultMakerFeeE9")
    default_taker_fee_e9: StrictStr = Field(description="Default taker fee (e9 format).", alias="defaultTakerFeeE9")
    insurance_pool_address: StrictStr = Field(description="Insurance pool address.", alias="insurancePoolAddress")
    fee_pool_address: StrictStr = Field(description="Fee pool address.", alias="feePoolAddress")
    trading_start_time_at_utc_millis: StrictStr = Field(description="The time when trading will start/have started on the market.", alias="tradingStartTimeAtUtcMillis")
    mtb_long_e9: StrictStr = Field(description="Maximum take bound for long positions (e9 format).", alias="mtbLongE9")
    mtb_short_e9: StrictStr = Field(description="Maximum take bound for short positions (e9 format).", alias="mtbShortE9")
    delisting_price_e9: StrictStr = Field(description="Delisting price (e9 format).", alias="delistingPriceE9")
    isolated_only: StrictBool = Field(description="Indicates whether the market only allows isolated margin.", alias="isolatedOnly")
    __properties: ClassVar[List[str]] = ["symbol", "marketAddress", "status", "baseAssetSymbol", "baseAssetName", "baseAssetDecimals", "stepSizeE9", "tickSizeE9", "minOrderQuantityE9", "maxLimitOrderQuantityE9", "maxMarketOrderQuantityE9", "minOrderPriceE9", "maxOrderPriceE9", "maintenanceMarginRatioE9", "initialMarginRatioE9", "insurancePoolRatioE9", "defaultLeverageE9", "maxNotionalAtOpenE9", "minTradeQuantityE9", "maxTradeQuantityE9", "minTradePriceE9", "maxTradePriceE9", "maxFundingRateE9", "defaultMakerFeeE9", "defaultTakerFeeE9", "insurancePoolAddress", "feePoolAddress", "tradingStartTimeAtUtcMillis", "mtbLongE9", "mtbShortE9", "delistingPriceE9", "isolatedOnly"]

    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 Market 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 Market from a dict"""
        if obj is None:
            return None

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

        _obj = cls.model_validate({
            "symbol": obj.get("symbol"),
            "marketAddress": obj.get("marketAddress"),
            "status": obj.get("status"),
            "baseAssetSymbol": obj.get("baseAssetSymbol"),
            "baseAssetName": obj.get("baseAssetName"),
            "baseAssetDecimals": obj.get("baseAssetDecimals"),
            "stepSizeE9": obj.get("stepSizeE9"),
            "tickSizeE9": obj.get("tickSizeE9"),
            "minOrderQuantityE9": obj.get("minOrderQuantityE9"),
            "maxLimitOrderQuantityE9": obj.get("maxLimitOrderQuantityE9"),
            "maxMarketOrderQuantityE9": obj.get("maxMarketOrderQuantityE9"),
            "minOrderPriceE9": obj.get("minOrderPriceE9"),
            "maxOrderPriceE9": obj.get("maxOrderPriceE9"),
            "maintenanceMarginRatioE9": obj.get("maintenanceMarginRatioE9"),
            "initialMarginRatioE9": obj.get("initialMarginRatioE9"),
            "insurancePoolRatioE9": obj.get("insurancePoolRatioE9"),
            "defaultLeverageE9": obj.get("defaultLeverageE9"),
            "maxNotionalAtOpenE9": obj.get("maxNotionalAtOpenE9"),
            "minTradeQuantityE9": obj.get("minTradeQuantityE9"),
            "maxTradeQuantityE9": obj.get("maxTradeQuantityE9"),
            "minTradePriceE9": obj.get("minTradePriceE9"),
            "maxTradePriceE9": obj.get("maxTradePriceE9"),
            "maxFundingRateE9": obj.get("maxFundingRateE9"),
            "defaultMakerFeeE9": obj.get("defaultMakerFeeE9"),
            "defaultTakerFeeE9": obj.get("defaultTakerFeeE9"),
            "insurancePoolAddress": obj.get("insurancePoolAddress"),
            "feePoolAddress": obj.get("feePoolAddress"),
            "tradingStartTimeAtUtcMillis": obj.get("tradingStartTimeAtUtcMillis"),
            "mtbLongE9": obj.get("mtbLongE9"),
            "mtbShortE9": obj.get("mtbShortE9"),
            "delistingPriceE9": obj.get("delistingPriceE9"),
            "isolatedOnly": obj.get("isolatedOnly")
        })
        return _obj


