This project was generated almost entirely by ChatGPT4.
This software provides a set of commands that you can use to specify a list of accounts and the amount of money in each account, and then allow you to provide a "plan" to redistribute money across the accounts so that account A has 20%, account B has 30% and etc. whatever you want.
I've been using ChatGPT to create some personal software projects, nothing for work yet. A pattern that I have found useful is to describe what I want to do in a couple of paragraphs and then ask ChatGPT to create a Software Design Spec for me, in Markdown format. Then, I use some prompts to refine ChatCPT's spec.
Next I ask ChatGPT to implement the spec in a specific language with a build and run script, to display the directory structure of the project and then to provide complete listings of every file required. I enter that code into my IDE and try to build an run it. When I encounter error messages, I paste them into ChatGPT and I get a fix. As I encounter bugs and problems in the code, I add new requirements and coding rules to the spec document generated by ChatGPT.
Once the code looks good and is partially working, I ask ChatGPT to regenerate the entire project based on the amended spec document. Then I fix errors, debug and continue to amend the original spec from ChatGPT. Rinse and repeat: I iterate on this process until things actually work. For this project, I probably spent 4 hours tweaking the prompt, fussing at ChatGPT and debugging things.
Provide a complete implementation of this specification, paying careful attention to the Implementation Rules and Specifications section, double check that the implementation meets those requirements! First display the projects file and directory structure. Then provide the listings of all files, complete implementations of each and every function. Do not leave any code for me to write.
The Account Management Language (AML) is a command-line interface implemented in TypeScript that allows users to manage accounts holding money. The system supports operations like adding accounts, selling amounts from an account, buying amounts into an account, planning, and executing account rebalances. The commands are callable from a bash command line via the Commander library. All data persists between command line invocations as they are stored in a JSON file.
This command creates a new account with the specified name and initial amount.
Inputs:
<account-name>
: An alphanumeric string with no spaces, which will serve as the unique identifier for the account.<account-amount>
: A numerical value specifying the initial amount in the account.
This command sells a specified amount from an existing account. The sold amount goes into the cash-on-hand account.
Inputs:
<account-name>
: The name of an existing account.<sell-amount>
: A numerical value specifying the amount to be sold from the account.
This command buys a specified amount into an existing account. The bought amount comes out of the cash-on-hand account.
Inputs:
<account-name>
: The name of an existing account.<buy-amount>
: A numerical value specifying the amount to be bought into the account.
This command generates a list of commands that, when executed, will re-balance accounts according to a specified plan provided as a CSV file. It doesn't execute the commands, it just prints them out.
Inputs:
<csv-file>
: A CSV file with two columns -account_name
andpercentage
. Theaccount_name
is the name of an existing account, and thepercentage
is a numerical value representing the desired proportion of the total investment for that account.
This command re-balances accounts according to a specified plan provided as a CSV file. After the rebalance is done, the data is saved.
Inputs:
<csv-file>
: A CSV file with two columns -account_name
andpercentage
. Theaccount_name
is the name of an existing account, and thepercentage
is a numerical value representing the desired proportion of the total investment for that account.
This command lists all existing accounts, their amounts, and their proportions of the total investment across all accounts.
This command displays help for a specific command.
The AML software has several integral components:
-
AccountManager
: This TypeScript class maintains a list of accounts and their amounts, including a cash-on-hand account. -
Account
: This interface represents each account withname
andamount
properties. -
ParseCSV
: This class is responsible for parsing CSV files for theplan
andexecute
commands. -
Project Files: The system includes
Account.ts
,AccountManager.ts
,ParseCSV.ts
,package.json
,tsconfig.json
,AccountManager.test.ts
, with all js files being ignored by.gitconfig
.
- The TypeScript code does not use implicit any.
- Account names must be alphanumeric without spaces or special characters.
- Accounts are stored using a Map<String, Account>, with Account names as the map keys. When displayed, they are listed alphabetically.
- Display of accounts uses a table with borders using the cli-table3 library.
- The
package.json
file includes commands for build, start, and test, and lists all dependencies used in the TypeScript code. - Jest tests are provided for each function of
AccountManager.ts
, and Jest config is present inpackage.json
. - The
plan
andexecute
commands share the logic for calculating new account balances and creating the list of buy and sell operations. When creating a buy/sell plan, all sells are done first. - There is a
TUTORIAL.md
document providing a tutorial on using the AML, with examples using at least four accounts and aplan.csv
file for rebalancing.
Future enhancements could include implementing transaction history, interest calculations, transaction fees, more complex rebalancing strategies, and improved error handling and validation.