Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wiseplat
GitHub Repository: wiseplat/python-code
Path: blob/master/ invest-robot-contest_tinkoff-contest-python-main/src/containers/market.py
5935 views
1
from dataclasses import dataclass
2
from typing import List
3
4
from tinkoff.invest import (
5
HistoricCandle,
6
MoneyValue,
7
Order,
8
OrderDirection,
9
OrderState,
10
OrderType,
11
PositionsSecurities,
12
Quotation,
13
)
14
15
16
@dataclass(frozen=True)
17
class TraderDecision:
18
"""Base type for the trader decision"""
19
20
pass
21
22
23
class CreateOrder(TraderDecision):
24
"""Trader decision to create a new order with the given parameters"""
25
26
order_type: OrderType
27
order_direction: OrderDirection
28
price: Quotation
29
quantity: int
30
31
32
class CancelOrder(TraderDecision):
33
"""Trader decision to cancel the not fulfilled order with the given `order_id`"""
34
35
order_id: str
36
37
38
@dataclass(frozen=True)
39
class MarketData:
40
"""Market data for an asset"""
41
42
bids: List[Order]
43
asks: List[Order]
44
candles: List[HistoricCandle]
45
46
47
@dataclass(frozen=True)
48
class AccountBalance:
49
"""Balance on the current account"""
50
51
money: List[MoneyValue]
52
securities: List[PositionsSecurities]
53
54
55
@dataclass(frozen=True)
56
class MarketState:
57
"""Current state used by traders to make a decision"""
58
59
account_balance: AccountBalance
60
market_data: MarketData
61
opened_orders: List[OrderState]
62
63