Path: blob/master/ invest-robot-contest_tinkoff-contest-python-main/src/containers/market.py
5935 views
from dataclasses import dataclass1from typing import List23from tinkoff.invest import (4HistoricCandle,5MoneyValue,6Order,7OrderDirection,8OrderState,9OrderType,10PositionsSecurities,11Quotation,12)131415@dataclass(frozen=True)16class TraderDecision:17"""Base type for the trader decision"""1819pass202122class CreateOrder(TraderDecision):23"""Trader decision to create a new order with the given parameters"""2425order_type: OrderType26order_direction: OrderDirection27price: Quotation28quantity: int293031class CancelOrder(TraderDecision):32"""Trader decision to cancel the not fulfilled order with the given `order_id`"""3334order_id: str353637@dataclass(frozen=True)38class MarketData:39"""Market data for an asset"""4041bids: List[Order]42asks: List[Order]43candles: List[HistoricCandle]444546@dataclass(frozen=True)47class AccountBalance:48"""Balance on the current account"""4950money: List[MoneyValue]51securities: List[PositionsSecurities]525354@dataclass(frozen=True)55class MarketState:56"""Current state used by traders to make a decision"""5758account_balance: AccountBalance59market_data: MarketData60opened_orders: List[OrderState]616263