triangular_arbitrage_bot/src/rest_client.h

46 lines
1.6 KiB
C

#ifndef REST_CLIENT_H
#define REST_CLIENT_H
#include <stdbool.h>
#include <stddef.h>
/* Keepalive HTTPS connection for KuCoin REST API. */
typedef struct rest_conn_s rest_conn_t;
/* Create a REST connection handle. Does not connect yet. */
rest_conn_t *rest_conn_new(void);
/* Set the API credentials. Must be called before any request. */
void rest_conn_set_auth(rest_conn_t *rc,
const char *api_key,
const char *api_secret,
const char *api_passphrase);
/* Place a market order.
Returns true on success and fills out_order_id.
Returns false and fills out_error (up to err_sz) on failure. */
bool rest_order_place(rest_conn_t *rc,
const char *symbol, const char *side,
double funds, double size,
const char *client_oid,
char *out_order_id, size_t out_sz,
char *out_error, size_t err_sz);
/* Validate an order via the test endpoint.
Returns true if the order would be accepted. */
bool rest_order_test(rest_conn_t *rc,
const char *symbol, const char *side,
double funds, double size,
char *out_error, size_t err_sz);
/* Fetch available balance for a currency (GET /api/v1/accounts).
Returns true and writes the available amount to *out on success. */
bool rest_get_balance(rest_conn_t *rc,
const char *currency,
double *out);
/* Close the connection and free resources. */
void rest_conn_free(rest_conn_t *rc);
#endif