-
Notifications
You must be signed in to change notification settings - Fork 1
/
tradeTypes.py
72 lines (59 loc) · 1.26 KB
/
tradeTypes.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
from dataclasses import dataclass
from datetime import datetime
from enum import Enum
from typing import Optional
class TradeType(Enum):
BUY = 1
SELL = 2
SHORT_SELL = 3
STOP = 4
COVER = 5
GTC = 6
Cancel = 7
MARKET_BUY = 8
MARKET_SELL = 9
SHORT_COVER = 10
LIMIT_BUY = 11
LIMIT_SELL = 12
class InsufficientFundsError(Exception):
pass
class InsufficientSharesError(Exception):
pass
class InvalidCommissionTypeError(Exception):
pass
class InvalidOrderError(Exception):
pass
class ShortPositionError(Exception):
pass
@dataclass
class Holding:
tradeType: TradeType
ticker: str
commission: float
executedSuccessfully: bool
numShares: int
totalCost: float
entryPrice: float
shortPosition: bool = False
@dataclass
class Transaction:
tradeType: TradeType
ticker: str
commission: float
executedSuccessfully: bool
numShares: int
pricePerShare: float
totalCost: float
date: datetime
profitLoss: float = 0.0
notes: str = ""
@dataclass
class Order:
tradeType: TradeType
ticker: str
numShares: int
targetPrice: float
duration: str # 'DAY' or 'GTC'
orderDate: datetime
active: bool = True
limitPrice: Optional[float] = None