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

feat: ToStringOut() for series #1150

Merged
merged 30 commits into from
Dec 24, 2024
Merged

feat: ToStringOut() for series #1150

merged 30 commits into from
Dec 24, 2024

Conversation

DaveSkender
Copy link
Owner

@DaveSkender DaveSkender commented Jan 26, 2024

Description

This is a quirky helper utility to convert ISeries (quotes and results lists) to a fixed width, CSV, or JSON string. Mostly, I'm thinking this is helpful anyone debugging or wanting to output something to Console for quick visual inspections or general development sharing. Default is OutType.FixedWidth, since I mostly had Console output and .NET Fiddle use in mind.

   i  Timestamp      Open     High      Low    Close     Volume
---------------------------------------------------------------
   1  2017-01-03   212.71  213.350  211.520  212.570   96708880
   2  2017-01-04   212.64  214.220  212.638  213.648   83348752
   3  2017-01-05   213.14  214.060  213.020  213.685   82961968
   4  2017-01-06   213.41  215.170  213.414  214.318   75744152
   5  2017-01-09   213.87  214.530  213.866  214.193   49684316
   6  2017-01-10   214.03  214.890  213.520  214.083   67500792

To do

  • depends on merge of feat: Full chain streaming prototypes #1092, since it restructures IResult to be parameterless
  • question: isn't there a built-in set of converters that might work better here? seems like we're re-engineering something that probably already exists in C# features.
  • question: any way to use inner override of result class ToString()? Probably not. Maybe we just use .ToStringList() or .ToStringOut()
  • fix: order date as first property, it's inherited, so it is always at the end right now
  • fix: use of unused arguments for certain OutType values
  • fix: formatting issues for date. For OutType.FixedWidth, it would ideally be the smallest format possible, keeping in mind that bars could be high frequency date/time values or wider.
  • consider overload .ToString(int limitQty) or .ToString(int startIndex, int endIndex)
  • add separate backlog items if some classes might have their own (property, type, value, description (from XML docs)), ref:
    Property   Type          Value  Description
    -------------------------------------------------------------------
    Timestamp  DateTime 2024-02-02  The close date/time for this period
    Size       Decimal        3.00  High - Low price
    Body       Decimal        1.00  | Open - Close | (absolute value)
    UpperWick  Decimal        1.00  High - max(Open, Close)
    ...
  • fix: overall performance, needs major refactoring
  • add real unit tests

@DaveSkender DaveSkender added the on hold On hold / waiting label Jan 26, 2024
@DaveSkender DaveSkender self-assigned this Jan 26, 2024
@DaveSkender DaveSkender added this to the v3 milestone Jan 26, 2024
@DaveSkender
Copy link
Owner Author

Note: overriding ToString() doesn't work on enumerable, but does work for base types.

@DaveSkender DaveSkender added the experiment Pseudo-fork for experimental (do not merge) label Nov 11, 2024
@DaveSkender DaveSkender requested a review from Copilot November 15, 2024 23:51

Choose a reason for hiding this comment

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

Copilot reviewed 3 out of 3 changed files in this pull request and generated no suggestions.

Comments skipped due to low confidence (4)

tests/indicators/_common/Results/Result.Utilities.ToStringOut.Tests.cs:12

  • The test method 'ToStringFixedWidth' is not implemented correctly and needs to be properly implemented.
Assert.Fail("Test not implemented, very wrong syntax.");

tests/indicators/_common/Results/Result.Utilities.ToStringOut.Tests.cs:26

  • The test method 'ToStringCSV' is not implemented correctly and needs to be properly implemented.
Assert.Fail("Test not implemented, very wrong syntax.");

tests/indicators/_common/Results/Result.Utilities.ToStringOut.Tests.cs:36

  • The test method 'ToStringJson' is not implemented correctly and needs to be properly implemented.
Assert.Fail("Test not implemented, very wrong syntax.");

src/_common/Generics/StringOut.cs:66

  • The message should be 'ToStringOut() for JSON output ignores the number format N{decimalsToDisplay}.'
string message = $"ToStringOut() for JSON output ignores number format N{decimalsToDisplay}.";
@DaveSkender DaveSkender linked an issue Nov 29, 2024 that may be closed by this pull request
6 tasks
* Fix the order of date as the first property in the `ToStringOut` method.
* Use the `OutType` argument properly in the `ToStringOut` method.
* Fix formatting issues for date in the `ToStringOut` method.
* Add overloads for `.ToString(int limitQty)` and `.ToString(int startIndex, int endIndex)` methods.
* Refactor the `ToStringOut` method for better performance.

Add unit tests for `ToStringOut` method

* Add unit tests for the new overloads `.ToString(int limitQty)` and `.ToString(int startIndex, int endIndex)`.
* Add unit tests for the fixed order of date as the first property.
* Add unit tests for the proper use of `OutType` argument.
* Add unit tests for the fixed formatting issues for date.
* Add unit tests for the refactored `ToStringOut` method performance.
* Fix the order of date as the first property in the `ToStringOut` method
* Use the `OutType` argument properly in the `ToStringOut` method
* Fix formatting issues for date in the `ToStringOut` method
* Add overloads for `.ToString(int limitQty)` and `.ToString(int startIndex, int endIndex)` methods
* Refactor the `ToStringOut` method for better performance
* Add unit tests for the new overloads and fixed issues in `Result.Utilities.ToStringOut.Tests.cs`
@DaveSkender DaveSkender removed the on hold On hold / waiting label Nov 29, 2024
@DaveSkender DaveSkender linked an issue Dec 22, 2024 that may be closed by this pull request
@DaveSkender DaveSkender marked this pull request as ready for review December 24, 2024 00:48
@DaveSkender DaveSkender removed the experiment Pseudo-fork for experimental (do not merge) label Dec 24, 2024
@DaveSkender DaveSkender merged commit ab01d67 into v3 Dec 24, 2024
11 checks passed
@DaveSkender DaveSkender deleted the results-to-stringout branch December 24, 2024 00:49
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 26, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

add formatted console output for ISeries classes add formatted console output for ISeries lists
1 participant