You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

38 lines
767 B

"""Some orders on the market."""
from dataclasses import dataclass
from .interfaces import Order
@dataclass
class Long(Order):
"""Buy stock."""
stock: str
amount: float
price: float
@property
def amount_usd(self) -> float:
"""The amount in $"""
return self.amount * self.price
def __repr__(self) -> str:
return f"{self.__class__.__name__}({self.stock}: {self.amount_usd}$)"
@dataclass
class Short(Order):
"""Buy stock."""
stock: str
amount: float
price: float
@property
def amount_usd(self) -> float:
"""The amount in $"""
return self.amount * self.price
def __repr__(self) -> str:
return f"{self.__class__.__name__}({self.stock}: {self.amount_usd}$)"