Spot cost price
OKX provides both an Asset Overview Spot Cost Price and a Trading Account Spot Cost Price, with the following key differences:
Asset Overview Cost Price includes assets across the Trading Account, Funding Account, and Earn Account, whereas the Trading Account Cost Price only reflects assets within the Trading Account.
The Asset Overview Cost Price is calculated using the average cost method, while the Trading Account supports both average cost and cumulative cost calculation methods, which can be switched within the trading setting.
For the specific formulas of average and cumulative cost, please refer to the example provided under Trading Account - Spot Cost Price below.
1. Asset Overview Spot Cost Price
Definition: A weighted average of the cost prices and quantities across the Trading Account, Funding Account, and Earn Account. Transfers between these accounts do not affect the cost price.
Example: If the Asset Overview shows 1 ETH with a cost price of 3000, and this ETH is transferred from the Funding Account to the Trading Account, the Asset Overview cost price remains 3000.
2. Trading Account - Spot Cost Price
2.1 Summary
Average Cost Price | Cumulative Cost Price | |
Definition | Average cost price is the average price at which you buy spot | Cumulative cost price is the cumulative price at which you buy and sell spot |
Cost Price | (Average cost price before last buy × Amount + Price of last buy × Amount) / Net buying amount | (Cumulative buying value – Cumulative selling value) / Net buying amount |
PnL | (Last price – Cost price) × Net buying amount | Net buying amount × Last price – Cumulative buying value + Cumulative selling value |
PnL Ratio | (Last price – Cost price) / Cost price | PnL / (Cumulative buying value – Cumulative selling value) |
Recommended Use Case | Primarily used to assist in trading decisions, determining when to buy and sell | Primarily used to assist in trading decisions, determining when to sell |
2.2 Calculation Examples
You can understand the corresponding calculation formulas through the following examples:
Scenario 1: Assume you did not hold any ETH before. On Day 1, you purchase 2 ETH at a price of 3000, and the last price is 3500.
Average cost price
Average cost price = (0 + 3000 * 2) / 2 = 3000
PnL = (3500-3000)*2 = 1000
PnL Ratio = (3500 - 3000)/3000 * 100% = 16.67%
Cumulative Cost Price
Cumulative Cost Price = (3000 * 2 - 0)/2 = 3000
PnL = 3500 * 2 - 3000 * 2 + 0 = 1000
PnL Ratio = 1000 / (3000 * 2 - 0) * 100% = 16.67%
Scenario 2: On Day 2, you sell 1 ETH at a price of 3500, and the last price is now 4000.
Average cost price
Average cost price = 3000
PnL = (4000-3000)*1 = 1000
PnL Ratio = (4000 - 3000)/3000 * 100% = 33.3%
Cumulative Cost Price
Cumulative Cost Price = (2*3000 - 1*3500)/1 = 2500
PnL = 4000*1 - 2*3000 + 1*3500 = 1500
PnL Ratio = 1500 / (2*3000 - 1*3500) * 100% = 60%
Scenario 3:On Day 3, you buy 1 more ETH at a price of 4000, and the last price is now 4500.
Average cost price
Average cost price = ( 3000*1 + 4000*1 ) / 2 = 3500
PnL = (4500 - 3500) * 2 = 2000
PnL Ratio = (4500 - 3500)/3500 * 100% = 28.6%
Cumulative Cost Price
Cumulative Cost Price = ( 3000*2 + 4000*1 - 3500*1 ) / 2 = 3250
PnL = 2*4500 - (2*3000+1*4000) + 1*3500 = 2500
PnL Ratio = 2500 / (2*3000+1*4000 - 1*3500 ) * 100% = 38.5%
2.3 Important Notes
The spot cost price data range is effective from November 6, 2020, and the following scenarios will be included in the calculation:
Spot trading
Transfer of funds to the trading account upon the termination of strategy bots (e.g., spot grid)
Exchanges (including Convert, Simple Trade, One-Click Repay, and Easy Convert)
Stablecoins and fiat currencies are excluded from spot cost price calculations.
2.4 Open API data fields
Average Cost Price | Cumulative Cost Price | |
Cost Price | openAvgPx | accAvgPx |
PnL | spotUpl | totalPnl |
PnL Ratio | spotUplRatio | totalPnlRatio |
Net buying amount | spotBal | spotBal |