Page 1 of 1
STOCK MARKET! I KKNOW HOW NOW!
Posted: Tue Nov 17, 2009 11:17 pm
by Erik Mortis
I FIGURED IT U+OUT!.... I know how to make a stock market that can integrate with the bank...
Each stock is it's own entry... Mind you if there are THOUSANDS of stocks per company.. this makes for LOTS of entries.. but it makes the most sense to me how to track them.... And the database should be able to handle that many entries....
Re: STOCK MARKET! I KKNOW HOW NOW!
Posted: Wed Nov 18, 2009 12:43 am
by Andreas the Wise
You remember I still plan to program one in the near future?
Re: STOCK MARKET! I KKNOW HOW NOW!
Posted: Wed Nov 18, 2009 7:32 am
by Ari Rahikkala
Hello. This is a primer on using relational databases as more than just flat file stores.
Code: Select all
mysql> describe users;
+----------+------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+------+------+-----+---------+-------+
| username | text | YES | | NULL | |
+----------+------+------+-----+---------+-------+
1 row in set (0.00 sec)
mysql> describe stocks;
+-----------+------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+------+------+-----+---------+-------+
| stockname | text | YES | | NULL | |
+-----------+------+------+-----+---------+-------+
1 row in set (0.01 sec)
mysql> describe userstocks;
+--------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+---------+------+-----+---------+-------+
| user | text | YES | | NULL | |
| stock | text | YES | | NULL | |
| amount | int(11) | YES | | NULL | |
+--------+---------+------+-----+---------+-------+
3 rows in set (0.00 sec)
mysql> select * from users;
+----------+
| username |
+----------+
| ari |
| erik |
| scott |
+----------+
3 rows in set (0.00 sec)
mysql> select * from stocks;
+-----------+
| stockname |
+-----------+
| vbnc |
| megacorp |
| jhi |
+-----------+
3 rows in set (0.00 sec)
mysql> select * from userstocks;
+-------+----------+--------+
| user | stock | amount |
+-------+----------+--------+
| ari | jhi | 100 |
| ari | vbnc | 5 |
| scott | megacorp | 10000 |
+-------+----------+--------+
3 rows in set (0.00 sec)
mysql> select * from userstocks where user = 'ari';
+------+-------+--------+
| user | stock | amount |
+------+-------+--------+
| ari | jhi | 100 |
| ari | vbnc | 5 |
+------+-------+--------+
2 rows in set (0.00 sec)
mysql> select * from userstocks where stock = 'vbnc';
+------+-------+--------+
| user | stock | amount |
+------+-------+--------+
| ari | vbnc | 5 |
+------+-------+--------+
1 row in set (0.00 sec)
mysql> insert into userstocks values ('erik', 'vbnc', '10');
Query OK, 1 row affected (0.00 sec)
mysql> select sum(amount) from userstocks where stock = 'vbnc';
+-------------+
| sum(amount) |
+-------------+
| 15 |
+-------------+
1 row in set (0.00 sec)
This was a primer on using relational databases as more than just flat file stores. Hope you enjoyed it!
Re: STOCK MARKET! I KKNOW HOW NOW!
Posted: Wed Nov 18, 2009 10:55 am
by Erik Mortis
Why didn't I think of that?
Andreas... are you actually gonna do it any time soon?
Re: STOCK MARKET! I KKNOW HOW NOW!
Posted: Wed Nov 18, 2009 11:39 am
by Jonas
Erik Mortis wrote:Why didn't I think of that?
Andreas... are you actually gonna do it any time soon?
Otherwise you can make one for me. Kildare will pay.

Re: STOCK MARKET! I KKNOW HOW NOW!
Posted: Wed Nov 18, 2009 12:08 pm
by Erik Mortis
It will work for the entire commonwealth.
Re: STOCK MARKET! I KKNOW HOW NOW!
Posted: Wed Nov 18, 2009 1:41 pm
by Andreas the Wise
Andreas the Wise wrote:You remember I still plan to program one in the near future?
I'm finished exams as of yesterday afternoon, so I have time to program. So yes. I've thought through all the added stuff about price adjustments and making it profitable etc - and yes, will design it for the whole commonwealth, and incorporated with the bank, now I know how easy that is.
Ari - I'm not entirely sure I understand what you're getting at ... but I'll look again when I've got a little more into programming it.
Re: STOCK MARKET! I KKNOW HOW NOW!
Posted: Wed Nov 18, 2009 1:52 pm
by Erik Mortis
Oh.. well.. then I guess I ought toss what I got or send it to you. (not that I have much. Just the tables really). The bank can now handles mods better.
You might wanna figure out what Ari is getting at here. It makes a LOT more sense then what I had in mind. and might be the only way to do it well.
I was gonna create features in this order.
1. Ability to create stock for Company accounts.
2. Ability to set stocks a "Available" for sale. And to set the sale price.
ability to view all stocks set to "Available".
ability to buy stocks for the set price. moving the money as appropriate.
logs.
3. Dividends. (Not sure how to do this well)