This is an API that uses OKX API to estimate trade prices and execute orders.
npm install
docker-compose up
npm run start
npm run test:e2e
OKX_URL=
API_KEY=
SECRET_KEY=
OK_ACCESS_PASSPHRASE=
OPERATING_FEE= 0.0025
SPREAD= 0.005
EXPIRATION_SECONDS= 45
This is an example of how the service works:
This endpoint estimates a price given a pair, volume and side. It returns an estimated price, an estimation expiration date, and an estimation order ID, to execute it later.
POST api/estimate-price/
body: {
"pair": "BTC-USDT",
"volume": 1.2,
"side": "buy"
}
{
"estimatedPrice": 46263.96648,
"expirationDate": "2022-04-05T18:48:57.537Z",
"orderId": 5
}
This endpoint receives an order ID, to execute an estimated order, with its pair and volume. It returns the estimated and executed price.
POST api/execute-order/
body: {
orderId: 5
}
{
"estimatedPrice": 46263.96648,
"executedPrice": 46269.12733
}