Squashed 'utils_v2/' content from commit 97ea8e2e
git-subtree-dir: utils_v2 git-subtree-split: 97ea8e2eee0b34c9bf906d60cd7fe14b4ef82daa
This commit is contained in:
@@ -0,0 +1,132 @@
|
||||
"""
|
||||
|
||||
AUTHOR:
|
||||
|
||||
Khushal P Soonderji
|
||||
|
||||
DATE:
|
||||
|
||||
Wednesday, 30th Oct., 2024.
|
||||
|
||||
OBJECTIVE:
|
||||
|
||||
To provide a data model for describing the API response from Google's APIs.
|
||||
|
||||
REFERENCES:
|
||||
|
||||
N/A
|
||||
|
||||
DOWNLOADS:
|
||||
|
||||
N/A
|
||||
|
||||
"""
|
||||
|
||||
|
||||
# *****************************************************************************************************************
|
||||
# ***** ****
|
||||
# *** IMPORT ***
|
||||
# ***** ****
|
||||
# *****************************************************************************************************************
|
||||
|
||||
|
||||
# To make sibling directories accessible for imports:
|
||||
import sys
|
||||
sys.path.append(".")
|
||||
sys.path.append("..")
|
||||
|
||||
# For making data behaviour_models:
|
||||
from pydantic import BaseModel, Field, field_validator, model_validator
|
||||
from typing import Optional, Literal, Union, Dict, List, Any
|
||||
|
||||
# My utils:
|
||||
from utils_v2.string import json
|
||||
from utils_v2.string import regex
|
||||
|
||||
|
||||
# *****************************************************************************************************************
|
||||
# ***** ****
|
||||
# *** MACROS / ONE-TIME INIT ***
|
||||
# ***** ****
|
||||
# *****************************************************************************************************************
|
||||
|
||||
|
||||
# --- Nothing Yet
|
||||
|
||||
|
||||
# *****************************************************************************************************************
|
||||
# ***** ****
|
||||
# *** VARIABLES ***
|
||||
# ***** ****
|
||||
# *****************************************************************************************************************
|
||||
|
||||
|
||||
# --- Nothing Yet
|
||||
|
||||
|
||||
# *****************************************************************************************************************
|
||||
# ***** ****
|
||||
# *** FUNCTIONS ***
|
||||
# ***** ****
|
||||
# *****************************************************************************************************************
|
||||
|
||||
|
||||
class NSEApiResponse(BaseModel):
|
||||
|
||||
action: str = Field(frozen = False, default = None)
|
||||
|
||||
url: str | None = Field(frozen = True)
|
||||
method: str | None = Field(frozen = True)
|
||||
inputs: Any | None = Field(frozen = True)
|
||||
response: Any = None
|
||||
httpCode: int = None
|
||||
|
||||
success: bool = False
|
||||
message: str = None
|
||||
data: Any = None
|
||||
|
||||
exception: Any = None
|
||||
|
||||
# ┏┓ ┏•
|
||||
# ┃ ┏┓┏┓╋┓┏┓
|
||||
# ┗┛┗┛┛┗┛┗┗┫
|
||||
# ┛
|
||||
|
||||
class Config:
|
||||
extra = "forbid"
|
||||
|
||||
# ┏┓ ┏┓
|
||||
# ┃ ┓┏┏╋┏┓┏┳┓ ┣ ┓┏┏┓┏┏
|
||||
# ┗┛┗┻┛┗┗┛┛┗┗ ┻ ┗┻┛┗┗┛
|
||||
|
||||
def to_markdown(self):
|
||||
if self.exception: message = "❌ *NSE API EXCEPTION:* ❌\n\n"
|
||||
else: message = "*NSE API RESPONSE:*\n\n"
|
||||
message += f"*ACTION:*\n`{self.action}`\n\n"
|
||||
message += f"*URL:*\n`{self.url}`\n\n"
|
||||
message += f"*METHOD:*\n`{self.method}`\n\n"
|
||||
message += f"*RESPONSE:*\n`{self.response}`\n\n"
|
||||
message += f"*SUCCESS:*\n`{self.success}`\n\n"
|
||||
message += f"*MESSAGE:*\n`{self.message}`\n\n"
|
||||
message += f"*EXCEPTION:*\n`{self.exception.__class__.__name__}: {str(self.exception)}`\n\n"
|
||||
return message
|
||||
|
||||
async def get_json(self):
|
||||
try: return self.response.json()
|
||||
except: return {}
|
||||
|
||||
async def get_content(self):
|
||||
try: return self.response.content
|
||||
except: return b""
|
||||
|
||||
|
||||
# *****************************************************************************************************************
|
||||
# ***** ****
|
||||
# *** MAIN PROGRAM ***
|
||||
# ***** ****
|
||||
# *****************************************************************************************************************
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
pass
|
||||
@@ -0,0 +1,396 @@
|
||||
"""
|
||||
|
||||
AUTHOR:
|
||||
|
||||
Khushal P Soonderji
|
||||
|
||||
DATE:
|
||||
|
||||
Thursday, 9th Jan., 2025.
|
||||
|
||||
OBJECTIVE:
|
||||
|
||||
To provide data models for NSE's calendar events.
|
||||
|
||||
REFERENCES:
|
||||
|
||||
N/A
|
||||
|
||||
DOWNLOADS:
|
||||
|
||||
N/A
|
||||
|
||||
"""
|
||||
|
||||
|
||||
# *****************************************************************************************************************
|
||||
# ***** ****
|
||||
# *** IMPORT ***
|
||||
# ***** ****
|
||||
# *****************************************************************************************************************
|
||||
|
||||
|
||||
# To make sibling directories accessible for imports:
|
||||
import sys
|
||||
sys.path.append(".")
|
||||
sys.path.append("..")
|
||||
|
||||
# For making data behaviour_models:
|
||||
from pydantic import BaseModel, Field, field_validator, AwareDatetime, computed_field
|
||||
from typing import Optional, Literal, List
|
||||
|
||||
# My utils:
|
||||
from utils_v2.string import regex
|
||||
from utils_v2.date_time import date_time
|
||||
|
||||
# To work with date and time:
|
||||
import datetime
|
||||
|
||||
|
||||
# *****************************************************************************************************************
|
||||
# ***** ****
|
||||
# *** MACROS / ONE-TIME INIT ***
|
||||
# ***** ****
|
||||
# *****************************************************************************************************************
|
||||
|
||||
|
||||
# --- Nothing Yet
|
||||
|
||||
|
||||
# *****************************************************************************************************************
|
||||
# ***** ****
|
||||
# *** VARIABLES ***
|
||||
# ***** ****
|
||||
# *****************************************************************************************************************
|
||||
|
||||
|
||||
# --- Nothing Yet
|
||||
|
||||
|
||||
# *****************************************************************************************************************
|
||||
# ***** ****
|
||||
# *** FUNCTIONS ***
|
||||
# ***** ****
|
||||
# *****************************************************************************************************************
|
||||
|
||||
|
||||
class NSEHoliday(BaseModel):
|
||||
|
||||
scrapeTs: AwareDatetime = Field(
|
||||
description = "The time (UTC) at which this this data was scraped.",
|
||||
frozen = True,
|
||||
default_factory = lambda: date_time.get_current_utc_date_time(as_string = False)
|
||||
)
|
||||
|
||||
ts: AwareDatetime = Field(
|
||||
description = "The date which is to be recorded as a holiday.",
|
||||
frozen = True
|
||||
)
|
||||
|
||||
tz: str = Field(
|
||||
description = "The timezone in which the date has to be interpreted.",
|
||||
frozen = True,
|
||||
default = "Asia/Kolkata"
|
||||
)
|
||||
|
||||
event: str = Field(
|
||||
description = "The name of the event/occasion.",
|
||||
frozen = True
|
||||
)
|
||||
|
||||
type: List[str] = Field(
|
||||
description = "One or more types of holiday for this event.",
|
||||
frozen = True,
|
||||
examples = ["CBM", "CD", "CM", "CMOT", "COM", "FO", "IRD", "MF", "NDM", "NTRP", "SLBS"]
|
||||
)
|
||||
|
||||
# ┏┓ ┏•
|
||||
# ┃ ┏┓┏┓╋┓┏┓
|
||||
# ┗┛┗┛┛┗┛┗┗┫
|
||||
# ┛
|
||||
|
||||
class Config:
|
||||
extra = "ignore"
|
||||
|
||||
# ┏┓ ┏┓ ┓ ┏┓• ┓ ┓
|
||||
# ┣┫┓┏╋┏┓━━┃ ┏┓┏┳┓┏┓┓┏╋┏┓┏┫ ┣ ┓┏┓┃┏┫┏
|
||||
# ┛┗┗┻┗┗┛ ┗┛┗┛┛┗┗┣┛┗┻┗┗ ┗┻ ┻ ┗┗ ┗┗┻┛
|
||||
# ┛
|
||||
|
||||
@computed_field
|
||||
def year(self) -> int:
|
||||
return self.ts.year
|
||||
|
||||
# ┓┏ ┓• ┓ •
|
||||
# ┃┃┏┓┃┓┏┫┏┓╋┓┏┓┏┓┏
|
||||
# ┗┛┗┻┗┗┗┻┗┻┗┗┗┛┛┗┛
|
||||
|
||||
@field_validator("ts", "scrapeTs", mode = "before")
|
||||
def parse_date_time(cls, value):
|
||||
if isinstance(value, datetime.datetime):
|
||||
value = date_time.to_timezone(value, date_time.TIMEZONE_UTC)
|
||||
return value
|
||||
|
||||
# ┏┓ ┏┓
|
||||
# ┃ ┓┏┏╋┏┓┏┳┓ ┣ ┓┏┏┓┏┏
|
||||
# ┗┛┗┻┛┗┗┛┛┗┗ ┻ ┗┻┛┗┗┛
|
||||
|
||||
def to_json(self) -> dict:
|
||||
return {
|
||||
"event": self.event,
|
||||
"ts": self.ts.timestamp(),
|
||||
"tz": self.tz,
|
||||
"type": self.type
|
||||
}
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class NSECorporateEvent(BaseModel):
|
||||
|
||||
scrapeTs: AwareDatetime = Field(
|
||||
description = "The time (UTC) at which this this data was scraped.",
|
||||
frozen = True,
|
||||
default_factory = lambda: date_time.get_current_utc_date_time(as_string = False)
|
||||
)
|
||||
|
||||
kind: str | None = Field(
|
||||
description = "The type of 'index'.",
|
||||
frozen = True,
|
||||
default = None
|
||||
)
|
||||
|
||||
symbol: str = Field(
|
||||
description = "The trading symbol of the listed entity.",
|
||||
frozen = True
|
||||
)
|
||||
|
||||
name: str = Field(
|
||||
description = "The full name of the listed entity.",
|
||||
frozen = True
|
||||
)
|
||||
|
||||
ts: AwareDatetime = Field(
|
||||
description = "The date (UTC) of the corporate event.",
|
||||
frozen = True
|
||||
)
|
||||
|
||||
tz: str = Field(
|
||||
description = "The timezone in which the date has to be interpreted.",
|
||||
frozen = True,
|
||||
default = "Asia/Kolkata"
|
||||
)
|
||||
|
||||
purpose: str = Field(
|
||||
description = "The type of the event.",
|
||||
frozen = True
|
||||
)
|
||||
|
||||
description: str = Field(
|
||||
description = "A brief description of the event.",
|
||||
frozen = True
|
||||
)
|
||||
|
||||
attachment: str | None = Field(
|
||||
description = "Any file attachment with the event announcement.",
|
||||
frozen = True,
|
||||
default = None
|
||||
)
|
||||
|
||||
# ┏┓ ┏•
|
||||
# ┃ ┏┓┏┓╋┓┏┓
|
||||
# ┗┛┗┛┛┗┛┗┗┫
|
||||
# ┛
|
||||
|
||||
class Config:
|
||||
extra = "ignore"
|
||||
|
||||
# ┏┓ ┏┓ ┓ ┏┓• ┓ ┓
|
||||
# ┣┫┓┏╋┏┓━━┃ ┏┓┏┳┓┏┓┓┏╋┏┓┏┫ ┣ ┓┏┓┃┏┫┏
|
||||
# ┛┗┗┻┗┗┛ ┗┛┗┛┛┗┗┣┛┗┻┗┗ ┗┻ ┻ ┗┗ ┗┗┻┛
|
||||
# ┛
|
||||
|
||||
pass
|
||||
|
||||
# ┓┏ ┓• ┓ •
|
||||
# ┃┃┏┓┃┓┏┫┏┓╋┓┏┓┏┓┏
|
||||
# ┗┛┗┻┗┗┗┻┗┻┗┗┗┛┛┗┛
|
||||
|
||||
@field_validator("ts", "scrapeTs", mode = "before")
|
||||
def parse_date_time(cls, value):
|
||||
if isinstance(value, datetime.datetime):
|
||||
value = date_time.to_timezone(value, date_time.TIMEZONE_UTC)
|
||||
return value
|
||||
|
||||
# ┏┓ ┏┓
|
||||
# ┃ ┓┏┏╋┏┓┏┳┓ ┣ ┓┏┏┓┏┏
|
||||
# ┗┛┗┻┛┗┗┛┛┗┗ ┻ ┗┻┛┗┗┛
|
||||
|
||||
def to_json(self) -> dict:
|
||||
return {
|
||||
"symbol": self.symbol,
|
||||
"name": self.name,
|
||||
"kind": self.kind,
|
||||
"purpose": self.purpose,
|
||||
"description": self.description,
|
||||
"attachment": self.attachment,
|
||||
"ts": self.ts.timestamp(),
|
||||
"tz": self.tz
|
||||
}
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class NSECorporateAction(BaseModel):
|
||||
|
||||
scrapeTs: AwareDatetime = Field(
|
||||
description = "The time (UTC) at which this this data was scraped.",
|
||||
frozen = True,
|
||||
default_factory = lambda: date_time.get_current_utc_date_time(as_string = False)
|
||||
)
|
||||
|
||||
kind: str | None = Field(
|
||||
description = "The type of 'index'.",
|
||||
frozen = True,
|
||||
default = None
|
||||
)
|
||||
|
||||
symbol: str = Field(
|
||||
description = "The trading symbol of the listed entity.",
|
||||
frozen = True
|
||||
)
|
||||
|
||||
name: str = Field(
|
||||
description = "The full name of the listed entity.",
|
||||
frozen = True
|
||||
)
|
||||
|
||||
isin: str = Field(
|
||||
description = "The ISIN code of the listed entity.",
|
||||
frozen = True
|
||||
)
|
||||
|
||||
series: str = Field(
|
||||
description = "The series code of the listed entity.",
|
||||
frozen = True
|
||||
)
|
||||
|
||||
exTs: AwareDatetime | None = Field(
|
||||
description = "The ex-date/ex-dividend-date (UTC) ",
|
||||
frozen = True
|
||||
)
|
||||
|
||||
recTs: AwareDatetime | None = Field(
|
||||
description = "The record date (UTC).",
|
||||
frozen = True
|
||||
)
|
||||
|
||||
bcStartTs: AwareDatetime | None = Field(
|
||||
description = "The book-closure start date (UTC).",
|
||||
frozen = True
|
||||
)
|
||||
|
||||
bcEndTs: AwareDatetime | None = Field(
|
||||
description = "The book-closure end date (UTC).",
|
||||
frozen = True
|
||||
)
|
||||
|
||||
ndStartTs: AwareDatetime | None = Field(
|
||||
description = "The notice-date (start) date (UTC).",
|
||||
frozen = True
|
||||
)
|
||||
|
||||
ndEndTs: AwareDatetime | None = Field(
|
||||
description = "The notice-date (end) date (UTC).",
|
||||
frozen = True
|
||||
)
|
||||
|
||||
caBroadcastTs: AwareDatetime | None = Field(
|
||||
description = "The corporate-action broadcast date (UTC).",
|
||||
frozen = True
|
||||
)
|
||||
|
||||
tz: str = Field(
|
||||
description = "The timezone in which all dates have to be interpreted.",
|
||||
frozen = True,
|
||||
default = "Asia/Kolkata"
|
||||
)
|
||||
|
||||
action: str = Field(
|
||||
description = "The subject of the corporate action.",
|
||||
frozen = True
|
||||
)
|
||||
|
||||
faceVal: float | int = Field(
|
||||
description = "The face-value of the share of the entity.",
|
||||
frozen = True
|
||||
)
|
||||
|
||||
# ┏┓ ┏•
|
||||
# ┃ ┏┓┏┓╋┓┏┓
|
||||
# ┗┛┗┛┛┗┛┗┗┫
|
||||
# ┛
|
||||
|
||||
class Config:
|
||||
extra = "ignore"
|
||||
|
||||
# ┏┓ ┏┓ ┓ ┏┓• ┓ ┓
|
||||
# ┣┫┓┏╋┏┓━━┃ ┏┓┏┳┓┏┓┓┏╋┏┓┏┫ ┣ ┓┏┓┃┏┫┏
|
||||
# ┛┗┗┻┗┗┛ ┗┛┗┛┛┗┗┣┛┗┻┗┗ ┗┻ ┻ ┗┗ ┗┗┻┛
|
||||
# ┛
|
||||
|
||||
pass
|
||||
|
||||
# ┓┏ ┓• ┓ •
|
||||
# ┃┃┏┓┃┓┏┫┏┓╋┓┏┓┏┓┏
|
||||
# ┗┛┗┻┗┗┗┻┗┻┗┗┗┛┛┗┛
|
||||
|
||||
@field_validator(
|
||||
"scrapeTs",
|
||||
"exTs", "recTs",
|
||||
"bcStartTs", "bcEndTs",
|
||||
"ndStartTs", "ndEndTs",
|
||||
"caBroadcastTs",
|
||||
mode = "before"
|
||||
)
|
||||
def parse_date_time(cls, value):
|
||||
if isinstance(value, datetime.datetime):
|
||||
value = date_time.to_timezone(value, date_time.TIMEZONE_UTC)
|
||||
return value
|
||||
|
||||
# ┏┓ ┏┓
|
||||
# ┃ ┓┏┏╋┏┓┏┳┓ ┣ ┓┏┏┓┏┏
|
||||
# ┗┛┗┻┛┗┗┛┛┗┗ ┻ ┗┻┛┗┗┛
|
||||
|
||||
def to_json(self) -> dict:
|
||||
return {
|
||||
"symbol": self.symbol,
|
||||
"name": self.name,
|
||||
"isin": self.isin,
|
||||
"series": self.series,
|
||||
"kind": self.kind,
|
||||
"action": self.action,
|
||||
"faceVal": self.faceVal,
|
||||
"exTs": self.exTs.timestamp() if isinstance(self.exTs, datetime.datetime) else self.exTs,
|
||||
"recTs": self.recTs.timestamp()if isinstance(self.recTs, datetime.datetime) else self.recTs,
|
||||
"bcStartTs": self.bcStartTs.timestamp()if isinstance(self.bcStartTs, datetime.datetime) else self.bcStartTs,
|
||||
"bcEndTs": self.bcEndTs.timestamp()if isinstance(self.bcEndTs, datetime.datetime) else self.bcEndTs,
|
||||
"ndStartTs": self.ndStartTs.timestamp()if isinstance(self.ndStartTs, datetime.datetime) else self.ndStartTs,
|
||||
"ndEndTs": self.ndEndTs.timestamp()if isinstance(self.ndEndTs, datetime.datetime) else self.ndEndTs,
|
||||
"caBroadcastTs": self.caBroadcastTs.timestamp()if isinstance(self.caBroadcastTs, datetime.datetime) else self.caBroadcastTs,
|
||||
"tz": self.tz
|
||||
}
|
||||
|
||||
|
||||
# *****************************************************************************************************************
|
||||
# ***** ****
|
||||
# *** MAIN PROGRAM ***
|
||||
# ***** ****
|
||||
# *****************************************************************************************************************
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
pass
|
||||
@@ -0,0 +1,207 @@
|
||||
"""
|
||||
|
||||
AUTHOR:
|
||||
|
||||
Khushal P Soonderji
|
||||
|
||||
DATE:
|
||||
|
||||
Thursday, 9th Jan., 2025.
|
||||
|
||||
OBJECTIVE:
|
||||
|
||||
To provide data models for NSE's calendar events.
|
||||
|
||||
REFERENCES:
|
||||
|
||||
N/A
|
||||
|
||||
DOWNLOADS:
|
||||
|
||||
N/A
|
||||
|
||||
"""
|
||||
|
||||
|
||||
# *****************************************************************************************************************
|
||||
# ***** ****
|
||||
# *** IMPORT ***
|
||||
# ***** ****
|
||||
# *****************************************************************************************************************
|
||||
|
||||
|
||||
# To make sibling directories accessible for imports:
|
||||
import sys
|
||||
sys.path.append(".")
|
||||
sys.path.append("..")
|
||||
|
||||
# For making data behaviour_models:
|
||||
from pydantic import BaseModel, Field, field_validator, AwareDatetime, computed_field
|
||||
from typing import Optional, Literal, List
|
||||
|
||||
# My utils:
|
||||
from utils_v2.string import regex
|
||||
from utils_v2.date_time import date_time
|
||||
|
||||
# To work with date and time:
|
||||
import datetime
|
||||
|
||||
|
||||
# *****************************************************************************************************************
|
||||
# ***** ****
|
||||
# *** MACROS / ONE-TIME INIT ***
|
||||
# ***** ****
|
||||
# *****************************************************************************************************************
|
||||
|
||||
|
||||
# --- Nothing Yet
|
||||
|
||||
|
||||
# *****************************************************************************************************************
|
||||
# ***** ****
|
||||
# *** VARIABLES ***
|
||||
# ***** ****
|
||||
# *****************************************************************************************************************
|
||||
|
||||
|
||||
# --- Nothing Yet
|
||||
|
||||
|
||||
# *****************************************************************************************************************
|
||||
# ***** ****
|
||||
# *** FUNCTIONS ***
|
||||
# ***** ****
|
||||
# *****************************************************************************************************************
|
||||
|
||||
|
||||
class NSEIPO(BaseModel):
|
||||
|
||||
scrapeTs: AwareDatetime = Field(
|
||||
description = "The time (UTC) at which this this data was scraped.",
|
||||
frozen = True,
|
||||
default_factory = lambda: date_time.get_current_utc_date_time(as_string = False)
|
||||
)
|
||||
|
||||
issueStartTs: AwareDatetime = Field(
|
||||
description = "The start date (UTC) of the issue.",
|
||||
frozen = True
|
||||
)
|
||||
|
||||
issueEndTs: AwareDatetime = Field(
|
||||
description = "The end date (UTC) of the issue.",
|
||||
frozen = True
|
||||
)
|
||||
|
||||
listingTs: AwareDatetime | None = Field(
|
||||
description = "The date when the company was listed on the exchange.",
|
||||
frozen = True,
|
||||
default = None
|
||||
)
|
||||
|
||||
tz: str = Field(
|
||||
description = "The timezone in which the dates have to be interpreted.",
|
||||
frozen = True,
|
||||
default = "Asia/Kolkata"
|
||||
)
|
||||
|
||||
symbol: str = Field(
|
||||
description = "The trading symbol of this listing.",
|
||||
frozen = True
|
||||
)
|
||||
|
||||
name: str = Field(
|
||||
description = "The name of the parent company of this listing.",
|
||||
frozen = True
|
||||
)
|
||||
|
||||
status: str = Field(
|
||||
description = "Whether this IPO is active or has closed.",
|
||||
frozen = True
|
||||
)
|
||||
|
||||
kind: str | None = Field(
|
||||
description = "The category under which this IPO falls.",
|
||||
frozen = True,
|
||||
default = None,
|
||||
examples = ["SME", "EQ", "DEBT"]
|
||||
)
|
||||
|
||||
upperBand: float | None = Field(
|
||||
description = "The upper price of the price band.",
|
||||
frozen = True,
|
||||
default = None
|
||||
)
|
||||
|
||||
lowerBand: float | None = Field(
|
||||
description = "The lower price of the price band.",
|
||||
frozen = True,
|
||||
default = None
|
||||
)
|
||||
|
||||
issuePrice: float | None = Field(
|
||||
description = "The final price at which the shares were sold.",
|
||||
frozen = True,
|
||||
default = None
|
||||
)
|
||||
|
||||
offerQty: int | None = Field(
|
||||
description = "How many shares are being offered for sale by the parent.",
|
||||
frozen = True,
|
||||
default = None
|
||||
)
|
||||
|
||||
bidQty: int | None = Field(
|
||||
description = "How many shares investors are willing to buy.",
|
||||
frozen = True,
|
||||
default = None
|
||||
)
|
||||
|
||||
bidFactor: float | None = Field(
|
||||
description = "How many times over has the IPO been subscribed.",
|
||||
frozen = True,
|
||||
default = None
|
||||
)
|
||||
|
||||
# ┏┓ ┏•
|
||||
# ┃ ┏┓┏┓╋┓┏┓
|
||||
# ┗┛┗┛┛┗┛┗┗┫
|
||||
# ┛
|
||||
|
||||
class Config:
|
||||
extra = "ignore"
|
||||
|
||||
# ┏┓ ┏┓ ┓ ┏┓• ┓ ┓
|
||||
# ┣┫┓┏╋┏┓━━┃ ┏┓┏┳┓┏┓┓┏╋┏┓┏┫ ┣ ┓┏┓┃┏┫┏
|
||||
# ┛┗┗┻┗┗┛ ┗┛┗┛┛┗┗┣┛┗┻┗┗ ┗┻ ┻ ┗┗ ┗┗┻┛
|
||||
# ┛
|
||||
|
||||
pass
|
||||
|
||||
# ┓┏ ┓• ┓ •
|
||||
# ┃┃┏┓┃┓┏┫┏┓╋┓┏┓┏┓┏
|
||||
# ┗┛┗┻┗┗┗┻┗┻┗┗┗┛┛┗┛
|
||||
|
||||
@field_validator("scrapeTs", "issueStartTs", "issueEndTs", mode = "before")
|
||||
def parse_date_time(cls, value):
|
||||
if isinstance(value, datetime.datetime):
|
||||
value = date_time.to_timezone(value, date_time.TIMEZONE_UTC)
|
||||
return value
|
||||
|
||||
# ┏┓ ┏┓
|
||||
# ┃ ┓┏┏╋┏┓┏┳┓ ┣ ┓┏┏┓┏┏
|
||||
# ┗┛┗┻┛┗┗┛┛┗┗ ┻ ┗┻┛┗┗┛
|
||||
|
||||
def to_json(self) -> dict:
|
||||
return self.model_dump()
|
||||
|
||||
|
||||
# *****************************************************************************************************************
|
||||
# ***** ****
|
||||
# *** MAIN PROGRAM ***
|
||||
# ***** ****
|
||||
# *****************************************************************************************************************
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
pass
|
||||
Reference in New Issue
Block a user