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 portfolio API code generators, wrapper methods, and request/response types. #64

Merged
merged 1 commit into from
Jul 21, 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
8 changes: 8 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, 47, 48, 49, 50, 51, 52, 53, 54, 56, 57, 59, 60, 62, 63, 64, 65, 67, 68, 70, 71, 72, 73, 75, 76, 77, 79, 80, 81, 83, 84, 86, 87, 88, 91)
#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,23 +27,31 @@
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<FillsResponse> GetFills();
std::shared_ptr<OrdersResponse> GetOrders();
std::shared_ptr<OrderResponse> CreateOrder();
std::shared_ptr<OrderResponse> GetOrder(std::string_view orderId);
std::shared_ptr<CancelOrderResponse> CancelOrder(std::string_view orderId);
std::shared_ptr<AmendOrderResponse> AmendOrder(std::string_view orderId);
std::shared_ptr<OrderResponse> DecreaseOrder(std::string_view orderId);
std::shared_ptr<PortfolioPositionsResponse> GetPositions();
std::shared_ptr<PortfolioSettlementsResponse> GetPortfolioSettlements();

// helpers
bool IsLoggedIn();
Expand Down
56 changes: 56 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, 17, 19, 21, 22, 24, 25, 26, 27, 28, 29, 31, 32, 33, 34, 35, 36, 38, 39, 41, 42, 43, 44, 45, 47, 48, 49, 50, 51, 53, 54, 55, 56, 57, 59, 60, 62, 63, 64, 65, 66, 67, 69, 70, 71, 72, 73, 74, 76, 77, 78, 79, 80, 81, 83, 84, 85, 86, 87, 88, 90, 91, 92, 93, 94, 96, 97, 98, 99, 100, 101, 103, 104, 105, 106, 107, 109, 110, 111, 112, 113, 114, 116, 117, 119, 120, 121, 122, 123, 125, 126, 127, 128, 129, 130, 132, 133, 134, 135, 136, 137, 139, 140, 141, 142, 143, 144, 146, 147, 148, 149, 150, 151, 153, 154, 155, 156, 157, 158, 160, 161, 162, 163, 164, 165, 167, 168, 169, 170, 171, 172, 174, 175, 176, 177, 178, 179, 181, 182, 183, 184, 185, 186, 188, 192)
#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 @@ -122,13 +122,69 @@
}
API_CALL("GET", "{basePath}/portfolio/balance", GetBalance, PATH(String, basePath), AUTHORIZATION(String, authString, "Bearer"))

API_CALL_HEADERS(GetFills)
{
headers.put("Content-Type", "application/json");
headers.put("Accept", "application/json");
}
API_CALL("GET", "{basePath}/portfolio/fills", GetFills, PATH(String, basePath), AUTHORIZATION(String, authString, "Bearer"), BODY_DTO(Object<FillsRequest>, req))

API_CALL_HEADERS(GetOrders)
{
headers.put("Content-Type", "application/json");
headers.put("Accept", "application/json");
}
API_CALL("GET", "{basePath}/portfolio/orders", GetOrders, PATH(String, basePath), AUTHORIZATION(String, authString, "Bearer"), BODY_DTO(Object<OrdersRequest>, req))

API_CALL_HEADERS(CreateOrder)
{
headers.put("Content-Type", "application/json");
headers.put("Accept", "application/json");
}
API_CALL("POST", "{basePath}/portfolio/orders", CreateOrder, PATH(String, basePath), AUTHORIZATION(String, authString, "Bearer"), BODY_DTO(Object<CreateOrderRequest>, req))

API_CALL_HEADERS(GetOrder)
{
headers.put("Content-Type", "application/json");
headers.put("Accept", "application/json");
}
API_CALL("GET", "{basePath}/portfolio/orders/{order_id}", GetOrder, PATH(String, basePath), AUTHORIZATION(String, authString, "Bearer"), PATH(String, order_id))

API_CALL_HEADERS(CancelOrder)
{
headers.put("Content-Type", "application/json");
headers.put("Accept", "application/json");
}
API_CALL("DELETE", "{basePath}/portfolio/orders/{order_id}", CancelOrder, PATH(String, basePath), AUTHORIZATION(String, authString, "Bearer"), PATH(String, order_id))

