Wheeler v2 draft model#17
Conversation
|
You took a different approach focusing on the data model. I went more top down and Claude (web) produced a very similar, but not as detailed table structure. Did you use Claude Code for yours? I'm not sure how I should share my file - do I just add it to this commentary? |
|
I always go "bottom up" in terms of data. you can comment on this PR directly, claude can probably do it somehow too, and/or you can pull the branch and submit PRs to this branch. Ideally, if the "spec" is correct with data model with all use cases accounted for, then it's easy to generate the next layers up. |
Yes, this entire repo has been built by Claude Code. It's a great side project to learn with. I'm purposefully trying to keep my hands out of the code. |
For now, I've just added two files to this comment. I'm not proficient enough with git to figure out how to do all the pushing and pulling! The architecture file is what I originally came up with. I gave your spec to Claude and asked for a comparison and suggested merge approach, and that is attached too. The synopsis is to go with your data model and add in some additional functionality that I specified. wheeler_architecture_v2 - antamy.md
I originally used the web version, but then paid for Pro to get access to Claude Code inside VS Code. The web version did tell me that it would be better suited for architectural discussions and planning, the results of which can then be given to Claude Code for implementation, so that is what I did to create these documents. |
|
I agree with "### Option A: Start with Original Author's Base + Add Our Features". If we start with the data model specifically, we can account for all the use cases, have explicit tests, and know it all works before we leave the data layer. During a previous refactor, I had Claude identify all the "panels" across all the views and put them into a refactor plan. i went through them one by one and ensured each had a handler + test. I'd like to do the same for a v2 refactor. We can make a list of all panels, write out what they should do, and refactor each one in place. The whole application would continue to work. With the right data model beneath + data access layer, you can add all the features you want (different "campaigns" and other ways to focus the data). |
Do you want to work on refining the data model and I can work with Claude to create the updated list of panels and their high level functionality? We can then take a view on sequencing and have Claude merge all of that into a v2 architecture spec with an implementation plan. I'm not entirely clear on how we have 2 Claudes collaborate on one document. |
|
SGTM. I will do a detailed plan for the model + data layer + tests. You can make a plan with each of the panels and their requirements. Two different PRs, two different documents. |
|
@antamy Claude added a plan for detailed SQL data model w/ migrations. |
|
When we think about Account, is it necessary to have an account type? Taxable / non-taxable seems to be outside the scope of the application and could be reflected in an account's name. Accounts should just be flexible containers (folders) for grouping a set of instruments and associated trades and campaigns. |
|
Claude added "account_type" and I thought the same thing as you. I'll remove it. |
|
Data requirements for supporting wheels:
For each Wheel, this is what Claude came up with, based on the prototype where I used a JSON data store: The idea here is to explicitly define your wheels (stock, # of contracts, wheel strategy etc.) within an account (which may just be a pile of cash), then track the execution and performance of the wheels. Trades are entered from the wheel pages and tracked in sequence (so we would need to have a FK relationship to the transaction). The UI provides a simplified data entry which is context aware based on the state of the wheel. IV and delta can be tracked if required, along with stock price at the time of trade. Manipulating the trades through the Options and Symbols menus would not be allowed. |
f896ba1 to
472f721
Compare
|
@antamy I removed "account_type", per comments above, and also added a Trade table to the ERD. it rounds out the model. |
|
Also, re: your comments above about tracking a "wheel campaign" ... I think I understand. We'd need some way of grouping some trades together for some arbitrary reason. Perhaps after the base data model is improved, we can work on adding a "Strategies" view that contains the various campaigns that were tried, what their results were, etc.? |
|
@antamy the last commit on this PR cleans up the schema. Claude's migration plan looks pretty decent, but I'm wary it can do it all like that in one shot. |
did you upload the plan? does it have an assessment of how invasive the new schema will be to the codebase? let me know how you want to proceed. |
|
yes, claude implemented a migration plan in the markdown doc. I reviewed it pretty carefully, made edits (some of my commits), and I curious to try it's approach piecemeal. A second set of eyes couldn't hurt. There's ERD/data model/use cases/migration plan in the doc. |
|
I read through the v2 spec with the database migration plan, I didn't see any functional migration plan. It seems fine, however since the application needs to be rebuilt for the new schema the database migration would seem to be the last piece to implement. I was envisaging cloning the existing codebase, implementing the new database and the new functionality to CRUD Accounts. Then tackle vertical slices - Symbols, Treasuries, cash, Stocks, Options - before moving on to the analytical views and utility functions. I think, but haven't confirmed, that the vertical slices are pretty much independent, so we could work on them in parallel. We could have Claude create this work item list and then we can pick the next item to work on based on availability. How did you approach building the original codebase? Was it slice by slice, or did you establish the database, data access and API layers and then the major functions? |
|
Claude's "migration" is still to be implemented, but I think the SQL in the markdown needing to adjust the schema appears correct. I'm more curious about its coalesce statements that attempts to backfill data, like transactions. Other data needs to be filled in, like filling out trades with both ends, perhaps recording assignment, etc. according to history. I have hundreds of trades to migrate. Even if there's a v2 codebase, it'd require some parsing of CSVs exported from v1 with the same kind of logic to pair up trades and such into the new schema. It seems like a good schema w/ data layer and migration to new "trades" backfilled with transactions is the minimally viable thing. The default "trade type" would be the current wheel strategies that are hardcoded. The UI would continue to work as-is, because the old data model remains. If that all works, it's safe to develop and test the UI separately from the backend. |
|
My preference would be to refactor the existing application in a way that works the entire time. I have a lot of current/active data in my instance of Wheeler and I'm relying on it. But my only concern about that is the migration to the improved data model. So long as that's Easy™, Claude makes code (persistence and graphs) pretty easy. |
I hadn't thought too much about that, however don't we already have all the data for this? Each current trade is opened (sell to open) and then closed with a premium paid (buy to close) or just closed (expired). Matching up an expiration with a stock buy or sell (assignment) does seem a little tricky - I don't think I have a solution for that.
Not sure I understand this, why would the old data model remain? |
I guess my point was that the migration has to occur at some point. My view is that it would be easier to do that once the v2 transactional functionality is complete, vs at the beginning. Then you can continue to use v1, get v2 off the ground and understand nuances we haven't considered, and then migrate the data. I don't really mind. I've got several hundred transactions in it now and if we do migration first, I would probably continue with v1 and run fresh v1 to v2 migrations as the codebase takes shape. |
|
I suppose the first question is "refactor v1 or rewrite as v2?" both require the same data migration. both, in my mind, would tackle the data layer first w/ use cases and tests. But using v1 data model requires the full migration, I think, whereas build new v2 means v1 can stay as-is while a v2 is built from scratch. If v1 is refactored, then the same tables will exist. The Options table, for example, exists in both schemas but has more attributes for v2. This can be refactored from v1, if desired. the same UI views can continue to use the Options table with the preexisting attributes while the new ones would be used by v2. Each panel in the UI can change over time to use new data. This is how I envision keeping the whole thing running the whole time. Or v1 was a learning experience and Claude makes writing new code easier (still takes time to debug and fix everything). In either case, a well-defined data model that can account for all our use cases is a solid foundation. The UI is just fancy graphs on top of solid data. |
|
Ah, I see. I misinterpreted the approach as being to implement the v2 model then on 1st run, convert a v1 database into v2. We can try the re-factor approach and hopefully Claude doesn't create a lot of spaghetti! I have some time from this Friday thru' Thursday next week to work on this, then I'll be traveling until after Thanksgiving. Do you want to tackle the schema change, then I can work on account and other items? |
|
In some general rough order:
How to fix 6? Implement v2 UI in step 3? But what about existing trades we're managing today in real life? |
|
The current UI is pure CRUD to the database. The HTML forms have some JS validation in them. There is some logic in the handlers and/or model that performs calculations before persistence. This is the "hard-coded" Trade type I mentioned. The logic is throughout the stack and it's built to wheel in one way. Introducing the Trade table means we can make new UI to open a trade, make updates, close a trade. It's more of a flow (by trade type) than the simple CRUD forms in place today. We take actions on data. |

@antamy PTAL