I am making a small personal application regarding the shares of different companies about my business.
The action is selling or buying shares of a company. Therefore, details of the details in both cases will be:
- Number of shares
- average value
will it be better "buy" and To use different tables for "Selling" or just use a table for "business" and keep an area that demarcates "Purchase" from "Selling"?
This is really a difficult one on which the table you are talking about is basically a business There is a table, which buys and sells all of you.
In this sense, you will think that buying and selling both in a table will mean. However, in many jurisdictions, additional information for a selling order is a piece of information that buys offsets against buying (for capital gain or profit purposes) although it bought hard earlier, The first sold (FBFS) is not necessary in the environment, it does not make any sense.
For example, under Australian law, you actually purchase your most recent, until you have the logic written in clear language in the first place, even though my company adheres to FBFS, I am allowed to receive bonus issues or supplementary shares, which I can sell immediately.
If you adhere to the strict FBFS, then you don? T need additional information and your trade is symmetrical. Even where it is not, I have implemented it with additional information in a table, the course is worthless for order purchase order It was the easiest way to do this.
You can do this as two odd tables, but this causes problems a bit more problems because you often need to draw data from both the tables. My advice is to stay with a table with additional information if necessary.
I will never store the average value. I like the quantity, value per share and brokerage cost. For example:
AvgPrice = (Brokerage + SharePrice * ShareQuant) / ShareQuant
But it is sometimes impossible to work backwards from the average value only Because you do not know what the brokerage was.
And I will not have a boolean to buy / sell, it is easy to use negative numbers to sell it. Order and this calculation of balance sheet type makes it very easy because you are kind of like Instead of denying some of them on the basis of the order type, add value to it.
Update: If, as you point out, you are only going to store total information for each company, I will go for the following: Company ID: CompanyBuyQuant CompanyBuyAvgPrice CompanySellQuant CompanySellAvgPrice
Sales You do not need a separate line to buy / sell goodsWhen the company is added for the first time, both quantities and prices have been set to 0.Your institution is now a company, so it makes more sense. One thing you might want to consider is to store the total prices of purchased and sold shares instead of selling the average purchases and prices. This will make calculating your updates easier, and you can get the average by dividing the composite by volume.
Then, the following table:
Companies: CompanyID primary key
- When adding a company, 0 Set all quanities and values,
- When you buy
M
>N
dollars on each share,M
to < Code> Company Quant andN * M
toCompanyBuyValue
. >> - Enter
M
toN
for each dollar,M
toCompanySellQuant
AndN * M
toCompanySellValue
. - <<> Get the average purchase price in the form of CompanyBuyValue / CompanyBuyQuant .
-
CompanySellValue / CompanySellQuant
. Find average sales prices in the form of
Comments
Post a Comment