API_CALL_HEADERS(AmendOrder)
{
headers.put("Content-Type", "application/json");
headers.put("Accept", "application/json");
}
API_CALL("POST", "{basePath}/portfolio/orders/{order_id}/amend", AmendOrder, PATH(String, basePath), AUTHORIZATION(String, authString, "Bearer"), PATH(String, order_id), BODY_DTO(Object<AmendOrderRequest>, req))

API_CALL_HEADERS(DecreaseOrder)
{
headers.put("Content-Type", "application/json");
headers.put("Accept", "application/json");
}
API_CALL("POST", "{basePath}/portfolio/orders/{order_id}/decrease", DecreaseOrder, PATH(String, basePath), AUTHORIZATION(String, authString, "Bearer"), PATH(String, order_id), BODY_DTO(Object<DecreaseOrderRequest>, req))

API_CALL_HEADERS(GetPositions)
{
headers.put("Content-Type", "application/json");
headers.put("Accept", "application/json");
}
API_CALL("GET", "{basePath}/portfolio/positions", GetPositions, PATH(String, basePath), AUTHORIZATION(String, authString, "Bearer"), BODY_DTO(Object<PortfolioPositionsRequest>, portfolioPositionsRequest))

API_CALL_HEADERS(GetPortfolioSettlements)
{
headers.put("Content-Type", "application/json");
headers.put("Accept", "application/json");
}
API_CALL("GET", "{basePath}/portfolio/settlements", GetPortfolioSettlements, PATH(String, basePath), AUTHORIZATION(String, authString, "Bearer"), BODY_DTO(Object<PortfolioSettlementsRequest>, req))

};

#include OATPP_CODEGEN_END(ApiClient)
Expand Down
227 changes: 227 additions & 0 deletions include/api/types.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef TYPES_HPP

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

View workflow job for this annotation

GitHub Actions / cpp-linter

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

File include/api/types.hpp does not conform to LLVM style guidelines. (lines 4, 7, 8, 10, 11, 12, 13, 15, 17, 18, 19, 21, 23, 25, 26, 27, 29, 31, 32, 33, 35, 37, 38, 39, 41, 43, 45, 47, 48, 50, 51, 52, 54, 56, 57, 59, 61, 62, 63, 65, 67, 68, 70, 72, 73, 75, 76, 77, 79, 81, 82, 83, 84, 86, 88, 89, 90, 92, 94, 95, 97, 99, 100, 101, 103, 105, 106, 108, 110, 111, 112, 114, 116, 117, 118, 119, 120, 121, 122, 124, 126, 127, 128, 130, 132, 133, 135, 137, 138, 139, 141, 143, 145, 147, 148, 149, 151, 153, 155, 157, 158, 159, 161, 163, 164, 166, 168, 169, 171, 172, 173, 175, 177, 178, 179, 180, 181, 183, 185, 186, 187, 189, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 236, 238, 239, 240, 242, 244, 245, 246, 247, 248, 249, 250, 251, 252, 254, 256, 257, 258, 260, 262, 263, 265, 267, 268, 269, 271, 273, 275, 277, 278, 279, 281, 283, 285, 287, 288, 289, 291, 293, 294, 296, 298, 299, 300, 302, 304, 305, 306, 307, 308, 309, 310, 311, 313, 315, 316, 317, 319, 321, 322, 323, 324, 325, 326, 327, 329, 331, 332, 333, 335, 337, 338, 340, 342, 343, 344, 346, 348, 349, 350, 351, 352, 354, 356, 357, 358, 360, 362, 364, 366, 367, 368, 370, 372, 373, 375, 377, 378, 379, 381, 383, 385, 387, 388, 389, 391, 393, 395, 397, 398, 399, 401, 403, 404, 406, 408, 409, 410, 412, 414, 415, 416, 417, 418, 419, 420, 422, 424, 425, 426, 428, 430, 432, 434, 435, 436, 438, 440, 441, 442, 443, 444, 445, 447, 449, 450, 451, 453, 455, 456, 457, 458, 460, 462, 463, 464, 466, 468, 469, 470, 471, 473, 475, 476, 477, 479, 481, 482, 483, 484, 485, 486, 487, 489, 491, 492, 493, 495, 497, 498, 499, 501, 503, 504, 505, 507, 509, 510, 511, 513, 515, 516, 518, 519, 520, 521, 523, 524, 525, 527, 529, 530, 531, 533, 535, 536, 537, 538, 539, 540, 542, 544, 545, 546, 548, 550, 551, 552, 553, 554, 555, 556, 557, 558, 560, 562, 563, 564, 566, 568, 569, 571, 573, 574, 575, 577, 579, 580, 581, 582, 583, 584, 585, 587, 589, 590, 591, 593, 595, 596, 597, 598, 599, 600, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621, 622, 624, 626, 627, 628, 630, 632, 633, 635, 637, 638, 639, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 655, 657, 658, 659, 661, 663, 665, 667, 668, 669, 671, 673, 674, 676, 678, 679, 680, 682, 684, 685, 686, 687, 688, 689, 690, 691, 693, 695, 696, 697, 699, 701, 702, 704, 706, 707, 708, 710, 712, 713, 715, 717, 718, 719, 721, 723, 724, 725, 726, 727, 728, 730, 732, 733, 734, 736, 738, 739, 740, 741, 742, 743, 745, 747, 748, 749, 751, 753, 754, 755, 756, 757, 758, 759, 761, 763, 764, 765, 767, 769, 770, 771, 773, 775, 776, 777, 779, 781, 782, 784, 786, 787, 788, 790, 792, 793, 794, 795, 796, 797, 798, 799, 801, 803, 804, 805, 807, 809, 810, 812, 816)
#define TYPES_HPP

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

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

