From b3f9b7783abcbcb9f3067ed1fcfcd5c4d5c7f8cc Mon Sep 17 00:00:00 2001 From: Anatoly Ostrovsky Date: Mon, 20 Nov 2023 22:34:55 +0200 Subject: [PATCH] Add redoc. Move yaml to separate folder --- Dockerfile | 2 +- Makefile | 23 +- package.json | 3 +- pkg/api.yaml | 221 ++++++++++++++++++ .../endpoints}/currencies_list.yaml | 2 +- .../endpoints}/instruments_list.yaml | 2 +- .../api => api/endpoints}/order_books.yaml | 4 +- .../endpoints}/trade_orders_list.yaml | 2 +- .../api => api/endpoints}/trades_list.yaml | 2 +- pkg/{ => api}/models/currency.yaml | 0 pkg/{ => api}/models/instrument.yaml | 0 pkg/{ => api}/models/order_book.yaml | 0 pkg/{ => api}/models/shared.yaml | 0 pkg/{ => api}/models/trade.yaml | 0 pkg/{ => api}/models/trade_order.yaml | 0 pkg/{ => api}/models/trading_account.yaml | 0 pkg/{ => api}/openapi.yaml | 10 +- pkg/rest/.openapi-generator/FILES | 10 +- pkg/rest/README.md | 2 +- pkg/rest/api/api_order_books_service.go | 4 +- pkg/rest/api/model_currency.go | 30 +++ pkg/rest/api/model_instrument.go | 36 +++ pkg/rest/api/model_order_book.go | 26 +++ pkg/rest/api/model_price_volume.go | 26 +++ pkg/rest/api/model_trade.go | 25 ++ pkg/rest/api/model_trade_order.go | 33 +++ pkg/rest/api/model_trade_order_side.go | 23 ++ pkg/rest/api/model_trade_order_status.go | 23 ++ .../api/model_trade_order_time_in_force.go | 23 ++ pkg/rest/api/openapi.yaml | 157 ++++++++----- .../matching_service_market_order_test.go | 1 - 31 files changed, 601 insertions(+), 89 deletions(-) create mode 100644 pkg/api.yaml rename pkg/{rest/api => api/endpoints}/currencies_list.yaml (78%) rename pkg/{rest/api => api/endpoints}/instruments_list.yaml (78%) rename pkg/{rest/api => api/endpoints}/order_books.yaml (70%) rename pkg/{rest/api => api/endpoints}/trade_orders_list.yaml (78%) rename pkg/{rest/api => api/endpoints}/trades_list.yaml (78%) rename pkg/{ => api}/models/currency.yaml (100%) rename pkg/{ => api}/models/instrument.yaml (100%) rename pkg/{ => api}/models/order_book.yaml (100%) rename pkg/{ => api}/models/shared.yaml (100%) rename pkg/{ => api}/models/trade.yaml (100%) rename pkg/{ => api}/models/trade_order.yaml (100%) rename pkg/{ => api}/models/trading_account.yaml (100%) rename pkg/{ => api}/openapi.yaml (76%) create mode 100644 pkg/rest/api/model_currency.go create mode 100644 pkg/rest/api/model_instrument.go create mode 100644 pkg/rest/api/model_order_book.go create mode 100644 pkg/rest/api/model_price_volume.go create mode 100644 pkg/rest/api/model_trade.go create mode 100644 pkg/rest/api/model_trade_order.go create mode 100644 pkg/rest/api/model_trade_order_side.go create mode 100644 pkg/rest/api/model_trade_order_status.go create mode 100644 pkg/rest/api/model_trade_order_time_in_force.go diff --git a/Dockerfile b/Dockerfile index 7033593..92cdbd2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Build stage -FROM golang:1.20 AS build +FROM golang:1.21 AS build # Set the working directory WORKDIR /app diff --git a/Makefile b/Makefile index 028e178..8308416 100644 --- a/Makefile +++ b/Makefile @@ -29,30 +29,39 @@ DBDSN:="host=$(POSTGRES_HOST) user=$(POSTGRES_USER) password=$(POSTGRES_PASSWORD MIGRATE_OPTIONS=-allow-missing -dir="./pkg/db/migrations" db-update: ## Migrate down on database - goose -v $(MIGRATE_OPTIONS) postgres $(DBDSN) up + @goose -v $(MIGRATE_OPTIONS) postgres $(DBDSN) up db-downgrade: ## Migrate up on database - echo "$(MIGRATE_OPTIONS)" - goose -v $(MIGRATE_OPTIONS) postgres $(DBDSN) reset + @goose -v $(MIGRATE_OPTIONS) postgres $(DBDSN) reset db-rebuild: ## Reset the database - $(MAKE) db-downgrade - $(MAKE) db-update + @make db-downgrade + @make db-update validate-api: ## Validate api npx @openapitools/openapi-generator-cli validate \ -i pkg/openapi.yaml \ --recommend +bundle-api: + @npx @redocly/cli bundle \ + pkg/api/openapi.yaml \ + --output ./pkg/api.yaml \ + +validate-api: + @npx @redocly/cli lint \ + ./pkg/api.yaml \ + --format=checkstyle + generate-api: ## Generate server bindings, move model files, fix imports npx @openapitools/openapi-generator-cli generate \ - -i pkg/openapi.yaml \ + -i pkg/api.yaml \ -g go-server \ -o pkg/rest \ --additional-properties=packageName=api \ --additional-properties=sourceFolder=api \ --additional-properties=outputAsLibrary=true - $(MAKE) lint + @make lint help: grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) \ diff --git a/package.json b/package.json index e1f9603..4c639ef 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "private": true, "scripts": {}, "devDependencies": { - "@openapitools/openapi-generator-cli": "^2.7.0" + "@openapitools/openapi-generator-cli": "^2.7.0", + "@redocly/cli": "^1.4.1" } } diff --git a/pkg/api.yaml b/pkg/api.yaml new file mode 100644 index 0000000..b490702 --- /dev/null +++ b/pkg/api.yaml @@ -0,0 +1,221 @@ +openapi: 3.1.0 +info: + description: | + # Introduction + This API is documented in **OpenAPI 3.0 format**. + + This API the following operations: + * Retrieve a list of available instruments + * Retrieve a list of executed trades + + # Basics + * API calls have to be secured with HTTPS. + * All data has to be submitted UTF-8 encoded. + * The reply is sent JSON encoded. + version: 1.0.0 + title: OPEN OUTCRY API +servers: + - url: https://your.public.url +security: + - basicAuth: [] +paths: + /currencies: + get: + tags: + - currencies + summary: currencies list + description: Returns list of available currencies + operationId: getCurrencies + responses: + '200': + description: currencies list + content: + application/json: + schema: + $ref: '#/components/schemas/CurrencyList' + '500': + description: Error + /instruments: + get: + tags: + - instruments + summary: instrument list + description: Returns list of available instruments + operationId: getInstruments + responses: + '200': + description: instruments list + content: + application/json: + schema: + $ref: '#/components/schemas/InstrumentList' + '500': + description: Error + /order_books/{instrument_name}: + get: + tags: + - order_books + summary: get order books + description: Return an order book for an instrument + operationId: getOrderBook + parameters: + - in: path + name: instrument_name + required: true + schema: + $ref: '#/components/schemas/InstrumentName' + responses: + '200': + description: order book + content: + application/json: + schema: + $ref: '#/components/schemas/OrderBook' + '500': + description: Error + /trades: + get: + tags: + - trades + summary: trades list + description: Returns list of user's trades + operationId: getTrades + responses: + '200': + description: trades list + content: + application/json: + schema: + $ref: '#/components/schemas/TradeList' + '500': + description: Error + /trade_orders: + get: + tags: + - trade_order + summary: trade order list + description: Returns list of user's active trade orders + operationId: getTradeOrders + responses: + '200': + description: trades orders list + content: + application/json: + schema: + $ref: '#/components/schemas/TradeOrderList' + '500': + description: Error +components: + securitySchemes: + basicAuth: + type: http + scheme: basic + schemas: + CurrencyName: + type: string + description: ISO 4217 Currency symbol + example: USD + Currency: + type: object + description: Currency of payment account + properties: + name: + $ref: '#/components/schemas/CurrencyName' + precision: + type: integer + description: Currency precision as number of decimal points + example: 2 + CurrencyList: + type: array + description: List of currencies supported by app + items: + $ref: '#/components/schemas/Currency' + Id: + type: string + format: uuid + InstrumentName: + type: string + description: Ticker-like name of the instrument. For monetary instruments, a currency pair is used. + Instrument: + type: object + properties: + id: + $ref: '#/components/schemas/Id' + name: + $ref: '#/components/schemas/InstrumentName' + base_currency: + $ref: '#/components/schemas/CurrencyName' + quote_currency: + $ref: '#/components/schemas/CurrencyName' + enabled: + type: boolean + description: Availability for trading + InstrumentList: + type: array + items: + $ref: '#/components/schemas/Instrument' + PriceVolume: + type: object + properties: + price: + type: number + volume: + type: number + OrderBook: + type: object + properties: + sell: + type: array + items: + $ref: '#/components/schemas/PriceVolume' + buy: + type: array + items: + $ref: '#/components/schemas/PriceVolume' + Trade: + type: object + description: Execute trade + properties: + id: + $ref: '#/components/schemas/Id' + TradeList: + type: array + description: List of executed trades + items: + $ref: '#/components/schemas/Trade' + TradeOrderSide: + type: string + enum: + - SELL + - BUY + TradeOrderTimeInForce: + type: string + enum: + - GTC + - IOC + - FOK + - GTD + - GTT + TradeOrderStatus: + type: string + enum: + - OPEN + - REJECTED + - CANCELLED + TradeOrder: + type: object + properties: + id: + $ref: '#/components/schemas/Id' + instrument: + $ref: '#/components/schemas/InstrumentName' + side: + $ref: '#/components/schemas/TradeOrderSide' + timeInForce: + $ref: '#/components/schemas/TradeOrderTimeInForce' + status: + $ref: '#/components/schemas/TradeOrderStatus' + TradeOrderList: + type: array + items: + $ref: '#/components/schemas/TradeOrder' diff --git a/pkg/rest/api/currencies_list.yaml b/pkg/api/endpoints/currencies_list.yaml similarity index 78% rename from pkg/rest/api/currencies_list.yaml rename to pkg/api/endpoints/currencies_list.yaml index 8ed5906..7b25d4d 100644 --- a/pkg/rest/api/currencies_list.yaml +++ b/pkg/api/endpoints/currencies_list.yaml @@ -10,6 +10,6 @@ get: content: application/json: schema: - $ref: ../../models/currency.yaml#/components/schemas/CurrencyList + $ref: ../models/currency.yaml#/components/schemas/CurrencyList "500": description: Error diff --git a/pkg/rest/api/instruments_list.yaml b/pkg/api/endpoints/instruments_list.yaml similarity index 78% rename from pkg/rest/api/instruments_list.yaml rename to pkg/api/endpoints/instruments_list.yaml index f2b809f..74ec650 100644 --- a/pkg/rest/api/instruments_list.yaml +++ b/pkg/api/endpoints/instruments_list.yaml @@ -10,6 +10,6 @@ get: content: application/json: schema: - $ref: ../../models/instrument.yaml#/components/schemas/InstrumentList + $ref: ../models/instrument.yaml#/components/schemas/InstrumentList "500": description: Error diff --git a/pkg/rest/api/order_books.yaml b/pkg/api/endpoints/order_books.yaml similarity index 70% rename from pkg/rest/api/order_books.yaml rename to pkg/api/endpoints/order_books.yaml index 234f60d..841de0a 100644 --- a/pkg/rest/api/order_books.yaml +++ b/pkg/api/endpoints/order_books.yaml @@ -9,7 +9,7 @@ get: name: instrument_name required: true schema: - $ref: '../../models/instrument.yaml#/components/schemas/InstrumentName' + $ref: '../models/instrument.yaml#/components/schemas/InstrumentName' responses: "200": @@ -17,6 +17,6 @@ get: content: application/json: schema: - $ref: '../../models/order_book.yaml#/components/schemas/OrderBook' + $ref: '../models/order_book.yaml#/components/schemas/OrderBook' "500": description: Error diff --git a/pkg/rest/api/trade_orders_list.yaml b/pkg/api/endpoints/trade_orders_list.yaml similarity index 78% rename from pkg/rest/api/trade_orders_list.yaml rename to pkg/api/endpoints/trade_orders_list.yaml index 1372f24..5d09335 100644 --- a/pkg/rest/api/trade_orders_list.yaml +++ b/pkg/api/endpoints/trade_orders_list.yaml @@ -10,6 +10,6 @@ get: content: application/json: schema: - $ref: ../../models/trade_order.yaml#/components/schemas/TradeOrderList + $ref: ../models/trade_order.yaml#/components/schemas/TradeOrderList "500": description: Error diff --git a/pkg/rest/api/trades_list.yaml b/pkg/api/endpoints/trades_list.yaml similarity index 78% rename from pkg/rest/api/trades_list.yaml rename to pkg/api/endpoints/trades_list.yaml index 5511b6b..14a127a 100644 --- a/pkg/rest/api/trades_list.yaml +++ b/pkg/api/endpoints/trades_list.yaml @@ -10,6 +10,6 @@ get: content: application/json: schema: - $ref: '../../models/trade.yaml#/components/schemas/TradeList' + $ref: '../models/trade.yaml#/components/schemas/TradeList' "500": description: Error diff --git a/pkg/models/currency.yaml b/pkg/api/models/currency.yaml similarity index 100% rename from pkg/models/currency.yaml rename to pkg/api/models/currency.yaml diff --git a/pkg/models/instrument.yaml b/pkg/api/models/instrument.yaml similarity index 100% rename from pkg/models/instrument.yaml rename to pkg/api/models/instrument.yaml diff --git a/pkg/models/order_book.yaml b/pkg/api/models/order_book.yaml similarity index 100% rename from pkg/models/order_book.yaml rename to pkg/api/models/order_book.yaml diff --git a/pkg/models/shared.yaml b/pkg/api/models/shared.yaml similarity index 100% rename from pkg/models/shared.yaml rename to pkg/api/models/shared.yaml diff --git a/pkg/models/trade.yaml b/pkg/api/models/trade.yaml similarity index 100% rename from pkg/models/trade.yaml rename to pkg/api/models/trade.yaml diff --git a/pkg/models/trade_order.yaml b/pkg/api/models/trade_order.yaml similarity index 100% rename from pkg/models/trade_order.yaml rename to pkg/api/models/trade_order.yaml diff --git a/pkg/models/trading_account.yaml b/pkg/api/models/trading_account.yaml similarity index 100% rename from pkg/models/trading_account.yaml rename to pkg/api/models/trading_account.yaml diff --git a/pkg/openapi.yaml b/pkg/api/openapi.yaml similarity index 76% rename from pkg/openapi.yaml rename to pkg/api/openapi.yaml index 68adc92..f24ff04 100644 --- a/pkg/openapi.yaml +++ b/pkg/api/openapi.yaml @@ -28,12 +28,12 @@ components: scheme: basic paths: /currencies: - $ref: ./rest/api/currencies_list.yaml + $ref: ./endpoints/currencies_list.yaml /instruments: - $ref: ./rest/api/instruments_list.yaml + $ref: ./endpoints/instruments_list.yaml /order_books/{instrument_name}: - $ref: ./rest/api/order_books.yaml + $ref: ./endpoints/order_books.yaml /trades: - $ref: ./rest/api/trades_list.yaml + $ref: ./endpoints/trades_list.yaml /trade_orders: - $ref: ./rest/api/trade_orders_list.yaml + $ref: ./endpoints/trade_orders_list.yaml diff --git a/pkg/rest/.openapi-generator/FILES b/pkg/rest/.openapi-generator/FILES index 40a6263..fcadc66 100644 --- a/pkg/rest/.openapi-generator/FILES +++ b/pkg/rest/.openapi-generator/FILES @@ -14,5 +14,13 @@ api/error.go api/helpers.go api/impl.go api/logger.go -api/model_get_order_book_200_response.go +api/model_currency.go +api/model_instrument.go +api/model_order_book.go +api/model_price_volume.go +api/model_trade.go +api/model_trade_order.go +api/model_trade_order_side.go +api/model_trade_order_status.go +api/model_trade_order_time_in_force.go api/openapi.yaml diff --git a/pkg/rest/README.md b/pkg/rest/README.md index 2ad018e..6919935 100644 --- a/pkg/rest/README.md +++ b/pkg/rest/README.md @@ -24,7 +24,7 @@ To see how to make this your own, look here: [README](https://openapi-generator.tech) - API version: 1.0.0 -- Build date: 2023-09-05T23:22:31.538915+03:00[Europe/Riga] +- Build date: 2023-11-20T22:33:35.531021+02:00[Europe/Riga] ### Running the server diff --git a/pkg/rest/api/api_order_books_service.go b/pkg/rest/api/api_order_books_service.go index a0d27a3..da44d82 100644 --- a/pkg/rest/api/api_order_books_service.go +++ b/pkg/rest/api/api_order_books_service.go @@ -31,8 +31,8 @@ func (s *OrderBooksAPIService) GetOrderBook(ctx context.Context, instrumentName // TODO - update GetOrderBook with the required logic for this service method. // Add api_order_books_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation. - // TODO: Uncomment the next line to return response Response(200, GetOrderBook200Response{}) or use other options such as http.Ok ... - // return Response(200, GetOrderBook200Response{}), nil + // TODO: Uncomment the next line to return response Response(200, OrderBook{}) or use other options such as http.Ok ... + // return Response(200, OrderBook{}), nil // TODO: Uncomment the next line to return response Response(500, {}) or use other options such as http.Ok ... // return Response(500, nil),nil diff --git a/pkg/rest/api/model_currency.go b/pkg/rest/api/model_currency.go new file mode 100644 index 0000000..a075794 --- /dev/null +++ b/pkg/rest/api/model_currency.go @@ -0,0 +1,30 @@ +/* + * OPEN OUTCRY API + * + * # Introduction This API is documented in **OpenAPI 3.0 format**. This API the following operations: * Retrieve a list of available instruments * Retrieve a list of executed trades # Basics * API calls have to be secured with HTTPS. * All data has to be submitted UTF-8 encoded. * The reply is sent JSON encoded. + * + * API version: 1.0.0 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package api + +// Currency - Currency of payment account +type Currency struct { + + // ISO 4217 Currency symbol + Name *interface{} `json:"name,omitempty"` + + // Currency precision as number of decimal points + Precision *interface{} `json:"precision,omitempty"` +} + +// AssertCurrencyRequired checks if the required fields are not zero-ed +func AssertCurrencyRequired(obj Currency) error { + return nil +} + +// AssertCurrencyConstraints checks if the values respects the defined constraints +func AssertCurrencyConstraints(obj Currency) error { + return nil +} diff --git a/pkg/rest/api/model_instrument.go b/pkg/rest/api/model_instrument.go new file mode 100644 index 0000000..84ea436 --- /dev/null +++ b/pkg/rest/api/model_instrument.go @@ -0,0 +1,36 @@ +/* + * OPEN OUTCRY API + * + * # Introduction This API is documented in **OpenAPI 3.0 format**. This API the following operations: * Retrieve a list of available instruments * Retrieve a list of executed trades # Basics * API calls have to be secured with HTTPS. * All data has to be submitted UTF-8 encoded. * The reply is sent JSON encoded. + * + * API version: 1.0.0 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package api + +type Instrument struct { + Id *interface{} `json:"id,omitempty"` + + // Ticker-like name of the instrument. For monetary instruments, a currency pair is used. + Name *interface{} `json:"name,omitempty"` + + // ISO 4217 Currency symbol + BaseCurrency *interface{} `json:"base_currency,omitempty"` + + // ISO 4217 Currency symbol + QuoteCurrency *interface{} `json:"quote_currency,omitempty"` + + // Availability for trading + Enabled *interface{} `json:"enabled,omitempty"` +} + +// AssertInstrumentRequired checks if the required fields are not zero-ed +func AssertInstrumentRequired(obj Instrument) error { + return nil +} + +// AssertInstrumentConstraints checks if the values respects the defined constraints +func AssertInstrumentConstraints(obj Instrument) error { + return nil +} diff --git a/pkg/rest/api/model_order_book.go b/pkg/rest/api/model_order_book.go new file mode 100644 index 0000000..91ad0dc --- /dev/null +++ b/pkg/rest/api/model_order_book.go @@ -0,0 +1,26 @@ +/* + * OPEN OUTCRY API + * + * # Introduction This API is documented in **OpenAPI 3.0 format**. This API the following operations: * Retrieve a list of available instruments * Retrieve a list of executed trades # Basics * API calls have to be secured with HTTPS. * All data has to be submitted UTF-8 encoded. * The reply is sent JSON encoded. + * + * API version: 1.0.0 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package api + +type OrderBook struct { + Sell *interface{} `json:"sell,omitempty"` + + Buy *interface{} `json:"buy,omitempty"` +} + +// AssertOrderBookRequired checks if the required fields are not zero-ed +func AssertOrderBookRequired(obj OrderBook) error { + return nil +} + +// AssertOrderBookConstraints checks if the values respects the defined constraints +func AssertOrderBookConstraints(obj OrderBook) error { + return nil +} diff --git a/pkg/rest/api/model_price_volume.go b/pkg/rest/api/model_price_volume.go new file mode 100644 index 0000000..615b163 --- /dev/null +++ b/pkg/rest/api/model_price_volume.go @@ -0,0 +1,26 @@ +/* + * OPEN OUTCRY API + * + * # Introduction This API is documented in **OpenAPI 3.0 format**. This API the following operations: * Retrieve a list of available instruments * Retrieve a list of executed trades # Basics * API calls have to be secured with HTTPS. * All data has to be submitted UTF-8 encoded. * The reply is sent JSON encoded. + * + * API version: 1.0.0 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package api + +type PriceVolume struct { + Price *interface{} `json:"price,omitempty"` + + Volume *interface{} `json:"volume,omitempty"` +} + +// AssertPriceVolumeRequired checks if the required fields are not zero-ed +func AssertPriceVolumeRequired(obj PriceVolume) error { + return nil +} + +// AssertPriceVolumeConstraints checks if the values respects the defined constraints +func AssertPriceVolumeConstraints(obj PriceVolume) error { + return nil +} diff --git a/pkg/rest/api/model_trade.go b/pkg/rest/api/model_trade.go new file mode 100644 index 0000000..51de752 --- /dev/null +++ b/pkg/rest/api/model_trade.go @@ -0,0 +1,25 @@ +/* + * OPEN OUTCRY API + * + * # Introduction This API is documented in **OpenAPI 3.0 format**. This API the following operations: * Retrieve a list of available instruments * Retrieve a list of executed trades # Basics * API calls have to be secured with HTTPS. * All data has to be submitted UTF-8 encoded. * The reply is sent JSON encoded. + * + * API version: 1.0.0 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package api + +// Trade - Execute trade +type Trade struct { + Id *interface{} `json:"id,omitempty"` +} + +// AssertTradeRequired checks if the required fields are not zero-ed +func AssertTradeRequired(obj Trade) error { + return nil +} + +// AssertTradeConstraints checks if the values respects the defined constraints +func AssertTradeConstraints(obj Trade) error { + return nil +} diff --git a/pkg/rest/api/model_trade_order.go b/pkg/rest/api/model_trade_order.go new file mode 100644 index 0000000..4c4bb15 --- /dev/null +++ b/pkg/rest/api/model_trade_order.go @@ -0,0 +1,33 @@ +/* + * OPEN OUTCRY API + * + * # Introduction This API is documented in **OpenAPI 3.0 format**. This API the following operations: * Retrieve a list of available instruments * Retrieve a list of executed trades # Basics * API calls have to be secured with HTTPS. * All data has to be submitted UTF-8 encoded. * The reply is sent JSON encoded. + * + * API version: 1.0.0 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package api + +type TradeOrder struct { + Id *interface{} `json:"id,omitempty"` + + // Ticker-like name of the instrument. For monetary instruments, a currency pair is used. + Instrument *interface{} `json:"instrument,omitempty"` + + Side TradeOrderSide `json:"side,omitempty"` + + TimeInForce TradeOrderTimeInForce `json:"timeInForce,omitempty"` + + Status TradeOrderStatus `json:"status,omitempty"` +} + +// AssertTradeOrderRequired checks if the required fields are not zero-ed +func AssertTradeOrderRequired(obj TradeOrder) error { + return nil +} + +// AssertTradeOrderConstraints checks if the values respects the defined constraints +func AssertTradeOrderConstraints(obj TradeOrder) error { + return nil +} diff --git a/pkg/rest/api/model_trade_order_side.go b/pkg/rest/api/model_trade_order_side.go new file mode 100644 index 0000000..82c716f --- /dev/null +++ b/pkg/rest/api/model_trade_order_side.go @@ -0,0 +1,23 @@ +/* + * OPEN OUTCRY API + * + * # Introduction This API is documented in **OpenAPI 3.0 format**. This API the following operations: * Retrieve a list of available instruments * Retrieve a list of executed trades # Basics * API calls have to be secured with HTTPS. * All data has to be submitted UTF-8 encoded. * The reply is sent JSON encoded. + * + * API version: 1.0.0 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package api + +type TradeOrderSide struct { +} + +// AssertTradeOrderSideRequired checks if the required fields are not zero-ed +func AssertTradeOrderSideRequired(obj TradeOrderSide) error { + return nil +} + +// AssertTradeOrderSideConstraints checks if the values respects the defined constraints +func AssertTradeOrderSideConstraints(obj TradeOrderSide) error { + return nil +} diff --git a/pkg/rest/api/model_trade_order_status.go b/pkg/rest/api/model_trade_order_status.go new file mode 100644 index 0000000..297d745 --- /dev/null +++ b/pkg/rest/api/model_trade_order_status.go @@ -0,0 +1,23 @@ +/* + * OPEN OUTCRY API + * + * # Introduction This API is documented in **OpenAPI 3.0 format**. This API the following operations: * Retrieve a list of available instruments * Retrieve a list of executed trades # Basics * API calls have to be secured with HTTPS. * All data has to be submitted UTF-8 encoded. * The reply is sent JSON encoded. + * + * API version: 1.0.0 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package api + +type TradeOrderStatus struct { +} + +// AssertTradeOrderStatusRequired checks if the required fields are not zero-ed +func AssertTradeOrderStatusRequired(obj TradeOrderStatus) error { + return nil +} + +// AssertTradeOrderStatusConstraints checks if the values respects the defined constraints +func AssertTradeOrderStatusConstraints(obj TradeOrderStatus) error { + return nil +} diff --git a/pkg/rest/api/model_trade_order_time_in_force.go b/pkg/rest/api/model_trade_order_time_in_force.go new file mode 100644 index 0000000..6416519 --- /dev/null +++ b/pkg/rest/api/model_trade_order_time_in_force.go @@ -0,0 +1,23 @@ +/* + * OPEN OUTCRY API + * + * # Introduction This API is documented in **OpenAPI 3.0 format**. This API the following operations: * Retrieve a list of available instruments * Retrieve a list of executed trades # Basics * API calls have to be secured with HTTPS. * All data has to be submitted UTF-8 encoded. * The reply is sent JSON encoded. + * + * API version: 1.0.0 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package api + +type TradeOrderTimeInForce struct { +} + +// AssertTradeOrderTimeInForceRequired checks if the required fields are not zero-ed +func AssertTradeOrderTimeInForceRequired(obj TradeOrderTimeInForce) error { + return nil +} + +// AssertTradeOrderTimeInForceConstraints checks if the values respects the defined constraints +func AssertTradeOrderTimeInForceConstraints(obj TradeOrderTimeInForce) error { + return nil +} diff --git a/pkg/rest/api/openapi.yaml b/pkg/rest/api/openapi.yaml index f98f42f..3dfdd09 100644 --- a/pkg/rest/api/openapi.yaml +++ b/pkg/rest/api/openapi.yaml @@ -28,16 +28,7 @@ paths: content: application/json: schema: - description: List of currencies supported by app - items: - description: Currency of payment account - properties: - name: - description: ISO 4217 Currency symbol - example: USD - precision: - description: Currency precision as number of decimal points - example: 2 + $ref: '#/components/schemas/CurrencyList' description: currencies list "500": description: Error @@ -53,21 +44,7 @@ paths: content: application/json: schema: - items: - properties: - id: - format: uuid - name: - description: "Ticker-like name of the instrument. For monetary\ - \ instruments, a currency pair is used." - base_currency: - description: ISO 4217 Currency symbol - example: USD - quote_currency: - description: ISO 4217 Currency symbol - example: USD - enabled: - description: Availability for trading + $ref: '#/components/schemas/InstrumentList' description: instruments list "500": description: Error @@ -84,15 +61,14 @@ paths: name: instrument_name required: true schema: - description: "Ticker-like name of the instrument. For monetary instruments,\ - \ a currency pair is used." + $ref: '#/components/schemas/InstrumentName' style: simple responses: "200": content: application/json: schema: - $ref: '#/components/schemas/getOrderBook_200_response' + $ref: '#/components/schemas/OrderBook' description: order book "500": description: Error @@ -108,12 +84,7 @@ paths: content: application/json: schema: - description: List of executed trades - items: - description: Execute trade - properties: - id: - format: uuid + $ref: '#/components/schemas/TradeList' description: trades list "500": description: Error @@ -129,29 +100,7 @@ paths: content: application/json: schema: - items: - properties: - id: - format: uuid - instrument: - description: "Ticker-like name of the instrument. For monetary\ - \ instruments, a currency pair is used." - side: - enum: - - SELL - - BUY - timeInForce: - enum: - - GTC - - IOC - - FOK - - GTD - - GTT - status: - enum: - - OPEN - - REJECTED - - CANCELLED + $ref: '#/components/schemas/TradeOrderList' description: trades orders list "500": description: Error @@ -160,21 +109,101 @@ paths: - trade_order components: schemas: - getOrderBook_200_response: + CurrencyName: + description: ISO 4217 Currency symbol + example: USD + Currency: + description: Currency of payment account + properties: + name: + description: ISO 4217 Currency symbol + example: USD + precision: + description: Currency precision as number of decimal points + example: 2 + CurrencyList: + description: List of currencies supported by app + items: + $ref: '#/components/schemas/Currency' + Id: + format: uuid + InstrumentName: + description: "Ticker-like name of the instrument. For monetary instruments,\ + \ a currency pair is used." + Instrument: + properties: + id: + format: uuid + name: + description: "Ticker-like name of the instrument. For monetary instruments,\ + \ a currency pair is used." + base_currency: + description: ISO 4217 Currency symbol + example: USD + quote_currency: + description: ISO 4217 Currency symbol + example: USD + enabled: + description: Availability for trading + InstrumentList: + items: + $ref: '#/components/schemas/Instrument' + PriceVolume: + properties: + price: {} + volume: {} + OrderBook: example: sell: "" buy: "" properties: sell: items: - properties: - price: {} - volume: {} + $ref: '#/components/schemas/PriceVolume' buy: items: - properties: - price: {} - volume: {} + $ref: '#/components/schemas/PriceVolume' + Trade: + description: Execute trade + properties: + id: + format: uuid + TradeList: + description: List of executed trades + items: + $ref: '#/components/schemas/Trade' + TradeOrderSide: + enum: + - SELL + - BUY + TradeOrderTimeInForce: + enum: + - GTC + - IOC + - FOK + - GTD + - GTT + TradeOrderStatus: + enum: + - OPEN + - REJECTED + - CANCELLED + TradeOrder: + properties: + id: + format: uuid + instrument: + description: "Ticker-like name of the instrument. For monetary instruments,\ + \ a currency pair is used." + side: + $ref: '#/components/schemas/TradeOrderSide' + timeInForce: + $ref: '#/components/schemas/TradeOrderTimeInForce' + status: + $ref: '#/components/schemas/TradeOrderStatus' + TradeOrderList: + items: + $ref: '#/components/schemas/TradeOrder' securitySchemes: basicAuth: scheme: basic diff --git a/pkg/services/matching_service_market_order_test.go b/pkg/services/matching_service_market_order_test.go index 4376d0a..02558f7 100644 --- a/pkg/services/matching_service_market_order_test.go +++ b/pkg/services/matching_service_market_order_test.go @@ -391,5 +391,4 @@ func (assert *ServiceTestSuite) TestProcessMarketSellOrderWithExistingMarketBuyA assert.Equal(0, GetSellBookOrderCount()) assert.Equal([]PriceVolume{}, GetVolumes("BTC_EUR", models.Buy)) assert.Equal([]PriceVolume{}, GetVolumes("BTC_EUR", models.Sell)) - // } }