# Covario Docs ## Authentication ### Request Token To request an API token, you will need to submit a POST request with the following parameters - client_id - client_secret - grant_type ``` POST /connect/token CONTENT-TYPE application/x-www-form-urlencoded client_id = client1 & client_secret = secret & grant_type = client_credentials ``` ## DMA ### SignalR #### Overview A SignalR hub is used to route orders down to venues. **BaseUrl:** https://api.covar.io/v2/dma/orderHub **Methods:** `PlaceOrder` | `params: PlaceOrderRequest` (Add hyper link to section in which is described) `CancelOrderById` | `params: venueCode, fundId, orderId` ##### How to connect: ``` //Javascript example var connection = new signalR.HubConnectionBuilder() .withUrl(endPoint, { accessTokenFactory: () => token }) .configureLogging(signalR.LogLevel.Debug) .build(); await connection.start() ``` ``` //C# example var token = AuthenticationService.GetAccessToken(); var connection = new HubConnectionBuilder() .WithUrl("https://api.covar.io/v2/dma/orderHub"), options => options.AccessTokenProvider = () => token) .Build(); connection.StartAsync().Wait(); ``` ##### How to listen to an event: To listen to events, before starting the connection event listeners need to be attached to the connecion object like bellow: ``` //Javascript example connection.on("OrderUpdated", (order) => { //Do something with order.data }); connection.on("NewExecution", (execution) => { // do something with (execution.data); }); connection.on("MarginUpdate", (margin) => { //Do something with (margin.data); }); ``` ``` //C# example connection.On<ApiBaseResponse<OrderDTO>>("OrderUpdated", (msg) => { //Do something with msg.data }) connection.On<ApiBaseResponse<ExecutionReportDTO>>("NewExecution", (msg) => { //Do something with msg.data }) connection.On<ApiBaseResponse<MarginReportDTO>>("MarginUpdate", (msg) => { //Do something with msg.data }) ``` ##### SignalR Events to subscribe: `OrderUpdated` `NewExecution` `MarginUpdate` `Heartbeat` #### Place Order Send buy and sell orders direct to connected venues **Parameters** : 1 Parameter - ApiOrderRequest: obj **Signature** : `PlaceOrder(ApiOrderRequest orderRequest)` **Place order request:** Parameter | Required | Type | Enum | Description -----------------|----------|---------|-------------------------------------------------------------|---------------------------------------------------------- clientReference | true | string | | your unique client order reference for tracking purposes venue | true | string | binance, deribit, ftx, kraken | venue where the order should be routed to fundId | true | uuid | uuid | fundId in a guid (uuid) format instrumentType | true | string | spot, options, futures, swaps | type of security to be traded symbol | true | string | | instrument code (i.e BTC-USD-PERP-BTC) side | true | string | buy, sell | direction of order orderType | true | string | market, limit | type of order timeInForce | true | string | GoodTillCancel, DayOrSession, FillOrKill, ImmediateOrCancel | Time in force to define order life cycle price | true | decimal | | limit price to pay on the execution (default = 0) quantity | true | decimal | | amount to buy or sell **Place order request example** ```json // Javascript example var placeOrderRequest = { "fundId":"541cd25b-5810-4631-b97c-e92f54031094", "clientReference":"2ad23bef-ed29-4768-a712-a0ce7e1eb7f6", "venue":"deribit", "symbol":"BTC-USD-PERP-BTC", "price":1000, "quantity":100, "side":"buy", "timeInForce":"GoodTillCancel", "orderType":"limit", "instrumentType":"swaps" } connection.invoke("PlaceOrder", placeOrderRequest) ``` After sending the request you will receive the order acknowledgement and need to subscribe to order update events to receieve further updates. **Order response:** Parameter | Type | Description -------------------|---------|-------------------------------------------------------------------------------------------------- messageType | string | Type of payload received (Order, Rejection, MarginReport, FundingReport, CancelAck, OrderUpdate) clientReference | string | Unique client reference passed erroCode | int | error code (default = 0 (No error)) text | string | Text message when an error happened on the order sending/processing data | obj | Payload response obj (Order) › orderId | uuid | Covario OrderId › clientReference | string | Unique client reference › venue | string | Selected venue › fundId | uuid | Selected fund › instrumentType | string | › symbol | string | Covario instrument code › side | string | Order side (Buy or Sell) › type | string | Market, Limit › timeInForce | string | GoodTillCancel, DayOrSession, FillOrKill, ImmediateOrCancel › price | decimal | default = 0 for market orders › quantity | decimal | Order amount › status | string | Order status › user | string | User email that sent the order › timestamp | string | DateTimeOffset UTC time › text | string | Text message specific to order **Order response example** ```json // Javascript example { "messageType":"Order", "clientReference":"TEST_ORDER:1affdaea-ef6c-48e1-ff43-3a0bffae3b91", "errorCode":0, "text":null, "data":{ "orderId":"77fdeaee-5266-4bfa-b09f-879176407333", "clientReference":"TEST_ORDER:1affdaea-ef6c-48e1-ff43-3a0bffae3b91", "venue":"Deribit", "fundId":"541cd25b-5810-4631-b97c-e92f54031094", "instrumentType":"Swaps", "symbol":"BTC-USD-PERP-BTC", "side":"Buy", "type":"Limit", "timeInForce":"GoodTillCancel", "price":1000, "quantity":100, "status":"PendingNew", "user":"technology@covar.io", "timestamp":"2022-08-04T10:00:46.997328+00:00", "text":null } } ``` #### Cancel Order Send order cancelation direct to connected venues **Signature** : `CancelOrderById(string venue, uuid fundId, uuid orderId)` **Cancel order request:** Parameter | Required | Type | Enum | Description ------------|-----------|---------|-------------------------------|------------------------------------- venueCode | true | string | binance, deribit, ftx, kraken | Name of the counterparty fundId | true | uuid | | Fund where the order was originated orderId | true | uuid | | Unique Covario orderId ``` // Javascript example connection.invoke("CancelOrderById", "deribit", "541cd25b-5810-4631-b97c-92f54031094", "77fdeaee-5266-4bfa-b09f-879176407333") ``` After sending the request an order update message will be received on the websocket ```json { "messageType":"Order", "clientReference":"TEST_ORDER:1affdaea-ef6c-48e1-ff43-3a0bffae3b91", "errorCode":0, "text":"Order 77fdeaee-5266-4bfa-b09f-879176407333, buy @ 1000.0 has been cancelled", "data":{ "orderId":"77fdeaee-5266-4bfa-b09f-879176407333", "clientReference":"TEST_ORDER:1affdaea-ef6c-48e1-ff43-3a0bffae3b91", "venue":"Deribit", "fundId":"541cd25b-5810-4631-b97c-e92f54031094", "instrumentType":"Swaps", "symbol":"BTC-USD-PERP-BTC", "side":"Buy", "type":"Limit", "timeInForce":"GoodTillCancel", "price":1000, "quantity":100, "status":"Canceled", "user":"technology@covar.io", "timestamp":"2022-08-04T10:00:46.997328+00:00", "text":"Order 77fdeaee-5266-4bfa-b09f-879176407333, buy @ 1000.0 has been cancelled" } } ``` ### Rest ### GetOrders ### GetMagins ## MarketData ### Get Orderbooks Used to subscribe to a stream of full snapshots. **Parameters** : 2 Parameters - OrderBook request - Delay between snapshots in milliseconds **Signature** : `GetOrderbook(OrderBookRequest orderBookRequest, int delay)` **Unsubscribe** : ` InvokeAsync("UnsubscribeOrderbook") ` **OrderBook request object** | Parameter | Required | Type | Enum | Description | |----------------|----------|--------|-------------------------------|-------------------------------| | venueCode | true | string | | Name of the counterparty | | instrumentType | true | string | Spot, Options, Futures, Swaps | Type of the instrument | | instrumentCode | true | string | | Code of the instrument | | depth | true | int | | Number of levels to subscribe | **OrderBook request example** ```json { "venueCode": "coinbase", "instrumentType": "Spot", "instrumentCode": "BTC-USD", "depth": 100 } ``` **OrderBook response example** Name | Type | Description ---|---|--- data | object | › asks | array of [price, amount] | List of asks › bids | array of [price, amount] | List of bids ```json { "bids":[["0.07164900","10.97890000"],["0.07164300","0.03510000"],...,["0.07162000","0.69800000"]], "asks":[["0.07165000","5.77460000"],["0.07165200","0.65050000"],...,["0.07166000","0.10760000"]] } ``` **Javascript stream example [Docs](https://docs.microsoft.com/en-us/aspnet/core/signalr/streaming?view=aspnetcore-6.0#javascript-client)** ```js const connection = new HubConnectionBuilder() .withUrl('https://api-test.covar.io/v1/marketdata/realtimeHub', { accessTokenFactory: () => 'YOUR ACCESS TOKEN TOKEN HERE' }).build(); let orderBookRequest = { venueCode: "Coinbase", instrumentCode: "BTC-USD", depth: "100" }; connection.start().then((result) => { connection.stream("GetOrderbook", orderBookRequest, 1000) .subscribe({ next: (item) => { console.log(item); }, complete: () => { console.log("Finished"); }, error: (err) => { console.log(err); } }); }); ``` ### Get Trades Used to subscribe to a stream of trades. **Parameters** : 1 Parameters - Trades request **Signature** : `GetTrades(TradesRequest tradesRequest)` **Unsubscribe** : ` InvokeAsync("UnsubscribeTrades") ` **Trades request object** | Parameter | Type | Enum | Description | |----------------|--------|-------------------------------|--------------------------| | venueCode | string | | Name of the counterparty | | instrumentType | string | Spot, Options, Futures, Swaps | Type of the instrument | | instrumentCode | string | | Code of the instrument | **Trades request example** ```json { "venueCode": "coinbase", "instrumentType": "Spot", "instrumentCode": "BTC-USD" } ``` **Trades response example** | Name | Type | Description | |---------------|-----------|----------------------------------------| | volume | string | Amount of the trade | | price | string | Price of the trade execution | | side | string | Side of the trade | | trade_id | string | Id of the trade in the exchange | | time | timestamp | Timestamp of the trade execution | | time_vendor | timestamp | Timestamp from the exchange | | time_received | timestamp | Timestamp covario received the message | ```json { "volume":"3.84", "price":"3.855", "side":"buy", "trade_id":"571264", "time":"2021-11-08T10:13:19.9457110+00:00" "time_vendor":"2021-11-08T10:13:19.9453110+00:00" "time_received":"2021-11-08T10:13:20.0011391+00:00" } ``` **Javascript stream example [Docs](https://docs.microsoft.com/en-us/aspnet/core/signalr/streaming?view=aspnetcore-6.0#javascript-client)** ```js const connection = new HubConnectionBuilder() .withUrl('https://api-test.covar.io/v1/marketdata/realtimeHub', { accessTokenFactory: () => 'YOUR ACCESS TOKEN TOKEN HERE' }).build(); let tradesRequest = { venueCode: "Coinbase", instrumentCode: "BTC-USD" }; connection.start().then((result) => { connection.stream("GetTrades", tradesRequest) .subscribe({ next: (item) => { console.log(item); }, complete: () => { console.log("Finished"); }, error: (err) => { console.log(err); } }); }); ``` ## Custody **Get Transfer** ---- Get transfer information by id * **URL** `/api/transfer/{transferID}` * **Method:** `GET` * **URL Params** | Parameter | Type | Enum | Description | |----------------|--------|-------------------------------|------------------------| | transferId | GUID | | Id of the transfer | * **Success Response:** | Name | Type | Enum | Description | |-----------------------|-----------------|------|-------------------------------------------------| | id | string | | Id of the transfer | | vendorTransactionId | string | | Fireblocks transaction ID | | fundId | GUID | | Id of the fund | | senderId | GUID | | Id of the sender account | | receiverId | GUID | | Id of the receiver account | | asset | string | | Asset that has been transferred | | requestedAmount | decimal | | Amount requested to transfer | | grossAmount | decimal | | Gross amount | | netAmount | decimal | | Net received amount | | transactionFees | arrayof TransactionFees | | Fees object | | status | string | SUBMITTED, QUEUED, PENDING_AUTHORIZATION, PENDING_SIGNATURE, BROADCASTING, PENDING_3RD_PARTY_MANUAL_APPROVAL, PENDING_3RD_PARTY, CONFIRMING, PENDING_AML_CHECKUP, PARTIALLY_COMPLETED, PENDING_AML_SCREENING, COMPLETED, CANCELLED, REJECTED, BLOCKED, FAILED | Status of the transfer | | subStatus | string | | Substatus of the transfer | | createdBy | string | | Email of the transfer initiator | | createdAt | Timestamp | | Time the transfer initiated | | updatedAt | Timestamp | | Last transfer update | | numberOfConfirmations | int | | Number of confirmations needed for the transfer | | comment | string | | Comment of the transfer | | type | string | | Type of the transfer | | sequence | int | | Sequence of the transfer | | parentTransactionId | GUID? | | Parent ID in case of multileg transfer | | childTransactions | arrayof GUID | | Id of children transaction in case of multileg | TransactionFees: | Name | Type | Enum | Description | |-----------------------|-----------------|------|-------------------------------------------------| | id | string | | Id of the fee | | transactionId | string | | Id of the transfer | | feeType | string | | Type of the fee | | asset | string | | Fee currency for the fee | | amount | Decimal | | Amount of the fee | * **Code:** 200 <br /> **Content:** ``` { "id": "string", "vendorTransactionId": "string", "fundId": "string", "senderId": "string", "receiverId": "string", "asset": "string", "requestedAmount": 0, "grossAmount": 0, "netAmount": 0, "transactionFees": [ { "id": "string", "transactionId": "string", "feeType": "string", "asset": "string", "amount": 0 } ], "status": "UNKNOWN", "subStatus": "string", "createdBy": "string", "createdAt": "2022-08-04T09:19:15.722Z", "updatedAt": "2022-08-04T09:19:15.722Z", "numberOfConfirmations": 0, "comment": "string", "type": "STANDARD", "sequence": 0, "parentTransactionId": "string", "childTransactions": [ "string" ] } ``` * **Error Response:** * **Code:** 401 UNAUTHORIZED <br /> * **Sample Call:** ``` curl -X 'GET' \ 'https://baseURL/api/transfers/0000-0000-0000-0000' \ -H 'accept: application/json' ``` **Get Transfer** ---- Get transfers information * **URL** `/api/transfers` * **Method:** `GET` * **Success Response:** | Name | Type | Enum | Description | |-----------------------|-----------------|------|-------------------------------------------------| | data | array | | List of transfers | | > id | string | | Id of the transfer | | > vendorTransactionId | string | | Fireblocks transaction ID | | > fundId | GUID | | Id of the fund | | > senderId | GUID | | Id of the sender account | | > receiverId | GUID | | Id of the receiver account | | > asset | string | | Asset that has been transferred | | > requestedAmount | decimal | | Amount requested to transfer | | > grossAmount | decimal | | Gross amount | | > netAmount | decimal | | Net received amount | | > transactionFees | arrayof TransactionFees | | Fees object | | > status | string | SUBMITTED, QUEUED, PENDING_AUTHORIZATION, PENDING_SIGNATURE, BROADCASTING, PENDING_3RD_PARTY_MANUAL_APPROVAL, PENDING_3RD_PARTY, CONFIRMING, PENDING_AML_CHECKUP, PARTIALLY_COMPLETED, PENDING_AML_SCREENING, COMPLETED, CANCELLED, REJECTED, BLOCKED, FAILED | Status of the transfer | | > subStatus | string | | Substatus of the transfer | | > createdBy | string | | Email of the transfer initiator | | > createdAt | Timestamp | | Time the transfer initiated | | > updatedAt | Timestamp | | Last transfer update | | > numberOfConfirmations | int | | Number of confirmations needed for the transfer | | > comment | string | | Comment of the transfer | | > type | string | | Type of the transfer | | > sequence | int | | Sequence of the transfer | | > parentTransactionId | GUID? | | Parent ID in case of multileg transfer | | > childTransactions | arrayof GUID | | Id of children transaction in case of multileg | TransactionFees: | Name | Type | Enum | Description | |-----------------------|-----------------|------|-------------------------------------------------| | id | string | | Id of the fee | | transactionId | string | | Id of the transfer | | feeType | string | | Type of the fee | | asset | string | | Fee currency for the fee | | amount | Decimal | | Amount of the fee | * **Code:** 200 <br /> **Content:** ``` [ { "id": "string", "vendorTransactionId": "string", "fundId": "string", "senderId": "string", "receiverId": "string", "asset": "string", "requestedAmount": 0, "grossAmount": 0, "netAmount": 0, "transactionFees": [ { "id": "string", "transactionId": "string", "feeType": "string", "asset": "string", "amount": 0 } ], "status": "UNKNOWN", "subStatus": "string", "createdBy": "string", "createdAt": "2022-08-04T12:29:52.730Z", "updatedAt": "2022-08-04T12:29:52.730Z", "numberOfConfirmations": 0, "comment": "string", "type": "STANDARD", "sequence": 0, "parentTransactionId": "string", "childTransactions": [ "string" ] } ] ``` * **Error Response:** * **Code:** 401 UNAUTHORIZED <br /> * **Sample Call:** ``` curl -X 'GET' \ 'https://baseURL/api/transfers' \ -H 'accept: application/json' ``` **Create transfer** ---- initiate a transfer of assets. * **URL** `/api/transfers` * **Method:** `POST` * **Body Params** | Parameter | Type | Enum | Description | |------------|---------|------|----------------------------| | senderId | GUID | | Account id of the sender | | receiverId | GUID | | Account id of the receiver | | asset | string | | Asset to be transferred | | amount | decimal | | Amount to transfer | ``` { "senderId": "0000-0000-0000-0000", "receiverId": "0000-0000-0000-0000", "asset": "BTC", "amount": 1 } ``` * **Success Response:** * **Code:** 200 <br /> **Content:** ``` { "success": true, "status": "Initiated", "message": "", "entryId": "0000-0000-0000-0000" } ``` * **Error Response:** * **Code:** 401 UNAUTHORIZED <br /> * **Sample Call:** ``` curl -X 'POST' \ 'http://10.10.11.108/api/transfers' \ -H 'accept: application/json' \ -H 'Authorization: Bearer 897C5E42D8CB4E705F4AED5412B8D440381DC9B334B26469480621996DB806C1' \ -H 'Content-Type: application/json' \ -d '{ "senderId": "0000-0000-0000-0000", "receiverId": "0000-0000-0000-0000", "asset": "BTC", "amount": 1 }' ``` ## Instruments **Get Spot instruments** ---- Get a list of spot instruments * **URL** `api/instruments/spot` * **Method:** `GET` * **Success Response:** | Name | Type | Enum | Description | |-----------------------|-----------------|------|-------------------------------------------------| | symbol | string | | Code of the instrument | | base | string | | Base currency | | quote | string | | Quote currency | | active | bool | | Active state | * **Code:** 200 <br /> **Content:** ``` [ { "symbol": "string", "base": "string", "quote": "string", "active": true } ] ``` * **Error Response:** * **Code:** 401 UNAUTHORIZED <br /> * **Sample Call:** ``` curl -X 'GET' \ 'https://api-test.covar.io/v2/api/instruments/spot' \ -H 'accept: text/plain' ``` **Get Futures instruments** ---- Get a list of spot future instruments * **URL** `api/instruments/future` * **Method:** `GET` * **Success Response:** | Name | Type | Enum | Description | |-----------------------|-----------------|------|-------------------------------------------------| | symbol | string | | Code of the instrument | | base | string | | Base currency | | quote | string | | Quote currency | | active | bool | | Active state | * **Code:** 200 <br /> **Content:** ``` [ { "symbol": "string", "base": "string", "quote": "string", "active": true } ] ``` * **Error Response:** * **Code:** 401 UNAUTHORIZED <br /> * **Sample Call:** ``` curl -X 'GET' \ 'https://api-test.covar.io/v2/api/instruments/future' \ -H 'accept: text/plain' ``` **Get Options instruments** ---- Get a list of spot options instruments * **URL** `api/instruments/option` * **Method:** `GET` * **Success Response:** | Name | Type | Enum | Description | |-----------------------|-----------------|------|-------------------------------------------------| | symbol | string | | Code of the instrument | | base | string | | Base currency | | quote | string | | Quote currency | | active | bool | | Active state | * **Code:** 200 <br /> **Content:** ``` [ { "symbol": "string", "base": "string", "quote": "string", "active": true } ] ``` * **Error Response:** * **Code:** 401 UNAUTHORIZED <br /> * **Sample Call:** ``` curl -X 'GET' \ 'https://api-test.covar.io/v2/api/instruments/option' \ -H 'accept: text/plain' ```