STOCK MARKET! I KKNOW HOW NOW!

Programmers Guild

Moderator: Andreas the Wise

Post Reply
Erik Mortis
Posts: 7238
Joined: Thu Oct 02, 2003 10:37 pm
Location: County of Monty Crisco
Contact:

STOCK MARKET! I KKNOW HOW NOW!

Post 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....

User avatar
Andreas the Wise
Posts: 5253
Joined: Sat Oct 27, 2007 10:41 pm
Location: The Island of Melangia, Atterock, Kildare
Contact:

Re: STOCK MARKET! I KKNOW HOW NOW!

Post by Andreas the Wise »

You remember I still plan to program one in the near future?
The character Andreas the Wise is on indefinite leave.
However, this account still manages:
Cla'Udi - Count of Melangia
Manuel - CEO of VBNC. For all you'll ever need.
Vincent Waldgrave - Lord General of Gralus
Q - Director of SAMIN
Duke Mel'Kat - Air Pirate, Melangian, and Duke of the Flying Duchy of Glanurchy

And references may be made to Vur'Alm Xei'Bôn (a Nelagan Micron of undisclosed purpose).

User avatar
Ari Rahikkala
Posts: 4326
Joined: Sun Jan 21, 2001 12:56 pm
Contact:

Re: STOCK MARKET! I KKNOW HOW NOW!

Post 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!
No-one should be without a parasol, Sirocco.

Erik Mortis
Posts: 7238
Joined: Thu Oct 02, 2003 10:37 pm
Location: County of Monty Crisco
Contact:

Re: STOCK MARKET! I KKNOW HOW NOW!

Post by Erik Mortis »

Why didn't I think of that?

Andreas... are you actually gonna do it any time soon?

User avatar
Jonas
Posts: 5334
Joined: Mon Feb 19, 2007 9:53 am

Re: STOCK MARKET! I KKNOW HOW NOW!

Post 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. :document
From a distance I'm concerned about the rampant lawyerism manifesting itself in Shireroth currently. A simple Kaiserial slap on the wrist or censure by the community should suffice. - Jacobus Loki
Can't you see? I'm crazy! :tomcutterhamonfire :smashy

Erik Mortis
Posts: 7238
Joined: Thu Oct 02, 2003 10:37 pm
Location: County of Monty Crisco
Contact:

Re: STOCK MARKET! I KKNOW HOW NOW!

Post by Erik Mortis »

It will work for the entire commonwealth.

User avatar
Andreas the Wise
Posts: 5253
Joined: Sat Oct 27, 2007 10:41 pm
Location: The Island of Melangia, Atterock, Kildare
Contact:

Re: STOCK MARKET! I KKNOW HOW NOW!

Post 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.
The character Andreas the Wise is on indefinite leave.
However, this account still manages:
Cla'Udi - Count of Melangia
Manuel - CEO of VBNC. For all you'll ever need.
Vincent Waldgrave - Lord General of Gralus
Q - Director of SAMIN
Duke Mel'Kat - Air Pirate, Melangian, and Duke of the Flying Duchy of Glanurchy

And references may be made to Vur'Alm Xei'Bôn (a Nelagan Micron of undisclosed purpose).

Erik Mortis
Posts: 7238
Joined: Thu Oct 02, 2003 10:37 pm
Location: County of Monty Crisco
Contact:

Re: STOCK MARKET! I KKNOW HOW NOW!

Post 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)

Post Reply

Return to “Church of the Machine God”

Who is online

Users browsing this forum: No registered users and 1 guest