We will use this sample to demonstrate the capabilities of WSO2 WSAS, highlighting the ease of integration of QoS modules. In the context of this trading scenario, this emphasizes the use of security and reliable messaging.
In a nutshell, the trading sample takes place in a scenario where there are interactions taking place between a stock exchange, trader (stock broker) & client (shareholder). A shareholder who buys and sells shares on the stock market needs to do so through a stock broker or trader, in which case he would first need to become a client of that particular trader. The shareholder uses his Central Depository System (CDS) account which registers him with the stock exchange to sell & buy shares on the stock market. A trader can register his client (the shareholder) with the stock exchange.
The following section describes the services offered by each of the parties involved in this scenario.
Client creates an account with a trader by which the Client receives an user ID. The Trader in return, registers the Client with the stock exchange using client information. The Client obtains a CDS account at this registration through which he is allowed to trade on the stock market. The Client can only buy & sell shares on the market through the Trader. The Trader places these buy & sell orders of the Client on the stock exchange.
The Trader also registers feed targets to the Exchange.
To access any of the services from the stock exchange, The Trader needs to first login to the Exchange using the Trader's username & password.
The Clients get stock quotes (company name, symbol, selling price, high, low), and portfolio information from the Trader. He also deposits money in his account through the Trader.
The User (shareholder) can directly gain market information such as total traded shares, average price, and average size of trade from The stock exchange.
Trader provides market data updates to stock exchange
cd WSO2WSAS_HOME\samples\Trader
antYou should see messages like this:
Buildfile: build.xml clean: [delete] Deleting directory C:\wso2wsas-2.1\samples\Trader\temp init: [mkdir] Created dir: C:\wso2wsas-2.1\samples\Trader\temp [mkdir] Created dir: C:\wso2wsas-2.1\samples\Trader\temp\classes [some lines deleted here] build-all: [echo] Copying the created aar files in to the repository [copy] Copying 4 files to C:\wso2wsas-2.1\repository\services BUILD SUCCESSFUL Total time: 10 seconds C:\wso2wsas-2.1\samples\Trader>The build automatically copies the .aar files containing the necessary services into the repository.
./run-client.shYou should see:
Populating the stock market ................Done. Using following parameters TraderService URL : http://localhost:9762/services/TraderClient ExchangeService URL : http://localhost:9762/services/ExchangeClient STARTING TRADE SAMPLE CLIENT ============================= ... Please select your operation... --------------------------------- (1) createAccount (2) getQuote (3) getSymbols (4) deposit (5) buy (6) sell (7) getPortFolio (8) getMarketInfo (9) Exit
./run-client.sh -qos secureYou would see a prompt asking for the username and password before listing the operations available as follows:
Populating the stock market ................Done. Using following parameters TraderService URL : http://localhost:9762/services/TraderClient ExchangeService URL : http://localhost:9762/services/ExchangeClient QOS : security STARTING TRADE SAMPLE CLIENT ============================= ... Please enter your username :test Please enter your password :test
...Creating account... Please enter the Name:test1 Please enter the password:test1 Results ------- User ID :test1
...Doing deposit... Please enter the username:test1 Please enter the password:test1 Please enter the amount:100 Deposit Successful !!
...Buying stocks... Please enter the username:test1 Please enter the password:test1 Please enter the symbol:mn Please enter the quantity:100 Results ------- Status :true Reason :Success
...Selling stocks... Please enter the username:test1 Please enter the password:test1 Please enter the symbol:mn Please enter the quantity:50 Results --------- Status :true Reason :Success
...Getting Portfolio... Please enter the username:test1 Please enter the password:test1 Results ------- Symbol:mn Amount:50 Symbol:h Amount:200Likewise, please explore the options available in the Trader client and see how it works for yourself!