Skip to content

Commit

Permalink
Add config option to show closed positions.
Browse files Browse the repository at this point in the history
  • Loading branch information
krazkidd committed Jul 22, 2024
1 parent c8c9dd7 commit 27398eb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
5 changes: 5 additions & 0 deletions include/config/Config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace kdeck
DTO_FIELD(String, KalshiApiUrl);
DTO_FIELD(String, SslTrustStoreDir);
DTO_FIELD(String, Email);
DTO_FIELD(Boolean, ShowClosedPositions);

};

Expand All @@ -43,8 +44,12 @@ namespace kdeck

std::string GetEmail() const;

bool GetShowClosedPositions() const;

void SetEmail(std::string email);

void SetShowClosedPositions(bool doShow);

private:
static constexpr int32_t kConfigVersion = 1;
static constexpr std::string_view kConfigFilename = "config.json";
Expand Down
11 changes: 11 additions & 0 deletions src/config/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,21 @@ namespace kdeck
return m_activeConfig->Email ? m_activeConfig->Email->c_str() : m_defaultConfig->Email->c_str();
}

bool Config::GetShowClosedPositions() const
{
return m_activeConfig->ShowClosedPositions ? m_activeConfig->ShowClosedPositions : m_defaultConfig->ShowClosedPositions;
}

void Config::SetEmail(std::string email)
{
m_activeConfig->Email = oatpp::String{email};
}

void Config::SetShowClosedPositions(bool doShow)
{
m_activeConfig->ShowClosedPositions = doShow;
}

std::shared_ptr<Config::UserConfig> Config::MakeDefaultConfig()
{
auto config = UserConfig::createShared();
Expand All @@ -154,6 +164,7 @@ namespace kdeck
config->KalshiApiUrl = std::string{kKalshiApiUrl};
config->SslTrustStoreDir = std::string{kSslTrustStoreDir};
config->Email = std::string{};
config->ShowClosedPositions = false;

return config.getPtr();
}
Expand Down
3 changes: 2 additions & 1 deletion utils/config.json.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"Version": 1,
"KalshiApiUrl": "https://demo-api.kalshi.co/trade-api/v2",
"SslTrustStoreDir": "/etc/ssl/certs"
"SslTrustStoreDir": "/etc/ssl/certs",
"ShowClosedPositions": false
}

0 comments on commit 27398eb

Please sign in to comment.