Accounting
We can query profit and loss information through trade and inventory inquiries.
info
The limit of queries is 5 times / sec. If it exceeds the limit, please wait a moment and try again.
Inventory
- Python
- Node.js
- C#
inventories = sdk.accounting.inventories(accounts.data[0])
print(inventories)
Result {
is_success: true,
message: None,
data : [
Inventory{
date: "2023/09/20", # Query date(Today) (string)
account: "26", # Account (string)
branch_no: 6460, # Branch number (number)
stock_no: "1101", # Symbol (string)
order_type: Stock, # Order Type (OrderType)
lastday_qty: 2000, # Yesterday Share balacne (number)
buy_qty: 0, # Total volume purchased today (number)
buy_filled_qty: 0, # Total purchased filled today (number)
buy_value: 0, # Total amount purchased today (number)
today_qty: 2000, # Today Share balacne (number)
tradable_qty: 2000, #Available quantity (number)
sell_qty: 0, # Total volume sell today (number)
sell_filled_qty: 0, # Total sell filled today (number)
sell_value: 0, # Total amount sell today (number)
odd: InventoryOdd{ # odd lot
lastday_qty: 0, # Yesterday odd lot balacne (number)
buy_qty: 0, # Total volume purchased today (number)
buy_filled_qty: 0, # Total purchased filled today (number)
buy_value: 0, # Total amount purchased today (number)
today_qty: 0, # Today odd lot balacne (number)
tradable_qty: 0, # Available quantity (number)
sell_qty: 0, # Total volume sell today (number)
sell_filled_qty: 0,# Total sell filled today (number)
sell_value: 0 # Total amount sell today (number)
}},
...
]
}
const inventory = sdk.accounting.inventories(accounts.data[0])
console.log(inventory)
{
isSuccess: true,
data:[
{
date: '2023/10/13', // Query date(Today) (string)
account: '26', // Account (string)
branchNo: '6460', // Branch number (string)
stockNo: '1101', // Symbol (string)
orderType: 'Stock', // Order Type (string)
lastdayQty: 2000, // Yesterday Share balacne (number)
buyQty: 0, // Total volume purchased today (number)
buyFilledQty: 0, // Total purchased filled today (number)
buyValue: 0, // Total amount purchased today (number)
todayQty: 2000, // Today share balacne (number)
tradableQty: 2000, // Available quantity (number)
sellQty: 0, // Total volume sell today (number)
sellFilledQty: 0, // Total sell filled today (number)
sellValue: 0, // Total amount sell today (number)
odd: { // odd lot
lastdayQty: 0, // Yesterday odd lot balacne (number)
buyQty: 0, // Total volume purchased today (number)
buyFilledQty: 0, // Total purchased filled today (number)
buyValue: 0, // Total amount purchased today (number)
todayQty: 0, // Today odd lot balacne (number)
tradableQty: 0, // Available quantity (number)
sellQty: 0, // Total volume sell today (number)
sellFilledQty: 0, // Total sell filled today (number)
sellValue: 0 // Total amount sell today (number)
}
},
...
]
}
var inventories = sdk.Accounting.Inventoies(accounts.data[0]);
foreach (var inventory in inventories.data)
{
Console.WriteLine(inventory);
}
{
date = 2023/09/21, // Query date(Today) (string)
account = 26, // Account (string)
branchNo = 6460, // Branch number (string)
stockNo = 1101, // Symbol (string)
orderType = Stock, // Order Type (OrderType)
lastdayQty = 2000, // Yesterday Share balacne (int)
buyQty = 0, // Total volume purchased today (int)
buyFilledQty = 0, // Total purchased filled today (int)
buyValue = 0, // Total amount purchased today (int)
todayQty = 2000, // Today share balacne (int)
tradableQty = 2000, // Available quantity (int)
sellQty = 0, // Total volume sell today (int)
sellFilledQty = 0, // Total sell filled today (int)
sellValue = 0, // Total amount sell today (int)
odd = InventoryOdd { // odd lot
lastdayQty = 0, // Yesterday odd lot balacne (int)
buyQty = 0, // Total volume purchased today (int)
buyFilledQty = 0, // Total purchased filled today (int)
buyValue = 0, // Total amount purchased today (int)
todayQty = 0, // Today odd lot balacne (int)
tradableQty = 0, // Available quantity (int)
sellQty = 0, // Total volume sell today (int)
sellFilledQty = 0, // Total sell filled today (int)
sellValue = 0 // Total amount sell today (int)
}
}
- Below example only extract data content
Unrealized profit and loss
- Python
- Node.js
- C#
unrealized_pnl = sdk.accounting.unrealized_gains_and_loses(accounts.data[0])
print(unrealized_pnl.data)
[UnrealizedData({
date: "2023/05/23", # Date of inquiry (string)
account: "482", # Account (string)
branch_no: "6460", # Branch number (string)
stock_no: "2442", # Symbol (string)
buy_sell: Buy, # Transaction direction (BSAction)
order_type: Margin, # Order Type (OrderType)
cost_price: 19.95, # Holding cost (number)
tradable_qty: 6000, # Available quantity (number)
unrealized_profit: 0, # Unrealized profit (number)
unrealized_loss: 10002 # Unrealized loss (number)
}),
...
]
const unrealizedPNL = sdk.accounting.unrealizedGainsAndLoses(accounts.data[0])
console.log(unrealizedPNL.data)
[
{
date: '2021/08/09', // Inventory creation date (string)
account: '26', // Account (string)
branchNo: '6460', // Branch number (string)
stockNo: '2303', // Symbol (string)
buySell: 'Buy', // Transaction direction (string)
orderType: 'Margin', // Order Type (string)
costPrice: 50, // Holding cost (number)
tradableQty: 1000, // Available quantity (number)
unrealizedProfit: 47000, // Unrealized profit (number)
unrealizedLoss: 0 // Unrealized loss (number)
},
...
]
var unrealizedPNL = sdk.Accounting.UnrealizedGainsAndLoses(accounts.data[0]);
foreach (var unrealized in unrealizedPNL.data)
{
Console.WriteLine(unrealized);
}
{
date = 2021/08/09, // Inventory creation date (string)
account = 26, // Account (string)
branchNo = 6460, // Branch number (string)
stockNo = 2303, // Symbol (string)
buySell = Buy, // Transaction direction (BSAction)
orderType = Margin, // Order Type (OrderType)
costPrice = 50, // Holding cost (double)
tradableQty = 1000, // Available quantity (int)
unrealizedProfit = 45600, // Unrealized profit (int)
unrealizedLoss = 0 // Unrealized loss (int)
}
Settlement information
You can inquire about Settlement information to confirm the amount receivable or payable for today or the past three days.
- Python
- Node.js
- C#
settlement = sdk.accounting.query_settlement(accounts.data[0],"0d")
print(settlement.data)
const settlement = sdk.accounting.querySettlement(accounts.data[0],"0d")
console.log(settlement.data)
var settlement = sdk.Accounting.QuerySettlement(accounts.data[0],"0d");
Console.WriteLine(settlement.data);
Console.WriteLine(settlement.data.settle);
The results of the following inquiry represent a receivable delivery amount of 68,100 TWD for September 12th:
- Python
- Node.js
- C#
SettlementData({
account: AccountRes { # Account Information
branch_no: "6460", # Account (string)
account: "26" # Branch number (string)
},
details: [ # Settlement Information
{
date: "2023/09/08", # Query Date (Today) (string)
settlement_date: "2023/09/12", # Settlement Date (string)
buy_value: 735500, # Buying Value (int)
buy_fee: 313, # Buying Fee (int)
buy_settlement: -1429513, # Buying Payable / Receivable Amount (int)
buy_tax: 0, # Buying Tax (int)
sell_value: 770500, # Selling Value (int)
sell_fee: 320, # Selling Fee (int)
sell_settlement: 0, # Selling Payable / Receivable Amount (int)
sell_tax: 2309, # Selling Tax (int)
total_bs_value: 1506000, # Total Buying & Selling Value (int)
total_fee: 633, # Total Fee (int)
total_tax: 2309, # Total Tax (int)
total_settlement_amount: -1429513, # Total Payable & Receivable Amount (int)
currency: "TWD", # Currency (string)
}
]
})
{
account: { // Account Information
branch_no: '6460', // Account (string)
account: '26' // Branch number (string)
},
details: [ // Settlement Information
{
date: '2023/09/08', // Query Date (Today) (string)
settlement_date: '2023/09/12', // Settlement Date (string)
buyValue: 735500, // Buying Value (int)
buyFee: 313, // Buying Fee (int)
buySettlement: -1429513, // Buying Payable / Received Amount (int)
buyTax: 0, // Buying Tax (int)
sellValue: 770500, // Selling Value (int)
sellFee: 320, // Selling Fee (int)
sellSettlement: 0, // Selling Payable / Received Amount (int)
sellTax: 2309, // Selling Tax (int)
totalBsValue: 1506000, // Total Buying & Selling Amount (int)
totalFee: 633, // Total Fee (int)
totalSettlementAmount: -1429513, // Total Payable & Received Amount (int)
totalTax: 2309, // Total Tax (int)
currency: "TWD" // Currency (string)
}
]
}
{
account = AccountRes { // Account Information
account = 26, // Account (string)
branchNo = 6460 // Branch number (string)
},
details = [ // Settlement Information
date = 2023/09/08, // Query Date (Today) (string)
settlementDate = 2023/09/12, // Settlement Date (string)
buyValue = 735500, // Buying Value (int)
buyFee = 313, // Buying Fee (int)
buySettlement = -1429513, // Buying Payable / Received Amount (int)
buyTax = 0, // Buying Tax (int)
sellValue = 770500, // Selling Value (int)
sellFee = 320, // Selling Fee (int)
sellSettlement = 0, // Selling Payable / Received Amount (int)
sellTax = 2309, // Selling Tax (int)
totalBsValue = 1506000, // Total Buying & Selling Amount (int)
totalFee = 633, // Total Fee (int)
totalSettlementAmount = -1429513, // Total Payable & Received Amount (int)
totalTax = 2309, // Total Tax (int)
currency = TWD // Currency (string)
]
}