Skip to content

Position

Position is an unrealized profit.

First, you need login.

In

api.list_positions(api.stock_account)

Out

[Position(code='2890', direction=<Action.Buy: 'Buy'>, quantity=10, price=10.1, pnl=1234.0, yd_quantity=10)]

In

positions = api.list_positions(api.stock_account)
df = pd.DataFrame(positions)
df

Out

code cond direction pnl price quantity yd_quantity
2890 StockOrderCond.Cash Action.Buy -1234.0 10.1 10 10

Attributes:

code (str): contract id.
direction (Action): action.
    {Buy, Sell}
quantity (int): quantity.
price (float): the average price.
pnl (float): unrealized profit.
yd_quantity (int): yesterday
cond (StockOrderCond): Default Cash.
    {Cash, Netting, MarginTrading, ShortSelling}