docs: Establish a standard for trade/order-update websocket events (#755)

* docs: initially commit WS_TRADE_UPDATES.md

* docs/WS_TRADE_UPDATES: shorter text

* docs: rename WS_TRADE_UPDATES to WS_ORDER_EVENTS as that is more descriptive of what it documents

* docs/ADD_NEW_EXCHANGE: reference the newly added WS_ORDER_EVENTS file

* WS_ORDER_EVENTS: common terminology

* WS_ORDER_EVENTS: turn the code segment into a markdown table

* WS_ORDER_EVENTS: AverageExecutedPrice is now not mandatory

* exchanges/README: link to WS_ORDER_EVENTS
This commit is contained in:
Yordan Miladinov
2021-08-23 02:48:16 +03:00
committed by GitHub
parent 3467914ab7
commit a15cbf6651
3 changed files with 40 additions and 0 deletions

View File

@@ -870,6 +870,9 @@ Run gocryptotrader with the following settings enabled in config
#### Handle websocket data:
- Trades and order events are handled by populating an order.Detail
struct by [the following rules](./WS_ORDER_EVENTS.md).
- Function to read data received from websocket:
```go

34
docs/WS_ORDER_EVENTS.md Normal file
View File

@@ -0,0 +1,34 @@
# Websocket trade events
GoCryptoTrader unifies trades and order update events by composing an
order.Detail object. This is the full list of order.Detail fields
that exchange implementations should populate on streamed
trade/order-update events. As exchanges provide different APIs, not
all fields are mandatory.
Note to developers: a special mention is the AverageExecutedPrice,
which is not always provided, but its presence is important and highly
desirable. Even if not reported, effort should be made to compute it
out of reported trades.
| order.Detail field | Description | Condition | Presence |
|----------------------|-------------------------------------------------------------------|---------------------------------------------------------|-----------|
| Price | Original price assigned to order | Depends on order type (e.g. limit orders have prices) | Mandatory |
| Amount | Original quantity assigned to order | | Mandatory |
| AverageExecutedPrice | Average price of what's traded thus far | Order is filled, partially filled or partially canceled | Desirable |
| ExecutedAmount | How much of the original order quantity is filled | Order is filled, partially filled or partially canceled | Mandatory |
| RemainingAmount | Amount - ExecutedAmount | | Mandatory |
| Cost | How much is spent thus far (cumulative transacted quote currency) | Order is filled, partially filled or partially canceled | Mandatory |
| CostAsset | Deprecated, cost currency is always pair.Quote | | - |
| Fee | How much last trade was charged by the exchange | Reported event is a trade | Optional |
| FeeAsset | Asset of the taken fee | | Optional |
| Exchange | String name of concerned exchange | | Mandatory |
| ID | Order ID (on the exchange) | | Mandatory |
| ClientOrderID | Client order ID (submitted by user) | | Mandatory |
| Type | e.g. MARKET or LIMIT, see exchanges/order/order_types.go | | Mandatory |
| Side | e.g. BUY or SELL, see exchanges/order/order_types.go | | Mandatory |
| Status | e.g. FILLED or CANCELLED, see exchanges/order/order_types.go | | Mandatory |
| AssetType | e.g. asset.Spot or asset.Futures | | Mandatory |
| Date | Time of order creation (as reported by the exchange) | | Optional |
| LastUpdated | Time of last order event (as reported by the exchange) | | Optional |
| Pair | Tradable pair | | Mandatory |