7.6. Sức mua/bán

Mô tả cách sử dụng thư viện sau khi người dùng đã đăng nhập. Chi tiết được nêu ra ở cuối chương này.

7.6.1. Cơ bản

username_dnse = 'REPLACE_WITH_YOUR_DNSE_USERNAME'
password_dnse = 'REPLACE_WITH_YOUR_DNSE_PASSWORD'

client_order = client.FiinQuantConnector(
    broker='DNSE',
    username=username_dnse,
    password=password_dnse,
    smart_otp=True
).login()

orderbook = client_order.get_orderbook(
    account_id='0001009212',
    loan_id='13720'
)
trade_cap = orderbook.get_trading_power(ticker='SSI', price=41200)
print(trade_cap.summary())

Mẫu kết quả trả ra là một dictionary chứa các thông tin sau:

{
    'investor_id': '0001006289',
    'account_id': '0001009212',
    'custody_code': '064C500006',
    'available_power': 4884924031998,
    'buying_power': 4884924031998,
    'selling_power': 4884924024532,
    'max_buy_quantity': 135560840,
    'max_sell_quantity': 1000,
    'price': 36000.0,
    'error': None,
    'status_code': 200
}

Dữ liệu có các thuộc tính:

Tên thuộc tính
Kiểu dữ liệu
Mô tả

investor_id

str

Mã định danh của nhà đầu tư (Investor ID).

account_id

str

Mã tài khoản giao dịch của nhà đầu tư.

custody_code

str

Mã lưu ký (Custody code) của tài khoản.

available_power

float

Tổng sức mua/bán khả dụng hiện tại (available trading power).

buying_power

float

Sức mua còn lại có thể sử dụng cho giao dịch mua.

selling_power

float

Sức bán còn lại có thể sử dụng cho giao dịch bán.

max_buy_quantity

int

Số lượng tối đa có thể mua tại mức giá hiện tại.

max_sell_quantity

int

Số lượng tối đa có thể bán tại mức giá hiện tại.

price

float

Mức giá tham chiếu hoặc giá khớp hiện tại được sử dụng để tính toán sức mua/bán.

error

str hoặc None

Thông tin lỗi (nếu có) khi lấy dữ liệu sức mua/bán.

status_code

int

Mã code, nếu thành công là 200

7.6.2. Phái sinh

username_dnse = 'REPLACE_WITH_YOUR_DNSE_USERNAME'
password_dnse = 'REPLACE_WITH_YOUR_DNSE_PASSWORD'

client_order = client.FiinQuantConnector(
    broker='DNSE',
    username=username_dnse,
    password=password_dnse,
    smart_otp=True
).login()

orderbook_der = client_order.get_derivative_orderbook(
    account_id='0001009212',
    loan_id='2278'
)

derivative_cap = orderbook_der.get_trading_power(ticker='41I1FB000', price=1975)
print(derivative_cap.summary())

Mẫu kết quả trả ra là một dictionary chứa các thông tin sau:

{
    'investor_id': '0001006289',
    'account_id': '0001009212',
    'custody_code': '064C500006',
    'available_power': 3573140495626,
    'buying_power': 3573214662334,
    'selling_power': 3573140495626,
    'max_buy_quantity': 99608,
    'max_sell_quantity': 99542,
    'price': 1940.0,
    'error': None,
    'status_code': 200
}

Dữ liệu có các thuộc tính:

Tên thuộc tính
Kiểu dữ liệu
Mô tả

investor_id

str

Mã định danh của nhà đầu tư (Investor ID).

account_id

str

Mã tài khoản giao dịch của nhà đầu tư.

custody_code

str

Mã lưu ký (Custody code) của tài khoản.

available_power

float

Tổng sức mua/bán khả dụng hiện tại (available trading power).

buying_power

float

Sức mua còn lại có thể sử dụng cho giao dịch mua.

selling_power

float

Sức bán còn lại có thể sử dụng cho giao dịch bán.

max_buy_quantity

int

Số lượng tối đa có thể mua tại mức giá hiện tại.

max_sell_quantity

int

Số lượng tối đa có thể bán tại mức giá hiện tại.

price

float

Mức giá tham chiếu hoặc giá khớp hiện tại được sử dụng để tính toán sức mua/bán.

error

str hoặc None

Thông tin lỗi (nếu có) khi lấy dữ liệu sức mua/bán.

status_code

int

Mã code, nếu thành công là 200

Last updated