View workflow job for this annotation

GitHub Actions / cpp-linter

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

'oatpp/core/macro/codegen.hpp' file not found
#include "oatpp/core/Types.hpp"

namespace kdeck
Expand Down Expand Up @@ -526,6 +526,194 @@

};

class FillsRequest
: public oatpp::DTO
{

DTO_INIT(FillsRequest, DTO /* extends */)

DTO_FIELD(String, ticker);
DTO_FIELD(String, order_id);
DTO_FIELD(Int64, min_ts);
DTO_FIELD(Int64, max_ts);
DTO_FIELD(Int32, limit);
DTO_FIELD(String, cursor);

};

class Fill
: public oatpp::DTO
{

DTO_INIT(Fill, DTO /* extends */)

DTO_FIELD(String, action);
DTO_FIELD(Int32, count);
DTO_FIELD(DateTime_Iso8601, created_time);
DTO_FIELD(Boolean, is_taker);
DTO_FIELD(Int64, no_price);
DTO_FIELD(String, order_id);
DTO_FIELD(String, side);
DTO_FIELD(String, ticker);
DTO_FIELD(Int64, yes_price);

};

class FillsResponse
: public oatpp::DTO
{

DTO_INIT(FillsResponse, DTO /* extends */)

DTO_FIELD(String, cursor);
DTO_FIELD(Object<Fill>, fills);

};

class OrdersRequest
: public oatpp::DTO
{

DTO_INIT(OrdersRequest, DTO /* extends */)

DTO_FIELD(String, ticker);
DTO_FIELD(String, event_ticker);
DTO_FIELD(Int64, min_ts);
DTO_FIELD(Int64, max_ts);
DTO_FIELD(String, status);
DTO_FIELD(String, cursor);
DTO_FIELD(Int32, limit);

};

class Order
: public oatpp::DTO
{

DTO_INIT(Order, DTO /* extends */)

DTO_FIELD(String, action);
DTO_FIELD(Int32, amend_count);
DTO_FIELD(Int32, amend_taker_fill_count);
DTO_FIELD(String, client_order_id);
DTO_FIELD(Int32, close_cancel_count);
DTO_FIELD(DateTime_Iso8601, created_time);
DTO_FIELD(Int32, decrease_count);
DTO_FIELD(DateTime_Iso8601, expiration_time);
DTO_FIELD(Int32, fcc_cancel_count);
DTO_FIELD(DateTime_Iso8601, last_update_time);
DTO_FIELD(Int64, maker_fees);
DTO_FIELD(Int64, maker_fill_cost);
DTO_FIELD(Int32, maker_fill_count);
DTO_FIELD(Int64, no_price);
DTO_FIELD(String, order_id);
DTO_FIELD(Int32, place_count);
DTO_FIELD(Int32, queue_position);
DTO_FIELD(Int32, remaining_count);
DTO_FIELD(String, side);
DTO_FIELD(String, status);
DTO_FIELD(Int64, taker_fees);
DTO_FIELD(Int64, taker_fill_cost);
DTO_FIELD(Int32, taker_fill_count);
DTO_FIELD(Int32, taker_self_trade_cancel_count);
DTO_FIELD(String, ticker);
DTO_FIELD(String, type);
DTO_FIELD(String, user_id);
DTO_FIELD(Int64, yes_price);

};

