Skip to content

Commit

Permalink
Add market API wrapper methods and response types.
Browse files Browse the repository at this point in the history
  • Loading branch information
krazkidd committed Jul 15, 2024
1 parent 66cf12d commit 88fe97f
Show file tree
Hide file tree
Showing 2 changed files with 277 additions and 0 deletions.
10 changes: 10 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();
std::shared_ptr<ExchangeStatusResponse> GetExchangeStatus();

// market
std::shared_ptr<EventsResponse> GetEvents();
std::shared_ptr<EventResponse> GetEvent();
std::shared_ptr<MarketsResponse> GetMarkets();
std::shared_ptr<TradesResponse> GetTrades();
std::shared_ptr<MarketResponse> GetMarket();
std::shared_ptr<MarketOrderbookResponse> GetMarketOrderbook();
std::shared_ptr<SeriesResponse> GetSeries();
std::shared_ptr<MarketCandlesticksResponse> GetMarketCandlesticks();

// portfolio
double GetBalance();
std::shared_ptr<PortfolioPositionsResponse> GetPositions();
Expand Down
267 changes: 267 additions & 0 deletions include/api/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,98 @@ namespace kdeck

};

struct Market
: public oatpp::DTO
{

DTO_INIT(Market, DTO /* extends */)

DTO_FIELD(Boolean, can_close_early);
DTO_FIELD(Float64, cap_strike);
DTO_FIELD(String, category);
DTO_FIELD(DateTime_Iso8601, close_time);
//TODO filled only if "strike_type" is "custom"
//DTO_FIELD(TODO, custom_strike);
DTO_FIELD(String, event_ticker);
DTO_FIELD(DateTime_Iso8601, expected_expiration_time);
DTO_FIELD(DateTime_Iso8601, expiration_time);
DTO_FIELD(String, expiration_value);
DTO_FIELD(DateTime_Iso8601, fee_waiver_expiration_time);
DTO_FIELD(Float64, floor_strike);
DTO_FIELD(String, functional_strike);
DTO_FIELD(Int64, last_price);
DTO_FIELD(DateTime_Iso8601, latest_expiration_time);
DTO_FIELD(Int64, liquidity);
DTO_FIELD(String, market_type);
DTO_FIELD(Int64, no_ask);
DTO_FIELD(Int64, no_bid);
DTO_FIELD(String, no_sub_title);
DTO_FIELD(Int64, notional_value);
DTO_FIELD(Int64, open_interest);
DTO_FIELD(DateTime_Iso8601, open_time);
DTO_FIELD(Int64, previous_price);
DTO_FIELD(Int64, previous_yes_ask);
DTO_FIELD(Int64, previous_yes_bid);
DTO_FIELD(String, response_price_units);
DTO_FIELD(String, result);
DTO_FIELD(Int64, risk_limit_cents);
DTO_FIELD(String, rules_primary);
DTO_FIELD(String, rules_secondary);
DTO_FIELD(Int32, settlement_timer_seconds);
DTO_FIELD(Int64, settlement_value);
DTO_FIELD(String, status);
DTO_FIELD(String, strike_type);
//DTO_FIELD(String, subtitle); // DEPRECATED
DTO_FIELD(Int64, tick_size);
DTO_FIELD(String, ticker);
DTO_FIELD(String, title);
DTO_FIELD(Int64, volume);
DTO_FIELD(Int64, volume_24h);
DTO_FIELD(Int64, yes_ask);
DTO_FIELD(Int64, yes_bid);
DTO_FIELD(String, yes_sub_title);

};

struct Event
: public oatpp::DTO
{

DTO_INIT(Event, DTO /* extends */)

//DTO_FIELD(String, category); // DEPRECATED
DTO_FIELD(String, event_ticker);
DTO_FIELD(List<Object<Market>>, markets);
DTO_FIELD(Boolean, mutually_exclusive);
DTO_FIELD(String, series_ticker);
DTO_FIELD(DateTime_Iso8601, strike_date);
DTO_FIELD(String, strike_period);
DTO_FIELD(String, sub_title);
DTO_FIELD(String, title);

};

struct EventsResponse
: public oatpp::DTO
{

DTO_INIT(EventsResponse, DTO /* extends */)

DTO_FIELD(String, cursor);
DTO_FIELD(List<Object<Event>>, events);

};

struct EventResponse
: public oatpp::DTO
{

DTO_INIT(EventResponse, DTO /* extends */)

DTO_FIELD(Object<Event>, event);

};

struct EventRequest
: public oatpp::DTO
{
Expand All @@ -192,6 +284,17 @@ namespace kdeck

};

