Guide · History
Read history. Not positions.
Positions are what is open now. History is what closed. The history call returns the most recent closed deals, newest first in the response order the broker gives.
01Call history for the account
The default limit is 1000 and the maximum is 5000, over the last 30 days unless you pass from and to as epoch seconds. Start with a smaller limit while you are wiring the screen.
curl "https://api.socketrade.com/v2/acc_.../history?limit=200" \
-H "X-API-Key: $SOCKETRADE_KEY"
{ "deals": [
{ "ticket": 4770849812, "order": 4802213845, "position": 4802213845,
"symbol": "Volatility 75 Index", "type": 0, "entry": 0,
"volume": 0.01, "price": 42623.34, "profit": 0.0,
"commission": 0.0, "swap": 0.0, "fee": 0.0,
"sl": 0.0, "tp": 0.0, "comment": "phase1",
"time": 1795945769 } ] }
# type: 0 buy, 1 sell. entry: 0 in, 1 out. time is the broker's epoch seconds.02Match a close to an open
Store your own mapping when you send the order: your reference to the ticket. That mapping is what lets you reconcile a close without guessing by symbol and time.
03Do not treat history as a live feed
History is a REST read. It does not stream. Refresh it after you close a position, or on a timer. The WebSocket sends price ticks only.
When it fails
401Key missing or wrong.
402The seat is not active.
404Account id wrong, or not yours.
Empty listNo closed deals in the window, or the account has not traded yet.