Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions pykis/adapter/account/balance.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

__all__ = [
"KisQuotableAccount",
"KisQuotableAccountImpl",
"KisQuotableAccountMixin",
]


Expand All @@ -36,7 +36,7 @@ def balance(
KisAPIError: API 호출에 실패한 경우
ValueError: 계좌번호가 잘못된 경우
"""
raise NotImplementedError
...

def daily_orders(
self: KisAccountProtocol,
Expand All @@ -59,7 +59,7 @@ def daily_orders(
KisAPIError: API 호출에 실패한 경우
ValueError: 계좌번호가 잘못된 경우
"""
raise NotImplementedError
...

def profits(
self: KisAccountProtocol,
Expand All @@ -84,10 +84,10 @@ def profits(
KisAPIError: API 호출에 실패한 경우
ValueError: 계좌번호가 잘못된 경우
"""
raise NotImplementedError
...


class KisQuotableAccountImpl:
class KisQuotableAccountMixin:
"""한국투자증권 잔고조회가능 프로토콜"""

from pykis.api.account.balance import account_balance as balance # 잔고 조회
Expand Down
26 changes: 13 additions & 13 deletions pykis/adapter/account/order.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from types import EllipsisType
from typing import TYPE_CHECKING, Protocol, runtime_checkable

from pykis.api.account.order import (
Expand All @@ -13,14 +14,13 @@
from pykis.api.account.pending_order import KisPendingOrders
from pykis.api.stock.info import COUNTRY_TYPE
from pykis.api.stock.market import MARKET_TYPE
from pykis.utils.params import EMPTY, EMPTY_TYPE

if TYPE_CHECKING:
from pykis.api.base.account import KisAccountProtocol

__all__ = [
"KisOrderableAccount",
"KisOrderableAccountImpl",
"KisOrderableAccountMixin",
]


Expand Down Expand Up @@ -95,7 +95,7 @@ def buy(
KisMarketNotOpenedError: 시장이 열리지 않은 경우
ValueError: 종목 코드가 올바르지 않은 경우
"""
raise NotImplementedError
...

def sell(
self: "KisAccountProtocol",
Expand Down Expand Up @@ -164,7 +164,7 @@ def sell(
KisMarketNotOpenedError: 시장이 열리지 않은 경우
ValueError: 종목 코드가 올바르지 않은 경우
"""
raise NotImplementedError
...

def order(
self: "KisAccountProtocol",
Expand Down Expand Up @@ -269,15 +269,15 @@ def order(
KisMarketNotOpenedError: 시장이 열리지 않은 경우
ValueError: 종목 코드가 올바르지 않은 경우
"""
raise NotImplementedError
...

def modify(
self: "KisAccountProtocol",
order: KisOrderNumber,
price: ORDER_PRICE | None | EMPTY_TYPE = EMPTY,
price: ORDER_PRICE | None | EllipsisType = ...,
qty: IN_ORDER_QUANTITY | None = None,
condition: ORDER_CONDITION | None | EMPTY_TYPE = EMPTY,
execution: ORDER_EXECUTION | None | EMPTY_TYPE = EMPTY,
condition: ORDER_CONDITION | None | EllipsisType = ...,
execution: ORDER_EXECUTION | None | EllipsisType = ...,
) -> KisOrder:
"""
한국투자증권 통합 주식 주문정정 (국내 모의투자 미지원, 해외 주간거래 모의투자 미지원)
Expand All @@ -294,7 +294,7 @@ def modify(
condition (ORDER_CONDITION, optional): 주문조건
execution (ORDER_EXECUTION_CONDITION, optional): 체결조건
"""
raise NotImplementedError
...

def cancel(
self: "KisAccountProtocol",
Expand All @@ -311,7 +311,7 @@ def cancel(
account (str | KisAccountNumber): 계좌번호
order (KisOrderNumber): 주문번호
"""
raise NotImplementedError
...

def orderable_amount(
self: "KisAccountProtocol",
Expand Down Expand Up @@ -373,7 +373,7 @@ def orderable_amount(
KisNotFoundError: 조회 결과가 없는 경우
ValueError: 주문조건이 잘못된 경우
"""
raise NotImplementedError
...

def pending_orders(
self: "KisAccountProtocol",
Expand All @@ -393,10 +393,10 @@ def pending_orders(
KisAPIError: API 호출에 실패한 경우
ValueError: 계좌번호가 잘못된 경우
"""
raise NotImplementedError
...


class KisOrderableAccountImpl:
class KisOrderableAccountMixin:
"""한국투자증권 주문가능 잔고 프로토콜"""

from pykis.api.account.order import account_buy as buy # 매수
Expand Down
22 changes: 11 additions & 11 deletions pykis/adapter/account_product/order.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

__all__ = [
"KisOrderableAccountProduct",
"KisOrderableAccountProductImpl",
"KisOrderableAccountProductMixin",
]


Expand Down Expand Up @@ -123,7 +123,7 @@ def order(
KisMarketNotOpenedError: 시장이 열리지 않은 경우
ValueError: 종목 코드가 올바르지 않은 경우
"""
raise NotImplementedError
...

def buy(
self: "KisAccountProductProtocol",
Expand Down Expand Up @@ -188,7 +188,7 @@ def buy(
KisMarketNotOpenedError: 시장이 열리지 않은 경우
ValueError: 종목 코드가 올바르지 않은 경우
"""
raise NotImplementedError
...

def sell(
self: "KisAccountProductProtocol",
Expand Down Expand Up @@ -253,7 +253,7 @@ def sell(
KisMarketNotOpenedError: 시장이 열리지 않은 경우
ValueError: 종목 코드가 올바르지 않은 경우
"""
raise NotImplementedError
...

def orderable_amount(
self: "KisAccountProductProtocol",
Expand Down Expand Up @@ -311,7 +311,7 @@ def orderable_amount(
KisNotFoundError: 조회 결과가 없는 경우
ValueError: 주문조건이 잘못된 경우
"""
raise NotImplementedError
...

def pending_orders(self: "KisAccountProductProtocol") -> KisPendingOrders:
"""
Expand All @@ -324,7 +324,7 @@ def pending_orders(self: "KisAccountProductProtocol") -> KisPendingOrders:
KisAPIError: API 호출에 실패한 경우
ValueError: 계좌번호가 잘못된 경우
"""
raise NotImplementedError
...

@property
def quantity(self) -> ORDER_QUANTITY:
Expand All @@ -334,7 +334,7 @@ def quantity(self) -> ORDER_QUANTITY:
Returns:
ORDER_QUANTITY: 보유수량
"""
raise NotImplementedError
...

@property
def qty(self) -> ORDER_QUANTITY:
Expand All @@ -344,7 +344,7 @@ def qty(self) -> ORDER_QUANTITY:
Returns:
ORDER_QUANTITY: 보유수량
"""
raise NotImplementedError
...

@property
def orderable(self) -> ORDER_QUANTITY:
Expand All @@ -354,7 +354,7 @@ def orderable(self) -> ORDER_QUANTITY:
Returns:
ORDER_QUANTITY: 주문 가능 수량
"""
raise NotImplementedError
...

@property
def purchase_amount(self) -> ORDER_PRICE:
Expand All @@ -364,10 +364,10 @@ def purchase_amount(self) -> ORDER_PRICE:
Returns:
ORDER_PRICE: 주문 가능 금액
"""
raise NotImplementedError
...


class KisOrderableAccountProductImpl:
class KisOrderableAccountProductMixin:
"""한국투자증권 주문가능 상품"""

from pykis.api.account.order import account_product_buy as buy # 매수
Expand Down
34 changes: 21 additions & 13 deletions pykis/adapter/account_product/order_modify.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from types import EllipsisType
from typing import TYPE_CHECKING, Protocol, runtime_checkable

from pykis.utils.params import EMPTY, EMPTY_TYPE

if TYPE_CHECKING:
from pykis.api.account.order import (
IN_ORDER_QUANTITY,
Expand All @@ -12,6 +11,15 @@
KisOrderNumber,
)

__all__ = [
"KisCancelableOrder",
"KisModifyableOrder",
"KisOrderableOrder",
"KisCancelableOrderMixin",
"KisModifyableOrderMixin",
"KisOrderableOrderMixin",
]


@runtime_checkable
class KisCancelableOrder(Protocol):
Expand All @@ -24,18 +32,18 @@ def cancel(self) -> "KisOrder":
국내주식주문 -> 주식주문(정정취소)[v1_국내주식-003]
국내주식주문 -> 해외주식 정정취소주문[v1_해외주식-003]
"""
raise NotImplementedError
...


class KisModifyableOrder(Protocol):
"""정정 가능 주문 프로토콜"""

def modify(
self,
price: "ORDER_PRICE | None | EMPTY_TYPE" = EMPTY,
price: "ORDER_PRICE | None | EllipsisType" = ...,
qty: "IN_ORDER_QUANTITY | None" = None,
condition: "ORDER_CONDITION | None | EMPTY_TYPE" = EMPTY,
execution: "ORDER_EXECUTION | None | EMPTY_TYPE" = EMPTY,
condition: "ORDER_CONDITION | None | EllipsisType" = ...,
execution: "ORDER_EXECUTION | None | EllipsisType" = ...,
) -> "KisOrder":
"""
한국투자증권 통합 주식 주문정정 (국내 모의투자 미지원, 해외 주간거래 모의투자 미지원)
Expand All @@ -49,15 +57,15 @@ def modify(
condition (ORDER_CONDITION, optional): 주문조건
execution (ORDER_EXECUTION_CONDITION, optional): 체결조건
"""
raise NotImplementedError
...


@runtime_checkable
class KisOrderableOrder(KisCancelableOrder, KisModifyableOrder, Protocol):
"""주문 가능 주문 프로토콜"""


class KisCancelableOrderImpl:
class KisCancelableOrderMixin:
"""취소 가능 주문"""

def cancel(
Expand All @@ -74,15 +82,15 @@ def cancel(
return cancel_order(self.kis, order=self)


class KisModifyableOrderImpl:
class KisModifyableOrderMixin:
"""정정 가능 주문"""

def modify(
self: "KisOrderNumber",
price: "ORDER_PRICE | None | EMPTY_TYPE" = EMPTY,
price: "ORDER_PRICE | None | EllipsisType" = ...,
qty: "IN_ORDER_QUANTITY | None" = None,
condition: "ORDER_CONDITION | None | EMPTY_TYPE" = EMPTY,
execution: "ORDER_EXECUTION | None | EMPTY_TYPE" = EMPTY,
condition: "ORDER_CONDITION | None | EllipsisType" = ...,
execution: "ORDER_EXECUTION | None | EllipsisType" = ...,
) -> "KisOrder":
"""
한국투자증권 통합 주식 주문정정 (국내 모의투자 미지원, 해외 주간거래 모의투자 미지원)
Expand All @@ -108,5 +116,5 @@ def modify(
)


class KisOrderableOrderImpl(KisCancelableOrderImpl, KisModifyableOrderImpl):
class KisOrderableOrderMixin(KisCancelableOrderMixin, KisModifyableOrderMixin):
"""주문 가능 주문"""
14 changes: 7 additions & 7 deletions pykis/adapter/product/quote.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

__all__ = [
"KisQuotableProduct",
"KisQuotableProductImpl",
"KisQuotableProductMixin",
]


Expand Down Expand Up @@ -42,7 +42,7 @@ def daily_chart(
KisNotFoundError: 조회 결과가 없는 경우
ValueError: 조회 파라미터가 올바르지 않은 경우
"""
raise NotImplementedError
...

def day_chart(
self,
Expand All @@ -69,7 +69,7 @@ def day_chart(
KisNotFoundError: 조회 결과가 없는 경우
ValueError: 조회 파라미터가 올바르지 않은 경우
"""
raise NotImplementedError
...

def orderbook(
self,
Expand All @@ -89,7 +89,7 @@ def orderbook(
KisNotFoundError: 조회 결과가 없는 경우
ValueError: 종목 코드가 올바르지 않은 경우
"""
raise NotImplementedError
...

def quote(
self,
Expand All @@ -109,7 +109,7 @@ def quote(
KisNotFoundError: 조회 결과가 없는 경우
ValueError: 종목 코드가 올바르지 않은 경우
"""
raise NotImplementedError
...

def chart(
self: KisProductProtocol,
Expand Down Expand Up @@ -152,10 +152,10 @@ def chart(
KisNotFoundError: 조회 결과가 없는 경우
ValueError: 조회 파라미터가 올바르지 않은 경우
"""
raise NotImplementedError
...


class KisQuotableProductImpl:
class KisQuotableProductMixin:
"""한국투자증권 시세조회가능 상품 프로토콜"""

from pykis.api.stock.daily_chart import product_daily_chart as daily_chart # 일봉 조회
Expand Down
Loading