Skip to content

Commit

Permalink
add MarketWatchAll model
Browse files Browse the repository at this point in the history
  • Loading branch information
yghaderi committed Apr 14, 2024
1 parent 91e0fe4 commit 0275548
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 33 deletions.
12 changes: 12 additions & 0 deletions oxtapus/models/tsetmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ class MarketWatchOrderBook(BaseModel):
ask_count: int = Field(alias="zmo")


class MarketWatchAll(BaseModel):
ins_code: str = Field(alias="insCode")
buy_vol_ind: float = Field(alias="buy_I_Volume")
buy_vol_ins: float = Field(alias="buy_N_Volume")
buy_count_ind: int = Field(alias="buy_CountI")
buy_count_ins: int = Field(alias="buy_CountN")
sell_vol_ind: float = Field(alias="sell_I_Volume")
sell_vol_ins: float = Field(alias="sell_N_Volume")
sell_count_ind: int = Field(alias="sell_CountI")
sell_count_ins: int = Field(alias="sell_CountN")


class MarketWatch(BaseModel):
ins_code: str = Field(alias="insCode")
ins_id: str = Field(alias="insID")
Expand Down
69 changes: 36 additions & 33 deletions oxtapus/tsetmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ def mw(self, sections: List[MWSections] | MWSections) -> str:
}
return f"{self.base_url}/ClosingPrice/GetMarketWatch?{urlencode(param)}"

def client_type(self):
return f"{self.base_url}/ClientType/GetClientTypeAll"

def search_ins_code(self, symbol_far) -> str:
"""
.. raw:: html
Expand Down Expand Up @@ -437,7 +440,7 @@ def search_ins_code(self, symbol: str) -> list[str]:
i["insCode"]
for i in r
if (word_normalize(i["lVal18AFC"]) == word_normalize(symbol))
and (i["lastDate"] == 1)
and (i["lastDate"] == 1)
]
return [
i["insCode"]
Expand All @@ -462,9 +465,9 @@ def wrapper(self, symbol=None, ins_code=None):

@_handle_ins_cod_or_symbol
def ins_info(
self,
symbol: str | list[str] | None = None,
ins_code: str | list[str] | None = None,
self,
symbol: str | list[str] | None = None,
ins_code: str | list[str] | None = None,
) -> pl.DataFrame:
"""
.. raw:: html
Expand Down Expand Up @@ -620,11 +623,11 @@ def specific_option_data(self, ins_id: str | list[str]) -> pl.DataFrame:

@_handle_ins_cod_or_symbol
def hist_price(
self,
symbol: str | list[str] | None = None,
ins_code: str | list[str] | None = None,
start: str | None = None,
end: str | None = None,
self,
symbol: str | list[str] | None = None,
ins_code: str | list[str] | None = None,
start: str | None = None,
end: str | None = None,
) -> pl.DataFrame:
"""
.. raw:: html
Expand Down Expand Up @@ -740,11 +743,11 @@ def hist_price(

@_handle_ins_cod_or_symbol
def adj_hist_price(
self,
symbol: str | list[str] | None = None,
ins_code: str | list[str] | None = None,
start: str | None = None,
end: str | None = None,
self,
symbol: str | list[str] | None = None,
ins_code: str | list[str] | None = None,
start: str | None = None,
end: str | None = None,
) -> pl.DataFrame:
"""
.. raw:: html
Expand Down Expand Up @@ -852,9 +855,9 @@ def adj_hist_price(

@_handle_ins_cod_or_symbol
def intraday_trades(
self,
symbol: str | list[str] | None = None,
ins_code: str | list[str] | None = None,
self,
symbol: str | list[str] | None = None,
ins_code: str | list[str] | None = None,
) -> pl.DataFrame:
"""
.. raw:: html
Expand Down Expand Up @@ -925,10 +928,10 @@ def intraday_trades(
return df

def intraday_trades_based_on_timeframe(
self,
symbol: str | list[str] | None = None,
ins_code: str | list[str] | None = None,
timeframe: str = "5m",
self,
symbol: str | list[str] | None = None,
ins_code: str | list[str] | None = None,
timeframe: str = "5m",
) -> pl.DataFrame:
"""
.. raw:: html
Expand Down Expand Up @@ -991,9 +994,9 @@ def intraday_trades_based_on_timeframe(

@_handle_ins_cod_or_symbol
def last_ins_data(
self,
symbol: str | list[str] | None = None,
ins_code: str | list[str] | None = None,
self,
symbol: str | list[str] | None = None,
ins_code: str | list[str] | None = None,
) -> pl.DataFrame:
"""
.. raw:: html
Expand Down Expand Up @@ -1081,9 +1084,9 @@ def last_ins_data(

@_handle_ins_cod_or_symbol
def client_type(
self,
symbol: str | list[str] | None = None,
ins_code: str | list[str] | None = None,
self,
symbol: str | list[str] | None = None,
ins_code: str | list[str] | None = None,
) -> pl.DataFrame:
"""
.. raw:: html
Expand Down Expand Up @@ -1172,9 +1175,9 @@ def client_type(

@_handle_ins_cod_or_symbol
def share_change(
self,
symbol: str | list[str] | None = None,
ins_code: str | list[str] | None = None,
self,
symbol: str | list[str] | None = None,
ins_code: str | list[str] | None = None,
) -> pl.DataFrame:
"""
.. raw:: html
Expand Down Expand Up @@ -1425,9 +1428,9 @@ def last_market_activity_datetime(self):

@_handle_ins_cod_or_symbol
def shareholder_list(
self,
symbol: str | list[str] | None = None,
ins_code: str | list[str] | None = None,
self,
symbol: str | list[str] | None = None,
ins_code: str | list[str] | None = None,
) -> pl.DataFrame:
"""
.. raw:: html
Expand Down

0 comments on commit 0275548

Please sign in to comment.