depth: Add methods to derive liquidity allowances on orderbooks by volume and slippage (#962)

* depth: methods to derive liquidity impact details

* depth: fix comments on link list methods

* depth: fix whoopsie

* Update exchanges/orderbook/linked_list_test.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* glorious: nits

* orderbook: standardise methods to GCT math package

* averagePrice: implementation (WIP)

* ll: hmmmmmm

* continued

* orderbook: reworked functions

* WIP

* orderbook: add tests link up with RPC

* orderbook: refined calculations, add tests (WIP)

* orderbook: add tests finalise/verify remove state until next PR if needed

* rpcserver/orderbook: remove redundant type and change wording

* linter: fix

* Update exchanges/orderbook/linked_list.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* gctcli: noobed it up

* orderbook: work work work (yesterday)

* depth: WIP and testing

* orderbook: improve calculations for bids traversal

* orderbook: adjust tests

* orderbook: linters/nits

* orderbook: fix error returns and add asset to whalebomb

* orderbook: drop error when full book is potentially consumed

* Update cmd/gctcli/orderbook.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* orderbook: Add tests and nits

* glorious: nits

* backtester: handle new errors

* grpc: linter

* orderbook: remove pesky t.Log()s

* glorious: nits (yesterday)

* depth/gctcli: Add in purchase requirements into orderbook movement, will also standardize in next commit after tests are fixed.

* orderbook: standardize and overhaul

* orderbook: update comments, update tests

* rpcserver: add average ordercost and amounts

* depth: add spread and imbalance methods

* linter: fix

* glorious: nits

* orderbook: don't purge price, rn test.

* glorious: codes nits

* linter: fix

* Update exchanges/orderbook/linked_list.go

Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>

* Update exchanges/orderbook/linked_list.go

Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>

* Update exchanges/orderbook/linked_list.go

Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>

* Update exchanges/orderbook/linked_list.go

Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>

* Update exchanges/orderbook/linked_list.go

Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>

* thrasher: nits

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
This commit is contained in:
Ryan O'Hara-Reid
2022-10-14 16:43:37 +11:00
committed by GitHub
parent 74d0cc323d
commit 9acbdbf203
21 changed files with 9150 additions and 3037 deletions

View File

@@ -2556,6 +2556,231 @@
]
}
},
"/v1/getorderbookamountbyimpact": {
"get": {
"operationId": "GoCryptoTraderService_GetOrderbookAmountByImpact",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/gctrpcGetOrderbookAmountByImpactResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"parameters": [
{
"name": "exchange",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "asset",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "pair.delimiter",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "pair.base",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "pair.quote",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "impactPercentage",
"in": "query",
"required": false,
"type": "number",
"format": "double"
},
{
"name": "sell",
"in": "query",
"required": false,
"type": "boolean"
},
{
"name": "requiresRestOrderbook",
"in": "query",
"required": false,
"type": "boolean"
}
],
"tags": [
"GoCryptoTraderService"
]
}
},
"/v1/getorderbookamountbynominal": {
"get": {
"operationId": "GoCryptoTraderService_GetOrderbookAmountByNominal",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/gctrpcGetOrderbookAmountByNominalResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"parameters": [
{
"name": "exchange",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "asset",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "pair.delimiter",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "pair.base",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "pair.quote",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "nominalPercentage",
"in": "query",
"required": false,
"type": "number",
"format": "double"
},
{
"name": "sell",
"in": "query",
"required": false,
"type": "boolean"
},
{
"name": "requiresRestOrderbook",
"in": "query",
"required": false,
"type": "boolean"
}
],
"tags": [
"GoCryptoTraderService"
]
}
},
"/v1/getorderbookmovement": {
"get": {
"operationId": "GoCryptoTraderService_GetOrderbookMovement",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/gctrpcGetOrderbookMovementResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"parameters": [
{
"name": "exchange",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "asset",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "pair.delimiter",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "pair.base",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "pair.quote",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "amount",
"in": "query",
"required": false,
"type": "number",
"format": "double"
},
{
"name": "sell",
"in": "query",
"required": false,
"type": "boolean"
},
{
"name": "requiresRestOrderbook",
"in": "query",
"required": false,
"type": "boolean"
},
{
"name": "purchase",
"in": "query",
"required": false,
"type": "boolean"
}
],
"tags": [
"GoCryptoTraderService"
]
}
},
"/v1/getorderbooks": {
"get": {
"operationId": "GoCryptoTraderService_GetOrderbooks",
@@ -5527,6 +5752,149 @@
}
}
},
"gctrpcGetOrderbookAmountByImpactResponse": {
"type": "object",
"properties": {
"amountRequired": {
"type": "number",
"format": "double"
},
"currencySelling": {
"type": "string"
},
"amountReceived": {
"type": "number",
"format": "double"
},
"currencyBuying": {
"type": "string"
},
"startPrice": {
"type": "number",
"format": "double"
},
"endPrice": {
"type": "number",
"format": "double"
},
"averageOrderCost": {
"type": "number",
"format": "double"
},
"sideAffected": {
"type": "string"
},
"approximateImpactSlippagePercentage": {
"type": "number",
"format": "double"
},
"updateProtocol": {
"type": "string"
},
"fullOrderbookSideConsumed": {
"type": "boolean"
}
}
},
"gctrpcGetOrderbookAmountByNominalResponse": {
"type": "object",
"properties": {
"amountRequired": {
"type": "number",
"format": "double"
},
"currencySelling": {
"type": "string"
},
"amountReceived": {
"type": "number",
"format": "double"
},
"currencyBuying": {
"type": "string"
},
"startPrice": {
"type": "number",
"format": "double"
},
"endPrice": {
"type": "number",
"format": "double"
},
"averageOrderCost": {
"type": "number",
"format": "double"
},
"sideAffected": {
"type": "string"
},
"approximateNominalSlippagePercentage": {
"type": "number",
"format": "double"
},
"updateProtocol": {
"type": "string"
},
"fullOrderbookSideConsumed": {
"type": "boolean"
}
}
},
"gctrpcGetOrderbookMovementResponse": {
"type": "object",
"properties": {
"nominalPercentage": {
"type": "number",
"format": "double"
},
"impactPercentage": {
"type": "number",
"format": "double"
},
"slippageCost": {
"type": "number",
"format": "double"
},
"currencyBought": {
"type": "string"
},
"bought": {
"type": "number",
"format": "double"
},
"currencySold": {
"type": "string"
},
"sold": {
"type": "number",
"format": "double"
},
"sideAffected": {
"type": "string"
},
"updateProtocol": {
"type": "string"
},
"fullOrderbookSideConsumed": {
"type": "boolean"
},
"startPrice": {
"type": "number",
"format": "double"
},
"endPrice": {
"type": "number",
"format": "double"
},
"noSlippageOccurred": {
"type": "boolean"
},
"averageOrderCost": {
"type": "number",
"format": "double"
}
}
},
"gctrpcGetOrderbookRequest": {
"type": "object",
"properties": {
@@ -6468,6 +6836,9 @@
},
"side": {
"type": "string"
},
"assetType": {
"type": "string"
}
}
},