class OrdersResponse
: public oatpp::DTO
{

DTO_INIT(OrdersResponse, DTO /* extends */)

DTO_FIELD(String, cursor);
DTO_FIELD(List<Object<Order>>, orders);

};

class CreateOrderRequest
: public oatpp::DTO
{

DTO_INIT(CreateOrderRequest, DTO /* extends */)

DTO_FIELD(String, action);
DTO_FIELD(Int64, buy_max_cost);
DTO_FIELD(String, client_order_id);
DTO_FIELD(Int32, count);
DTO_FIELD(Int64, expiration_ts);
DTO_FIELD(Int64, no_price);
DTO_FIELD(Int32, sell_position_floor);
DTO_FIELD(String, side);
DTO_FIELD(String, ticker);
DTO_FIELD(String, type);
DTO_FIELD(Int64, yes_price);

};

class OrderResponse
: public oatpp::DTO
{

DTO_INIT(OrderResponse, DTO /* extends */)

DTO_FIELD(Object<Order>, order);

};

class CancelOrderResponse
: public oatpp::DTO
{

DTO_INIT(CancelOrderResponse, DTO /* extends */)

DTO_FIELD(Object<Order>, order);
DTO_FIELD(Int32, reduced_by);

};

class AmendOrderRequest
: public oatpp::DTO
{

DTO_INIT(AmendOrderRequest, DTO /* extends */)

DTO_FIELD(String, action);
DTO_FIELD(String, client_order_id);
DTO_FIELD(Int32, count);
DTO_FIELD(Int64, no_price);
DTO_FIELD(String, side);
DTO_FIELD(String, ticker);
DTO_FIELD(String, updated_client_order_id);
DTO_FIELD(Int64, yes_price);

};

class AmendOrderResponse
: public oatpp::DTO
{

DTO_INIT(AmendOrderResponse, DTO /* extends */)

DTO_FIELD(Object<Order>, old_order);
DTO_FIELD(Object<Order>, order);

};

class DecreaseOrderRequest
: public oatpp::DTO
{

DTO_INIT(DecreaseOrderRequest, DTO /* extends */)

DTO_FIELD(Int32, reduce_by);
DTO_FIELD(Int32, reduce_to);

};

struct PortfolioPositionsRequest
: public oatpp::DTO
{
Expand Down Expand Up @@ -584,6 +772,45 @@

};

class PortfolioSettlementsRequest
: public oatpp::DTO
{

DTO_INIT(PortfolioSettlementsRequest, DTO /* extends */)

DTO_FIELD(Int64, limit);
DTO_FIELD(String, cursor);

};

class Settlement
: public oatpp::DTO
{

DTO_INIT(Settlement, DTO /* extends */)

DTO_FIELD(String, market_result);
DTO_FIELD(Int64, no_count);
DTO_FIELD(Int64, no_total_cost);
DTO_FIELD(Int64, revenue);
DTO_FIELD(DateTime_Iso8601, settled_time);
DTO_FIELD(String, ticker);
DTO_FIELD(Int64, yes_count);
DTO_FIELD(Int64, yes_total_cost);

};

class PortfolioSettlementsResponse
: public oatpp::DTO
{

DTO_INIT(PortfolioSettlementsResponse, DTO /* extends */)

DTO_FIELD(String, cursor);
DTO_FIELD(Object<Settlement>, settlements);

};

#include OATPP_CODEGEN_END(DTO)

}
Expand Down
Loading
Loading