trade server spec, such that it is.

1 view
Skip to first unread message

number_seven

unread,
Feb 6, 2010, 12:35:45 AM2/6/10
to Erlang Colearning
Okay, as I said, something simple. I'll combine the operations of
several servers into one (we can refactor them out when the time comes
to go out on our own :-P).

The server receives requests and processes them and sends responses
based on those requests.

We don't have to do EVERYTHING listed below, but it's good to ID a lot
of different things the server can do. Plus the below represents a
basic but complete server.

Trade request:
---------------------
The trade request is the prime mover of the server.

It takes a request from the client with the following parameters:
Trade Request Identifier
Account Number
Trade type (buy/sell)
Security Type (only equity for now)
Symbol
Amount

The server queries the data store to verify:
That the stock exists.
That the shares remaining in the store is greater than the requested
(on a buy).
That the account exists.
That the account has enough money to buy or has the stocks to sell.

It then executes the trade and adds/subtracts the commission. If we
really want to have some fun, we can have buys raise the price of the
stock by a predetermined amount or formula and a sell reduce it by a
similar amount or formula.

If successful, it executes the trade and returns the response to the
client:
Trade Response Identifier
Account Number
Symbol
Execution Price
Quantity
Total cost/return of sale

Balance request:
-----------------------
Requests the amount of money in the account.

Values in the request:
Balance Request Identifier
Account Number

The response:
Balance Response Identifier
Account Number
Balance

Position Request:
-----------------------
Requests a listing of the stocks that an account has.

The request:
Position Request Identifier
Account Number

The response:
Position Response Identifier
Account Number
Stock list:
Symbol
Quantity

Deposit Request:
-----------------------
Allows an account to deposit money to trade.

The request:
Deposit Request Identifier
Account Number
Amount To Deposit

The response:
Deposit Response Identifier
Account Number
Amount Deposited

Add/Remove Account:
------------------------------
Self-explanatory (keep as one or split into two?).

The Request:
Account Maint Identifier
Action to complete (add/remove)
Account Number (if remove)
Name on Account (if add)
Initial Deposit
Initial Stock List:
Symbol
Quantity

Account Info Request:
Returns the information for a particular account

The request:
Account Info Request Identifier
Account Number

The response:
Account Info Response Identifier
Account Number
Name on Account
Cash Available
Stock List:
Symbol
Quantity

Stock Listing:
------------------
Returns a list of stocks to buy and sell and their prices. If we
wanted to get fancy, we could have bid and ask (buy and sell,
respectively) prices instead of a simple price.

The request:
Stock Listing Request Identifier

The response:
Stock Listing Response Identifier
Stock Listing:
Symbol
Security Type (equity)
Shares Available
Current Price

Quote Request
--------------------
Returns the information for one stock

The request:
Quote Request Identifier
Symbol

The response:
Quote Response Identifier
Symbol
Security Type (equity)
Current Price
Shares Outstanding

And lastly, for our purposes:

Account Listing
--------------------
List all accounts on the server.

The request:
Account Listing Request Identifier

The response:
Account Listing Response Identifier
Account List:
Account Number
Name on Account
Money Available

Reply all
Reply to author
Forward
0 new messages