Dữ liệu cổ phiếu

xnoapi.vn.data.stocks

Danh sách cổ phiếu thanh khoản

list_liquid_asset()

Trả về danh sách cổ phiếu có tính thanh khoản cao trên thị trường Việt Nam.

Trả về:

DataFrame chứa symbol và volume giao dịch

Kiểu trả về:

pandas.DataFrame

Ví dụ:

from xnoapi.vn.data import stocks
liquid_stocks = stocks.list_liquid_asset()
print(liquid_stocks.head())

Lấy dữ liệu lịch sử

get_stock_hist(symbol, resolution='h')

Lấy dữ liệu OHLCV lịch sử của cổ phiếu.

Tham số:
  • symbol (str) -- Mã cổ phiếu (VD: "VIC", "HPG")

  • resolution (str) -- Khung thời gian ('h' cho giờ, 'D' cho ngày)

Trả về:

DataFrame chứa dữ liệu OHLCV

Kiểu trả về:

pandas.DataFrame

Ví dụ:

from xnoapi.vn.data import get_stock_hist
vic_data = get_stock_hist("VIC", resolution='h')
print(vic_data.head())

Quote Class

class Quote(symbol)

Lớp để truy xuất dữ liệu quote của cổ phiếu.

Tham số:

symbol (str) -- Mã cổ phiếu

history(start, end, interval)

Lấy dữ liệu lịch sử trong khoảng thời gian.

Tham số:
  • start (str) -- Ngày bắt đầu (format: "YYYY-MM-DD")

  • end (str) -- Ngày kết thúc (format: "YYYY-MM-DD")

  • interval (str) -- Khung thời gian ("1D", "1H", "1m")

Ví dụ:

from xnoapi.vn.data.stocks import Quote
q = Quote("ACB")
data = q.history(start="2024-01-01", end="2024-03-31", interval="1D")
intraday(page_size, last_time=None)

Lấy dữ liệu tick intraday.

Tham số:
  • page_size (int) -- Số lượng record muốn lấy

  • last_time (str, optional) -- Thời gian cuối (optional)

Ví dụ:

q = Quote("ACB")
intraday_data = q.intraday(page_size=200)
price_depth()

Lấy độ sâu giá (accumulated volume).

Ví dụ:

q = Quote("ACB")
depth_data = q.price_depth()

Trading Class

class Trading

Lớp chứa các phương thức liên quan đến giao dịch.

static price_board(symbols)

Lấy bảng giá realtime với thông tin foreign, ceiling/floor.

Tham số:

symbols (list) -- Danh sách mã cổ phiếu

Ví dụ:

from xnoapi.vn.data.stocks import Trading
price_board = Trading.price_board(["VCB","ACB","TCB"])