Skip to content

Commit

Permalink
Add market API wrapper methods and response types (#63)
Browse files Browse the repository at this point in the history
* Add oatpp code generators for market API calls.

* Add market API wrapper methods and response types.

* Implement market API wrapper methods.

This is a partial implementation.
  • Loading branch information
krazkidd authored Jul 16, 2024
1 parent 3e37d7d commit fa9a585
Show file tree
Hide file tree
Showing 4 changed files with 590 additions and 0 deletions.
14 changes: 14 additions & 0 deletions include/api/Api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ namespace kdeck
std::shared_ptr<ExchangeScheduleResponse> GetExchangeSchedule();

Check warning on line 31 in include/api/Api.hpp

View workflow job for this annotation

GitHub Actions / cpp-linter

include/api/Api.hpp:31:51 [modernize-use-trailing-return-type]

use a trailing return type for this function
std::shared_ptr<ExchangeStatusResponse> GetExchangeStatus();

Check warning on line 32 in include/api/Api.hpp

View workflow job for this annotation

GitHub Actions / cpp-linter

include/api/Api.hpp:32:49 [modernize-use-trailing-return-type]

use a trailing return type for this function

// market
std::shared_ptr<EventsResponse> GetEvents();

Check warning on line 35 in include/api/Api.hpp

View workflow job for this annotation

GitHub Actions / cpp-linter

include/api/Api.hpp:35:41 [modernize-use-trailing-return-type]

use a trailing return type for this function
std::shared_ptr<EventResponse> GetEvent(std::string_view eventTicker);

Check warning on line 36 in include/api/Api.hpp

View workflow job for this annotation

GitHub Actions / cpp-linter

include/api/Api.hpp:36:40 [modernize-use-trailing-return-type]

use a trailing return type for this function
std::shared_ptr<MarketsResponse> GetMarkets();

Check warning on line 37 in include/api/Api.hpp

View workflow job for this annotation

GitHub Actions / cpp-linter

include/api/Api.hpp:37:42 [modernize-use-trailing-return-type]

use a trailing return type for this function
std::shared_ptr<TradesResponse> GetTrades();

Check warning on line 38 in include/api/Api.hpp

View workflow job for this annotation

GitHub Actions / cpp-linter

include/api/Api.hpp:38:41 [modernize-use-trailing-return-type]

use a trailing return type for this function
std::shared_ptr<MarketResponse> GetMarket(std::string_view marketTicker);

Check warning on line 39 in include/api/Api.hpp

View workflow job for this annotation

GitHub Actions / cpp-linter

include/api/Api.hpp:39:41 [modernize-use-trailing-return-type]

use a trailing return type for this function
std::shared_ptr<MarketOrderbookResponse> GetMarketOrderbook(std::string_view marketTicker);

Check warning on line 40 in include/api/Api.hpp

View workflow job for this annotation

GitHub Actions / cpp-linter

include/api/Api.hpp:40:50 [modernize-use-trailing-return-type]

use a trailing return type for this function
std::shared_ptr<SeriesResponse> GetSeries(std::string_view seriesTicker);

Check warning on line 41 in include/api/Api.hpp

View workflow job for this annotation

GitHub Actions / cpp-linter

include/api/Api.hpp:41:41 [modernize-use-trailing-return-type]

use a trailing return type for this function
std::shared_ptr<MarketCandlesticksResponse> GetMarketCandlesticks(std::string_view seriesTicker, std::string_view marketTicker);

// portfolio
double GetBalance();
std::shared_ptr<PortfolioPositionsResponse> GetPositions();
Expand All @@ -54,6 +64,10 @@ namespace kdeck
std::shared_ptr<ExchangeScheduleResponse> schedule;
std::shared_ptr<ExchangeStatusResponse> status;

// market
std::shared_ptr<EventsResponse> events;
std::shared_ptr<MarketsResponse> markets;

// portfolio
std::shared_ptr<PortfolioBalanceResponse> balance;
std::shared_ptr<PortfolioPositionsResponse> positions;
Expand Down
51 changes: 51 additions & 0 deletions include/api/_Api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,57 @@ namespace kdeck
}
API_CALL("GET", "{basePath}/exchange/status", GetExchangeStatus, PATH(String, basePath))

// market ///////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////

API_CALL_HEADERS(GetEvents)
{
headers.put("Accept", "application/json");
}
API_CALL("GET", "{basePath}/events", GetEvents, PATH(String, basePath), QUERY(Object<EventsRequest>, eventsRequest))

API_CALL_HEADERS(GetEvent)
{
headers.put("Accept", "application/json");
}
API_CALL("GET", "{basePath}/events/{event_ticker}", GetEvent, PATH(String, basePath), PATH(String, event_ticker), QUERY(Object<EventRequest>, eventRequest))

API_CALL_HEADERS(GetMarkets)
{
headers.put("Accept", "application/json");
}
API_CALL("GET", "{basePath}/markets", GetMarkets, PATH(String, basePath), AUTHORIZATION(String, authString, "Bearer"), QUERY(Object<MarketsRequest>, marketsRequest))

API_CALL_HEADERS(GetTrades)
{
headers.put("Accept", "application/json");
}
API_CALL("GET", "{basePath}/markets/trades", GetTrades, PATH(String, basePath), QUERY(Object<TradesRequest>, tradesRequest))

API_CALL_HEADERS(GetMarket)
{
headers.put("Accept", "application/json");
}
API_CALL("GET", "{basePath}/markets/{ticker}", GetMarket, PATH(String, basePath), PATH(String, ticker))

API_CALL_HEADERS(GetMarketOrderbook)
{
headers.put("Accept", "application/json");
}
API_CALL("GET", "{basePath}/markets/{ticker}/orderbook", GetMarketOrderbook, PATH(String, basePath), AUTHORIZATION(String, authString, "Bearer"), QUERY(String, ticker), QUERY(Object<MarketOrderbookRequest>, marketOrderbookRequest))

API_CALL_HEADERS(GetSeries)
{
headers.put("Accept", "application/json");
}
API_CALL("GET", "{basePath}/series/{series_ticker}", GetSeries, PATH(String, basePath), PATH(String, series_ticker))

API_CALL_HEADERS(GetMarketCandlesticks)
{
headers.put("Accept", "application/json");
}
API_CALL("GET", "{basePath}/series/{series_ticker}/markets/{ticker}/candlesticks", GetMarketCandlesticks, PATH(String, basePath), AUTHORIZATION(String, authString, "Bearer"), PATH(String, series_ticker), PATH(String, ticker), QUERY(Object<MarketCandlesticksRequest>, marketCandlesticksRequest))

// portfolio ////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////

Expand Down
Loading

0 comments on commit fa9a585

Please sign in to comment.