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 get_open_and_resolved_markets function #57

Merged
merged 1 commit into from
Feb 26, 2024

Conversation

kongzii
Copy link
Contributor

@kongzii kongzii commented Feb 26, 2024

Summary by CodeRabbit

  • Refactor
    • Updated the market monitoring tool to improve how open and resolved markets are retrieved, enhancing efficiency and reliability.

Copy link

coderabbitai bot commented Feb 26, 2024

Walkthrough

The update enhances the monitor_app.py by integrating a new function, get_open_and_resolved_markets, which streamlines the retrieval of market data based on their status (open or resolved). This optimization replaces the earlier method of directly invoking get_manifold_markets_dated. The revision also includes an adjustment in import statements to accommodate the Market class, refining the structure and efficiency of the market monitoring application.

Changes

File Change Summary
.../monitor/monitor_app.py Introduced get_open_and_resolved_markets for fetching market data; updated imports to include Market class, replacing direct calls to get_manifold_markets_dated.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@kongzii kongzii merged commit d50c88e into main Feb 26, 2024
8 checks passed
@kongzii kongzii deleted the peter/get_open_and_resolved_markets branch February 26, 2024 12:34
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between e7d4b79 and 17cb829.
Files selected for processing (1)
  • prediction_market_agent_tooling/monitor/monitor_app.py (3 hunks)
Additional comments: 2
prediction_market_agent_tooling/monitor/monitor_app.py (2)
  • 7-10: The addition of the Market class to the import statements aligns with the PR objectives, indicating its use in the new get_open_and_resolved_markets function for handling market data. This change is straightforward and seems appropriate given the context.
  • 88-90: The integration of get_open_and_resolved_markets within the monitor_app function demonstrates the practical application of the new function. This change simplifies the process of fetching market data by encapsulating the logic within a dedicated function, improving the readability and maintainability of the monitor_app function. The use of the new function here aligns with the PR objectives of enhancing modularity and potentially performance. This is a positive change that contributes to the overall objectives of the PR.

Comment on lines +40 to +67
def get_open_and_resolved_markets(
start_time: datetime,
market_type: MarketType,
) -> tuple[list[Market], list[Market]]:
open_markets: list[Market]
resolved_markets: list[Market]

if market_type == MarketType.MANIFOLD:
open_markets = get_manifold_markets_dated(
oldest_date=start_time, filter_="open"
)
resolved_markets = [
m
for m in get_manifold_markets_dated(
oldest_date=start_time, filter_="resolved"
)
if not m.has_unsuccessful_resolution
]

elif market_type == MarketType.OMEN:
# TODO: Add Omen market support: https://github.com/gnosis/prediction-market-agent-tooling/issues/56
open_markets = []
resolved_markets = []

else:
raise ValueError(f"Unknown market type: {market_type}")

return open_markets, resolved_markets
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The get_open_and_resolved_markets function introduces a structured approach to retrieving open and resolved markets based on the market type. A few points to consider:

  1. Correctness and Logic: The function correctly branches based on market_type to handle different market types. However, it currently only supports MarketType.MANIFOLD with a placeholder for MarketType.OMEN. This is a good start, but the TODO comment indicates that support for Omen markets is pending. It's important to track this as a follow-up task to ensure feature completeness.

  2. Performance: By separating the retrieval of open and resolved markets and filtering out markets with unsuccessful resolutions, the function potentially optimizes data processing. However, the performance impact largely depends on the implementation details of get_manifold_markets_dated and the volume of market data.

  3. Error Handling: The function raises a ValueError for unknown market types, which is a good practice for handling unexpected inputs. However, consider logging this error for easier debugging and monitoring.

  4. Maintainability: The function is well-structured and uses clear variable names, making it maintainable. The separation of concerns (retrieving open vs. resolved markets) is well executed.

  5. TODO Comment: The placeholder for Omen market support is acknowledged with a TODO comment. It's crucial to ensure this task is tracked in the project's issue tracker to not lose sight of this pending enhancement.

Overall, the function is a significant improvement in structuring market data retrieval and lays a good foundation for future enhancements.

Consider adding error logging for the ValueError raised for unknown market types to improve debuggability.

Would you like me to open a GitHub issue to track the implementation of Omen market support as indicated by the TODO comment?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants