Skip to content

Profit Loss

Query account of profit loss

First, you need login.

In

api.list_profit_loss?

Out

Signature:
    api.list_profit_loss(
        account: shioaji.account.Account = None,
        begin_date: str = '',
        end_date: str = '',
        timeout: int = 5000,
        cb: Callable[[List[shioaji.position.ProfitLoss]], NoneType] = None,
    ) -> List[shioaji.position.ProfitLoss]
Docstring:
    query account of profit loss

    Args:
        account (:obj:Account): 
            choice the account from listing account (Default: stock account)
        begin_date (str): the start date of query profit loss (Default: today)
        end_date (str): the end date of query profit loss (Default: today)

In

api.list_profit_loss(api.stock_account,'2020-05-05','2020-05-30')

Out

[ProfitLoss(id=0, code='2890', seqno='14816', dseq='ID111', quantity=1, price=10.1, pnl=1234.0, pr_ratio=0.1237, cond='Cash', date='2020-05-22')]

In

profitloss = api.list_profit_loss(api.stock_account,'2020-05-05','2020-05-30')   
df = pd.DataFrame(profitloss)     
df     

Out

id code cond date pnl pr_ratio price quantity seqno dseq
0 2890 StockOrderCond.Cash 2020-05-22 1000.0 0.1237 10.1 1 14816 ID111

Attributes:

id (int): use to find detail.
code (str): contract id.
seqno (str): seqno no.
dseq (str): seqno no.
quantity (int): quantity.
price (float): price.
pnl (float): profit and loss.
pr_ratio (float): profit rate.
cond (StockOrderCond): {Cash, Netting, MarginTrading, ShortSelling}
date (str): trade date.