0
# Trading Analytics
1
2
The Trading class provides market trading statistics, order book data, foreign and proprietary trading flows, insider transactions, and various trading-related metrics for Vietnamese securities markets.
3
4
## Capabilities
5
6
### Trading Class
7
8
Adapter for trading data and market statistics with comprehensive analytics capabilities.
9
10
```python { .api }
11
class Trading:
12
"""
13
Trading data adapter for market statistics and trading analytics.
14
15
Supported sources: VCI, TCBS
16
"""
17
18
def __init__(self, source: str = "vci", symbol: str = "", random_agent: bool = False, show_log: bool = False):
19
"""
20
Initialize Trading data adapter.
21
22
Args:
23
source (str): Data source ("vci", "tcbs"), defaults to "vci"
24
symbol (str): Default symbol for operations, defaults to ""
25
random_agent (bool): Use random user agent, defaults to False
26
show_log (bool): Enable logging, defaults to False
27
"""
28
```
29
30
### Trading Statistics
31
32
Market trading statistics including volume, value, and participation metrics.
33
34
```python { .api }
35
def trading_stats(self, *args, **kwargs) -> pd.DataFrame:
36
"""
37
Get comprehensive trading statistics.
38
39
Returns:
40
pd.DataFrame: Trading statistics including volume, value, and market metrics
41
"""
42
43
def side_stats(self, *args, **kwargs) -> pd.DataFrame:
44
"""
45
Get bid/ask side trading statistics.
46
47
Returns:
48
pd.DataFrame: Bid/ask side trading data and imbalances
49
"""
50
51
def price_board(self, *args, **kwargs) -> pd.DataFrame:
52
"""
53
Get price board (order book) for symbols list.
54
55
Returns:
56
pd.DataFrame: Current market prices and order book data
57
"""
58
59
def price_history(self, *args, **kwargs) -> pd.DataFrame:
60
"""
61
Get price history for multiple symbols.
62
63
Returns:
64
pd.DataFrame: Multi-symbol price history data
65
"""
66
```
67
68
### Trading Flows
69
70
Specialized trading flow analysis including foreign and proprietary trading.
71
72
```python { .api }
73
def foreign_trade(self, *args, **kwargs) -> pd.DataFrame:
74
"""
75
Get foreign trading flow data.
76
77
Returns:
78
pd.DataFrame: Foreign investor trading activity
79
"""
80
81
def prop_trade(self, *args, **kwargs) -> pd.DataFrame:
82
"""
83
Get proprietary trading data.
84
85
Returns:
86
pd.DataFrame: Proprietary trading firm activity
87
"""
88
89
def insider_deal(self, *args, **kwargs) -> pd.DataFrame:
90
"""
91
Get insider trading transactions.
92
93
Returns:
94
pd.DataFrame: Insider dealing activity and disclosures
95
"""
96
97
def order_stats(self, *args, **kwargs) -> pd.DataFrame:
98
"""
99
Get order statistics and market microstructure data.
100
101
Returns:
102
pd.DataFrame: Order flow statistics and execution metrics
103
"""
104
```
105
106
## Usage Examples
107
108
```python
109
from vnstock import Trading
110
111
# Initialize trading adapter
112
trading = Trading(source="vci", symbol="TCB")
113
114
# Get trading statistics
115
stats = trading.trading_stats(symbol="TCB")
116
117
# Get foreign trading flows
118
foreign_flows = trading.foreign_trade(symbol="VCB")
119
120
# Get insider trading data
121
insider_data = trading.insider_deal(symbol="HPG")
122
123
# Get order book data
124
order_book = trading.price_board(symbols=["TCB", "VCB", "BID"])
125
```