mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 15:09:42 +00:00
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:
@@ -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
34
docs/WS_ORDER_EVENTS.md
Normal 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 |
|
||||
@@ -42,6 +42,9 @@ When submitting a PR, please abide by our coding guidelines:
|
||||
+ Code must adhere to our [coding style](https://github.com/thrasher-corp/gocryptotrader/blob/master/doc/coding_style.md).
|
||||
+ Pull requests need to be based on and opened against the `master` branch.
|
||||
|
||||
If contributing websocket improvements, please make sure order reports
|
||||
follow [these rules](../docs/WS_ORDER_EVENTS.md).
|
||||
|
||||
## Donations
|
||||
|
||||
<img src="https://github.com/thrasher-corp/gocryptotrader/blob/master/web/src/assets/donate.png?raw=true" hspace="70">
|
||||
|
||||
Reference in New Issue
Block a user