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

Merge place stock order #22

Merged
merged 6 commits into from
Feb 25, 2024
Merged

Merge place stock order #22

merged 6 commits into from
Feb 25, 2024

Conversation

stephenneale
Copy link
Collaborator

Adds functionality to place buy and sell MARKET or LIMIT orders on the "Place Order" page.

@stephenneale stephenneale merged commit b764034 into dev Feb 25, 2024
@stephenneale stephenneale deleted the place-stock-order branch February 25, 2024 00:23
@stephenneale
Copy link
Collaborator Author

stephenneale commented Feb 25, 2024

Found an issue to address:

All users add to the same stock transactions list when placing an order. Additionally, all users can see this unified stock transaction list when viewing their stock transaction history.

Steps to reproduce:

  1. Re-build and run all portions of the app. make clean, then make install, then make in the main directory.
  2. Log in as any user
  3. Navigate to Place Order and place any stock order.
  4. Navigate to the user's stock transaction history. "Stock Details">"Transaction History". Observe the recently placed transaction in history table.
    image
  5. Log out and sign in as a different user.
  6. Navigate to the different user's stock transaction history. "Stock Details">"Transaction History". Observe that this different user can see the same transaction placed by the previous user.

The process is repeatable. Orders placed by any user account will be visible by all accounts.

Possible fix:

Currently the backend only returns a list of all stock transactions placed by all users. This logic can be seen in the function getStockTransactions() used in order.routes.ts and order.controller.ts. We need to implement a filter in this logic to only find stock transactions placed by the currently signed in user. The desired functionality can be seen in stock.routes.ts and stock.controller.ts for the getStockPortfolio() function. Using the user's auth key in a similar way we can find stock transactions per user.

Important Notes

If the database already has a separate stock transaction history table for each user, then a fix for this is pretty straightforward as outlined above. Otherwise, if the backend is just storing all stock transactions into one table in the database, then logic must be implemented to create a table for each user, or add a user_name to each entry.

A separate transaction table for each user will probably be faster? If there was only one table then the backend would have to comb through the entire table and pick out only the currently logged in user's transactions, which would be wasteful when the table gets large. Any additional thoughts on the matter is appreciated.

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.

1 participant