struct MarketsResponse
: public oatpp::DTO
{

DTO_INIT(MarketsResponse, DTO /* extends */)

DTO_FIELD(String, cursor);
DTO_FIELD(List<Object<Market>>, markets);

};

struct MarketsRequest
: public oatpp::DTO
{
Expand All @@ -209,6 +312,33 @@ namespace kdeck

};

struct Trade
: public oatpp::DTO
{

DTO_INIT(Trade, DTO /* extends */)

DTO_FIELD(Int32, count);
DTO_FIELD(DateTime_Iso8601, created_time);
DTO_FIELD(Int64, no_price);
DTO_FIELD(String, taker_side);
DTO_FIELD(String, ticker);
DTO_FIELD(String, trade_id);
DTO_FIELD(Int64, yes_price);

};

struct TradesResponse
: public oatpp::DTO
{

DTO_INIT(TradesResponse, DTO /* extends */)

DTO_FIELD(String, cursor);
DTO_FIELD(List<Object<Trade>>, trades);

};

struct TradesRequest
: public oatpp::DTO
{
Expand All @@ -223,6 +353,37 @@ namespace kdeck

};

struct MarketResponse
: public oatpp::DTO
{

DTO_INIT(MarketResponse, DTO /* extends */)

DTO_FIELD(Object<Market>, market);

};

struct MarketOrderbook
: public oatpp::DTO
{

DTO_INIT(MarketOrderbook, DTO /* extends */)

DTO_FIELD(List<Int32>, no);
DTO_FIELD(List<Int32>, yes);

};

struct MarketOrderbookResponse
: public oatpp::DTO
{

DTO_INIT(MarketOrderbookResponse, DTO /* extends */)

DTO_FIELD(Object<MarketOrderbook>, orderbook);

};

struct MarketOrderbookRequest
: public oatpp::DTO
{
Expand All @@ -233,6 +394,112 @@ namespace kdeck

};

struct SettlementSource
: public oatpp::DTO
{

DTO_INIT(SettlementSource, DTO /* extends */)

DTO_FIELD(String, name);
DTO_FIELD(String, url);

};

struct Series
: public oatpp::DTO
{

DTO_INIT(Series, DTO /* extends */)

DTO_FIELD(String, category);
DTO_FIELD(String, contract_url);
DTO_FIELD(String, frequency);
DTO_FIELD(List<Object<SettlementSource>>, settlement_sources);
DTO_FIELD(List<String>, tags);
DTO_FIELD(String, ticker);
DTO_FIELD(String, title);

};

struct SeriesResponse
: public oatpp::DTO
{

DTO_INIT(SeriesResponse, DTO /* extends */)

DTO_FIELD(Int32, series);

};

struct Price
: public oatpp::DTO
{

DTO_INIT(Price, DTO /* extends */)

DTO_FIELD(Int64, close);
DTO_FIELD(Int64, high);
DTO_FIELD(Int64, low);
DTO_FIELD(Int64, mean);
DTO_FIELD(Int64, open);
DTO_FIELD(Int64, previous);

};

struct YesAsk
: public oatpp::DTO
{

DTO_INIT(YesAsk, DTO /* extends */)

DTO_FIELD(Int64, close);
DTO_FIELD(Int64, high);
DTO_FIELD(Int64, low);
DTO_FIELD(Int64, open);

};

struct YesBid
: public oatpp::DTO
{

DTO_INIT(YesBid, DTO /* extends */)

DTO_FIELD(Int64, close);
DTO_FIELD(Int64, high);
DTO_FIELD(Int64, low);
DTO_FIELD(Int64, open);

};

struct MarketCandlestick
: public oatpp::DTO
{

DTO_INIT(MarketCandlestick, DTO /* extends */)

DTO_FIELD(Int64, end_period_ts);
DTO_FIELD(Int64, open_interest);
DTO_FIELD(Object<Price>, price);
DTO_FIELD(Int64, volume);
DTO_FIELD(Object<YesAsk>, yes_ask);
DTO_FIELD(Object<YesBid>, yes_bid);
DTO_FIELD(String, ticker);

};

struct MarketCandlesticksResponse
: public oatpp::DTO
{

DTO_INIT(MarketCandlesticksResponse, DTO /* extends */)

DTO_FIELD(Int64, start_ts);
DTO_FIELD(Int64, end_ts);
DTO_FIELD(Int32, period_interval);

};

struct MarketCandlesticksRequest
: public oatpp::DTO
{
Expand Down

0 comments on commit 88fe97f

Please sign in to comment.