NO API REQUIRED. SINGLE USER. BUDGET: £30. HAVE STARTED IT OFF.
Users have a list of Positions, and an overall cash balance available for trading. Cant buy stocks if you literally dont have the money to in your account right?
Positions have a list of Transactions. Positions also have the sum total off all the transactions, positive or negative. So for example, lets say you bought 20 shares of Apple (AAPL) on Monday, and then 30 shares of AAPL on Wednesday, and then 50 shares of AAPL on Thursday. Well, your account need to show those three transactions, but your total position in AAPL is 100 shares. Do not worry about cost-basis if you ever look this stuff up.
Transactions include a stock symbol such as AAPL, a price bought or sold, and an the amount of shares bought or sold at that price.
A stock is just a symbol like AAPL.
Now, the stock market is about buying and selling stocks, so something, somewhere has to actually exchange the money, right? In the industry, we call these people "market makers". For this simulation, Im guessing you could just have the market maker class magically "create" a buyer or seller for the other side if your simulated transaction. In other words, if you want to buy 100 shares of AAPL, well someone has to want to sell 100 shares of AAPL. For this simulation, you can just have the market maker fake the other side of the transaction you want.
Finally, you will need a stock exchange that sets the price. In the USA, the two most common exchanges are the NYSE and the NASDAQ. They set the price. When you buy or sell a stock, the price should move a little. So if you buy 100 shares of AAPL, well, AAPL just got a little more valuable. Reverse if you sell. This balance of buy and sell determines the price. If you have hundreds of buy orders, and only a couple sell orders, you better believe those sell orders are going to demand a high price. The stock exchange tracks this price movement, as well as all the stocks available to be bought or sold.
To recap, heres the flow: I want to buy 100 shares of AAPL. I ask a market maker to look up the price of AAPL from the NYSE stock exchange, and find me a seller. The market maker finds me a seller, and makes the "trade". The market maker takes the share price of AAPL * 100, and takes that money out of my account, and in return gives me those shares. This process is represented as a transaction, and results in a position in my user account.