Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add market API wrapper methods and response types #63

Merged
merged 3 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions include/api/Api.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef API_HPP

Check notice on line 1 in include/api/Api.hpp

View workflow job for this annotation

GitHub Actions / cpp-linter

Run clang-format on include/api/Api.hpp

File include/api/Api.hpp does not conform to LLVM style guidelines. (lines 4, 12, 15, 16, 17, 18, 20, 21, 22, 23, 25, 26, 27, 29, 30, 31, 32, 34, 35, 36, 37, 38, 39, 40, 41, 42, 44, 45, 46, 48, 49, 51, 52, 54, 55, 56, 57, 59, 60, 62, 63, 64, 65, 67, 68, 69, 71, 72, 73, 75, 76, 78, 79, 80, 83)
#define API_HPP

#include <map>
Expand All @@ -7,7 +7,7 @@
#include <list>
#include <variant>

#include "oatpp/parser/json/mapping/ObjectMapper.hpp"

Check failure on line 10 in include/api/Api.hpp

View workflow job for this annotation

GitHub Actions / cpp-linter

include/api/Api.hpp:10:10 [clang-diagnostic-error]

'oatpp/parser/json/mapping/ObjectMapper.hpp' file not found

#include "api/types.hpp"
#include "api/_Api.hpp"
Expand All @@ -27,10 +27,20 @@
void Logout();

// exchange
std::shared_ptr<ExchangeAnnouncementsResponse> GetExchangeAnnouncements();

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

View workflow job for this annotation

GitHub Actions / cpp-linter

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

use a trailing return type for this function
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 @@
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
@@ -1,7 +1,7 @@
#ifndef _API_HPP

Check notice on line 1 in include/api/_Api.hpp

View workflow job for this annotation

GitHub Actions / cpp-linter

Run clang-format on include/api/_Api.hpp

File include/api/_Api.hpp does not conform to LLVM style guidelines. (lines 8, 9, 10, 12, 13, 14, 16, 18, 19, 21, 22, 24, 25, 26, 27, 28, 29, 31, 32, 33, 34, 35, 36, 38, 39, 41, 42, 43, 44, 45, 46, 48, 49, 50, 51, 52, 53, 55, 56, 57, 58, 59, 60, 62, 63, 65, 66, 67, 68, 69, 71, 72, 73, 74, 75, 77, 78, 79, 80, 81, 83, 84, 85, 86, 87, 89, 90, 91, 92, 93, 95, 96, 97, 98, 99, 101, 102, 103, 104, 105, 107, 108, 109, 110, 111, 113, 114, 116, 117, 118, 119, 120, 121, 123, 124, 125, 126, 127, 128, 130, 134)
#define _API_HPP

#include "oatpp/core/macro/codegen.hpp"

Check failure on line 4 in include/api/_Api.hpp

View workflow job for this annotation

GitHub Actions / cpp-linter

include/api/_Api.hpp:4:10 [clang-diagnostic-error]

'oatpp/core/macro/codegen.hpp' file not found
#include "oatpp/parser/json/mapping/ObjectMapper.hpp"
#include "oatpp/web/client/ApiClient.hpp"

Expand Down Expand Up @@ -59,6 +59,57 @@
}
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
Loading