Added: incubator/stonehenge/contrib/stocktrader/python/trader_client/templates/home.html URL: http://svn.apache.org/viewvc/incubator/stonehenge/contrib/stocktrader/python/trader_client/templates/home.html?rev=720802&view=auto ============================================================================== --- incubator/stonehenge/contrib/stocktrader/python/trader_client/templates/home.html (added) +++ incubator/stonehenge/contrib/stocktrader/python/trader_client/templates/home.html Wed Nov 26 02:55:38 2008 @@ -0,0 +1,219 @@ +<!-- +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +--> +{% extends "base.html" %} + +{% block title %} + {{ page.title }} +{% endblock %} + +{% block middle %} +<div class="main-title"> + <h1>Home</h1> + <script type="text/javascript"> + var thisdate = new Date(); + document.writeln(thisdate.toLocaleString()); + </script> +</div> +<h3>Welcome {{page.user}}</h3> +<table> + <tr> + <td> + <div class="left"> + <table class="normal"> + <thead> + <tr> + <th colspan="2">User Statistics</th> + </tr> + </thead> + <tbody> + <tr> + <td class="left">Account ID:</td> + <td>{{page.account_data.getAccountID}}</td> + </tr> + <tr> + <td class="left">Account Created:</td> + <td>{{page.account_data.getCreationDate}}</td> + </tr> + <tr> + <td class="left">Total Logins:</td> + <td>{{page.account_data.getLoginCount}}</td> + </tr> + <tr> + <td class="left">Session Created:</td> + <td>{{page.account_data.getLastLogin}}</td> + </tr> + </tbody> + <thead> + <tr> + <th colspan="2">Summary</th> + </tr> + </thead> + <tbody> + <tr> + <td class="left">Cash Balance:</td> + <td>${{page.account_data.getBalance}}</td> + </tr> + <tr> + <td class="left">Number of Holdings:</td> + <td>{{page.holding_info.getNumberOfHoldings}}</td> + </tr> + <tr> + <td class="left">Total of Holdings:</td> + <td>${{page.holding_info.market_value}}</td> + </tr> + <tr> + <td class="left">Sum of Cash and Holdings:</td> + <td>${{page.sum}}</td> + </tr> + <tr> + <td class="left">Opening Balance:</td> + <td>${{page.account_data.getOpenBalance}}</td> + </tr> + <tr> + <td class="left">Current Gain/(Loss):</td> + <td><span class="price">${{page.gain}}</span></td> + </tr> + <tr> + <td class="left">%Gain/(Loss):</td> + <td> + {% ifequal page.g_type 'loss' %} + <span class="price-loss">{{ page.gain_per }}</span> + {% endifequal %} + {% ifequal page.g_type 'gain' %} + <span class="price-gain">{{ page.gain_per }}</span> + {% endifequal %} + {% ifequal page.g_type 'bal' %} + <span>{{ page.gain_per }}</span> + {% endifequal %} + </td> + </tr> + </tbody> + </table> + </div> + </td> + <td> + <div class="right"> + <h3>Market Summary</h3> + <p>{{page.market_summary.summary_date}}</p> + <table class="table-outer" cellspacing="0"> + <tr> + <td class="special">Trade Stock Index (TSIA)</td> + <td> + {{page.market_summary.tsia}} + {% ifequal page.market_summary.gain_type 'loss' %} + <span class="price-loss">${{ page.market_summary.gain }}</span> + {% endifequal %} + {% ifequal page.market_summary.gain_type 'gain' %} + <span class="price-gain">${{ page.market_summary.gain }}</span> + {% endifequal %} + {% ifequal page.market_summary.gain_type 'bal' %} + <span>${{ page.market_summary.gain }}</span> + {% endifequal %} + </td> + </tr> + <tr> + <td class="special">Trading Volume</td> + <td>{{page.market_summary.volume}}</td> + </tr> + <tr> + <td class="special">Top Gainers</td> + <td> + <table class="table-inner" cellspacing="0"> + <thead> + <tr> + <th>Symbol</th> + <th>Price</th> + <th>Change</th> + </tr> + </thead> + <tbody> + {% for gainer in page.market_summary.getTopGainers %} + <tr> + <td> + <form action = "/quotes/" method = "post"> + <input type="hidden" name="SYMBOLS" value="{{gainer.symbol}}"/> + <input type="submit" name="GETQUOTE" value="{{gainer.symbol}}"></input> + </form> + </td> + <td>${{gainer.price}}</td> + <td> + {% ifequal gainer.change_t 'loss' %} + <span class="price-loss">${{ gainer.change }}</span> + {% endifequal %} + {% ifequal gainer.change_t 'gain' %} + <span class="price-gain">${{gainer.change}}</span> + {% endifequal %} + {% ifequal gainer.change_t 'bal' %} + <span>${{gainer.change}}</span> + {% endifequal %} + </td> + </tr> + {% endfor %} + </tbody> + </table> + </td> + </tr> + <tr> + <td class="special">Top Losers</td> + <td> + <table class="table-inner" cellspacing="0"> + <thead> + <tr> + <th>Symbol</th> + <th>Price</th> + <th>Change</th> + </tr> + </thead> + <tbody> + {% for looser in page.market_summary.getTopLoosers %} + <tr> + <td> + <form action = "/quotes/" method = "post"> + <input type="hidden" name="SYMBOLS" value="{{looser.symbol}}"/> + <input type="submit" name="GETQUOTE" value="{{looser.symbol}}"></input> + </form> + </td> + <td>${{looser.price}}</td> + <td> + {% ifequal looser.change_t 'loss' %} + <span class="price-loss">${{ looser.change }}</span> + {% endifequal %} + {% ifequal looser.change_t 'gain' %} + <span class="price-gain">${{looser.change}}</span> + {% endifequal %} + {% ifequal looser.change_t 'bal' %} + <span>${{looser.change}}</span> + {% endifequal %} + </td> + </tr> + {% endfor %} + </tbody> + </table> + </td> + </tr> + </table> + </div> + </td> + </tr> +</table> +<div class="bottom"> + <form action="/quotes/" method="post"> + <input type="text" size="25" name="SYMBOLS" value=""/> + <input class="button" type="submit" name="GETQUOTE" value="Get Quote"/> + </form> +</div> +{% endblock %}
Added: incubator/stonehenge/contrib/stocktrader/python/trader_client/templates/index.html URL: http://svn.apache.org/viewvc/incubator/stonehenge/contrib/stocktrader/python/trader_client/templates/index.html?rev=720802&view=auto ============================================================================== --- incubator/stonehenge/contrib/stocktrader/python/trader_client/templates/index.html (added) +++ incubator/stonehenge/contrib/stocktrader/python/trader_client/templates/index.html Wed Nov 26 02:55:38 2008 @@ -0,0 +1,61 @@ +<!-- +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +--> +{% extends "base.html" %} + +{% block title %} + {{ page.title }} +{% endblock %} + +{% block middle %} + <div class="main-title"><h1>Welcome!</h1><script type="text/javascript"> + var thisdate = new Date(); + document.writeln(thisdate.toLocaleString()); + </script> + </div> + <table> + <tr> + <td> + <div class="left"> + <p> The design of WSO2 StockTrader sample application is based on an online stock trading scenario with the functionality of the application equivalent to the <a href="http://msdn.microsoft.com/stocktrader">Microsoft .NET Stock Trader </a> sample benchmark application and <a href="https://www14.software.ibm.com/webapp/iwm/web/preLogin.do?source=trade6">IBM WebSphere Trade 6.1 </a> sample application. WSO2 StockTrader sample application is powered by <a href="http://wso2.org/projects/wsf/php">WSO2 WSF/PHP</a> and <a href="http://wso2.org/projects/wsas/java">WSO2 WSAS</a>. It serves to illustrate interoperability between PHP Java and .NET in deploying high-performance, scalable service oriented applications. </p> + +<p>For more details, check <a href="http://wso2.org/interop/stocktrader">WSO2 Stock Trader home page</a>. </p> + + </div> + </td> + <td> + <div class="right"> + <h3>Sample of Technologies Demonstrated</h3> + <table> + <tbody> + <tr> + <td> + <ul> + <li>Service-oriented, n-tier design with PHP, Java and .NET</li> + <li>Clean separation of UI, business services and DB access</li> + <li>WSO2 Web Services Framework For PHP</li> + <li>WSO2 Web Services Application Server</li> + <li>Interoperability with .NET</li> + <li>Loosely-coupled, message-oriented design</li> + </ul> + </td> + </tr> + </tbody> + </table> + </div> + </tr> + </table> +{% endblock %} Added: incubator/stonehenge/contrib/stocktrader/python/trader_client/templates/login.html URL: http://svn.apache.org/viewvc/incubator/stonehenge/contrib/stocktrader/python/trader_client/templates/login.html?rev=720802&view=auto ============================================================================== --- incubator/stonehenge/contrib/stocktrader/python/trader_client/templates/login.html (added) +++ incubator/stonehenge/contrib/stocktrader/python/trader_client/templates/login.html Wed Nov 26 02:55:38 2008 @@ -0,0 +1,42 @@ +<!-- +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +--> +{% extends "base.html" %} + +{% block title %} + {{ page.title }} +{% endblock %} + +{% block middle %} + <div class="main-title"><h1>Login</h1><script type="text/javascript"> + var thisdate = new Date(); + document.writeln(thisdate.toLocaleString()); + </script> + </div> + <div class="login"> + {% if page.error %} + {{page.error}} + {% else %} + <form action="." method="POST"> + <table> + {{ page.form.as_table }} + </table> + <p><input type = "submit" name = "LOGINREQUEST" value = "Login" class="button"/></p> + + </form> + {% endif %} + </div> +{% endblock %} Added: incubator/stonehenge/contrib/stocktrader/python/trader_client/templates/portfolio.html URL: http://svn.apache.org/viewvc/incubator/stonehenge/contrib/stocktrader/python/trader_client/templates/portfolio.html?rev=720802&view=auto ============================================================================== --- incubator/stonehenge/contrib/stocktrader/python/trader_client/templates/portfolio.html (added) +++ incubator/stonehenge/contrib/stocktrader/python/trader_client/templates/portfolio.html Wed Nov 26 02:55:38 2008 @@ -0,0 +1,143 @@ +<!-- +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +--> +{% extends "base.html" %} + +{% block title %} + {{ page.title }} +{% endblock %} + +{% block middle %} + {% if page.closed_orders %} + <p style="color: red" align="center">Trade Alert: The following orders have completed.</p> + <table class="table-outer" cellspacing="0" align="center"> + <thead> + <tr> + <th>Order ID</th> + <th>Order Status</th> + <th>Creation Date</th> + <th>Completion Date</th> + <th>Txn Fee</th> + <th>Type</th> + <th>Symbol</th> + <th>Quantity</th> + <th>Price</th> + </tr> + </thead> + <tbody> + {% for order in page.closed_orders %} + <tr> + <td>{{order.getOrderID}}</td> + <td>{{order.getOrderStatus}}</td> + <td>{{order.getOpenDate}}</td> + <td>{{order.getCompletionDate}}</td> + <td class="currency">${{order.getOrderFee}}</td> + <td>{{order.getOrderType}}</td> + <td>{{order.getSymbol}}</td> + <td>{{order.getQuantity}}</td> + <td class="currency">${{order.getPrice}}</td> + </tr> + {% endfor %} + </table> + </tbody> + </table> + {% endif %} + {% if page.holdings %} + <div class="main-title"> + <h1>Portfolio Information</h1> + <script type="text/javascript"> + var thisdate = new Date(); + document.writeln(thisdate.toLocaleString()); + </script> + </div> + <table class="table-outer" cellspacing="0" align="center"> + <thead> + <tr> + <th>Holding ID</th> + <th>Purchase Date</th> + <th>Symbol</th> + <th>Quantity</th> + <th>Purchase Price</th> + <th>Current Price</th> + <th>Purchase Basis</th> + <th>Market Value</th> + <th>Gain(Loss)</th> + <th>Trade</th> + </tr> + </thead> + <tbody> + {% for holding in page.holdings.h_list %} + <tr> + <td>{{holding.holding_id}}</td> + <td>{{holding.pur_date}}</td> + <td> + <form action="/quotes/" method="post"> + <input type="hidden" name="SYMBOLS" value="{{holding.quote_id}}"/> + <input type="submit" name="GETQUOTE" value="{{holding.quote_id}}"/> + </form> + </td> + <td class="currency">{{holding.quantity}}</td> + <td class="currency">${{holding.pur_price}}</td> + <td class="currency">${{holding.cur_price}}</td> + <td class="currency">${{holding.pur_basis}}</td> + <td class="currency">${{holding.mark_value}}</td> + <td class="currency"> + {% ifequal holding.gain_type 'gain' %} + <span class="price-gain">${{holding.gain}}</span> + {% endifequal %} + {% ifequal holding.gain_type 'loss' %} + <span class="price-loss">${{holding.gain}}</span> + {% endifequal %} + {% ifequal holding.gain_type 'bal' %} + <span >${{holding.gain}}</span> + {% endifequal %} + </td> + <td class="currency"> + <form action = "/confirmation/" method ="post"> + <input type="hidden" name="HOLDINGID" value="{{holding.holding_id}}"></input> + <input type="hidden" name="QUANTITY" value="{{holding.quantity}}"></input> + <input type="hidden" name="SYMBOL" value="{{holding.quote_id}}"></input> + <input type="submit" value = "Sell" name="SELL"></input> + </form> + </td> + </tr> + {% endfor %} + <tr class="total"> + <td colspan="6">Totals</td> + <td class="currency">${{page.holdings.purchase_basis}}</td> + <td class="currency">${{page.holdings.market_value}}</td> + <td> + {% ifequal page.holdings.gain_type 'gain' %} + <span class="price-gain">${{page.holdings.gain}}</span> + {% endifequal %} + {% ifequal page.holdings.gain_type 'loss' %} + <span class="price-loss">${{page.holdings.gain}}</span> + {% endifequal %} + {% ifequal page.holdings.gain_type 'bal' %} + <span >${{page.holdings.gain}}</span> + {% endifequal %} + </td> + <td></td> + </tr> + </tbody> + </table> + {% endif %} + <div class="bottom"> + <form action = "/quotes/" method = "post"> + <input type="text" value="" name="SYMBOLS" id="" size="25"/><input type="submit" name="GETQUOTE" value="Get Quote" class="button"/> + </form> + </div> +{% endblock %} Added: incubator/stonehenge/contrib/stocktrader/python/trader_client/templates/quotes.html URL: http://svn.apache.org/viewvc/incubator/stonehenge/contrib/stocktrader/python/trader_client/templates/quotes.html?rev=720802&view=auto ============================================================================== --- incubator/stonehenge/contrib/stocktrader/python/trader_client/templates/quotes.html (added) +++ incubator/stonehenge/contrib/stocktrader/python/trader_client/templates/quotes.html Wed Nov 26 02:55:38 2008 @@ -0,0 +1,238 @@ +<!-- +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +--> +{% extends "base.html" %} + +{% block title %} + {{ page.title }} +{% endblock %} + +{% block middle %} +{% if page.closed_orders %} + <p style="color: red" align="center">Trade Alert: The following orders have completed.</p> + <table class="table-outer" cellspacing="0" align="center"> + <thead> + <tr> + <th>Order ID</th> + <th>Order Status</th> + <th>Creation Date</th> + <th>Completion Date</th> + <th>Txn Fee</th> + <th>Type</th> + <th>Symbol</th> + <th>Quantity</th> + <th>Price</th> + </tr> + </thead> + <tbody> + {% for order in page.closed_orders %} + <tr> + <td>{{order.getOrderID}}</td> + <td>{{order.getOrderStatus}}</td> + <td>{{order.getOpenDate}}</td> + <td>{{order.getCompletionDate}}</td> + <td class="currency">${{order.getOrderFee}}</td> + <td>{{order.getOrderType}}</td> + <td>{{order.getSymbol}}</td> + <td>{{order.getQuantity}}</td> + <td class="currency">${{order.getPrice}}</td> + </tr> + {% endfor %} + </table> + </tbody> + </table> +{% endif %} + +{% if page.is_reply %} +{% ifequal page.is_reply True %} +<div class="main-title"> + <h1>New Order</h1> + <script type="text/javascript"> + var thisdate = new Date(); + document.writeln(thisdate.toLocaleString()); + </script> +</div> +<p align="center">Order {{page.buy_return.getOrderID}} to {% if page.buy_return %}buy {{page.buy_return.getQuantity}}{% else %}sell {{page.sell_return.getQuantity}} {% endif %}Shares of s:0 has been submitted for processing.</p> +<p align="center">Order Details:</p> +<table class="table-outer" cellspacing="0" align="center"> + <thead> + <tr> + <th>Order ID</th> + <th>Order Status</th> + <th>Creation Date</th> + <th>Completion Date</th> + <th>Txn Fee</th> + <th>Type</th> + <th>Symbol</th> + <th>Quantity</th> + </tr> + </thead> + <tbody> + {% if page.buy_return %} + <tr> + <td>{{page.buy_return.getOrderID}}</td> + <td>{{page.buy_return.getOrderStatus}}</td> + <td>{{page.buy_return.getCreationDate}}</td> + <td>{{page.buy_return.getCompletionDate}}</td> + <td>${{page.buy_return.getOrderFee}}</td> + <td>{{page.buy_return.getOrderType}}</td> + <td>{{page.buy_return.getSymbol}}</td> + <td>{{page.buy_return.getQuantity}}</td> + </tr> + {% endif %} + {% if page.sell_return %} + + <tr> + <td>{{page.sell_return.getOrderID}}</td> + <td>{{page.sell_return.getOrderStatus}}</td> + <td>{{page.sell_return.getCreationDate}}</td> + <td>{{page.sell_return.getCompletionDate}}</td> + <td>${{page.sell_return.getOrderFee}}</td> + <td>{{page.sell_return.getOrderType}}</td> + <td>{{page.sell_return.getSymbol}}</td> + <td>{{page.sell_return.getQuantity}}</td> + </tr> + {% endif %} + </tbody> +</table> +{% endifequal %} +{% ifequal page.is_reply False%} + +<div class="main-title"> + <h1>Stock Quotes</h1> + <script type="text/javascript"> + var thisdate = new Date(); + document.writeln(thisdate.toLocaleString()); + </script> +</div> +{% endifequal %} +{% endif %} + +{% if page.quote_return %} +<div class="main-title"> + <h1>Stock Quotes</h1> + <script type="text/javascript"> + var thisdate = new Date(); + document.writeln(thisdate.toLocaleString()); + </script> +</div> +<table class="table-outer" cellspacing="0" align="center"> + <thead> + <tr> + <th>Symbol</th> + <th>Company</th> + <th>Volume</th> + <th>Price Range</th> + <th>Open Price</th> + <th>Current Price</th> + <th>Gain(Loss)</th> + <th>Trade</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{page.quote_return.symbol}}</td> + <td>{{page.quote_return.company_name}}</td> + <td>{{page.quote_return.volume}}</td> + <td>${{page.quote_return.low}}-${{page.quote_return.high}}</td> + <td>${{page.quote_return.open}}</td> + <td>${{page.quote_return.price}}</td> + <td> + {% ifequal page.quote_return.change_t 'loss' %} + <span class="price-loss">${{ page.quote_return.change }}</span> + {% endifequal %} + {% ifequal page.quote_return.change_t 'gain' %} + <span class="price-gain">${{page.quote_return.change}}</span> + {% endifequal %} + {% ifequal page.quote_return.change_t 'bal' %} + <span>${{page.quote_return.change}}</span> + {% endifequal %} + </td> + <td> + <form action="/confirmation/" method="post"> + <input type="hidden" name="QUANTITY" value="{{page.quote_return.volume}}"/> + <input type="hidden" name="SYMBOL" value="{{page.quote_return.symbol}}"/> + <input type="hidden" name="PRICE" value="{{page.quote_return.price}}"/> + <input type="submit" name="BUY" value="Buy"></input> + </form> + </td> + </tr> + </tbody> +</table> +{% endif %} +{% if page.five_quotes %} + +<div class="main-title"> + <h1>Stock Quotes</h1> + <script type="text/javascript"> + var thisdate = new Date(); + document.writeln(thisdate.toLocaleString()); + </script> +</div> +<table class="table-outer" cellspacing="0" align="center"> + <thead> + <tr> + <th>Symbol</th> + <th>Company</th> + <th>Volume</th> + <th>Price Range</th> + <th>Open Price</th> + <th>Current Price</th> + <th>Gain(Loss)</th> + <th>Trade</th> + </tr> + </thead> + <tbody> + {% for quote in page.five_quotes %} + + <tr> + <td>{{quote.symbol}}</td> + <td>{{quote.company_name}}</td> + <td>{{quote.volume}}</td> + <td>${{quote.low}}-${{quote.high}}</td> + <td>${{quote.open}}</td> + <td>${{quote.price}}</td> + <td> + {% ifequal quote.change_t 'loss' %} + <span class="price-loss">${{ quote.change }}</span> + {% endifequal %} + {% ifequal quote.change_t 'gain' %} + <span class="price-gain">${{quote.change}}</span> + {% endifequal %} + {% ifequal quote.change_t 'bal' %} + <span>${{quote.change}}</span> + {% endifequal %} + </td> + <td> + <form action="/confirmation/" method="post"> + <input type="hidden" name="QUANTITY" value="{{quote.volume}}"/> + <input type="hidden" name="SYMBOL" value="{{quote.symbol}}"/> + <input type="hidden" name="PRICE" value="{{quote.price}}"/> + <input type="submit" name="BUY" value="Buy"></input> + </form> + </td> + </tr> + {% endfor %} + </tbody> +</table> +{% endif %} +<div class="bottom"> + <form method = "post" action = "/quotes/"> + <input type="text" value="" name="SYMBOLS" size="25"/> + <input type="submit" value="Get Quote" name="GETQUOTE" class="button"/> + </form> +</div> +{% endblock %} Added: incubator/stonehenge/contrib/stocktrader/python/trader_client/urls.py URL: http://svn.apache.org/viewvc/incubator/stonehenge/contrib/stocktrader/python/trader_client/urls.py?rev=720802&view=auto ============================================================================== --- incubator/stonehenge/contrib/stocktrader/python/trader_client/urls.py (added) +++ incubator/stonehenge/contrib/stocktrader/python/trader_client/urls.py Wed Nov 26 02:55:38 2008 @@ -0,0 +1,38 @@ + +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +from django.conf.urls.defaults import * +from django.conf import settings +import views + +urlpatterns = patterns( + '', + (r'^index/$', views.index_page), + (r'^config/$', views.config_page), + (r'^login/$', views.login_page), + (r'^account/$', views.account_view), + (r'^glossary/$', views.glossary_view), + (r'^quotes/$', views.quotes_view), + (r'^portfolio/$', views.portfolio_view), + (r'^home/$', views.home_view), + (r'^confirmation/$', views.confirmation_view), + (r'^site_media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': '/home/milinda/fun_projects/djangotest/stock_trader/media'}), + + # Example: + # (r'^stock_trader/', include('stock_trader.foo.urls')), + + # Uncomment this for admin: +# (r'^admin/', include('django.contrib.admin.urls')), +) Added: incubator/stonehenge/contrib/stocktrader/python/trader_client/views.py URL: http://svn.apache.org/viewvc/incubator/stonehenge/contrib/stocktrader/python/trader_client/views.py?rev=720802&view=auto ============================================================================== --- incubator/stonehenge/contrib/stocktrader/python/trader_client/views.py (added) +++ incubator/stonehenge/contrib/stocktrader/python/trader_client/views.py Wed Nov 26 02:55:38 2008 @@ -0,0 +1,230 @@ + +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +from django.shortcuts import render_to_response +from django import newforms as forms +from django.template.loader import get_template +from django.template import Context +from django.http import HttpResponse +from django.http import HttpResponseRedirect + +from request_processor import * + +class ConfigForm(forms.Form): + end_point = forms.CharField(widget=forms.TextInput(attrs={'size':'75',}), label='Address for Remote Host:') + +class LoginForm(forms.Form): + user_name = forms.CharField(widget=forms.TextInput(attrs={'size':'25',}), label='User Name:') + password = forms.CharField(widget=forms.PasswordInput(attrs={'size':'25',}), label='Password:') + + +def index_page(request): + return render_to_response('index.html', {'page':{'title':'WSF/Python StockTrader Welcome'}}) + +def config_page(request): + end_point = '' + default_epr='' + if request.method == 'POST' and 'SETENDPOINT' in request.POST: + form = ConfigForm(request.POST) + if form.is_valid(): + end_point = form.cleaned_data['end_point'] + response_post = HttpResponseRedirect('/login') + response_post.set_cookie('ENDPOINT', end_point) + return response_post + + else: + if 'ENDPOINT' in request.COOKIES: + default_epr = request.COOKIES['ENDPOINT'] + else: + default_epr = 'http://localhost:8080/config_service/config_svc.php' + form = ConfigForm(initial={'end_point':default_epr}) + + t = get_template('config.html') + html = t.render(Context({'page':{'title':'WSF/Python StockTrader Configuration', 'form': form}})) + response = HttpResponse(html) + return response + +def login_page(request): + reponse_post = None + form = None + if request.method == 'POST' and 'LOGINREQUEST' in request.POST: + form = LoginForm(request.POST) + if form.is_valid(): + user_name = form.cleaned_data['user_name'] + password = form.cleaned_data['password'] + epr = get_bs_epr(request.COOKIES['ENDPOINT']) + if login_request(user_name, password, epr): + reponse_post = HttpResponseRedirect('/account') + reponse_post.set_cookie('USERNAME', user_name) + else: + t = get_template('login.html') + form = LoginForm(initial={'user_name':'User Name or Password incorrect.', 'password':'User Name or Password incorrect.'}) + html = t.render(Context({'page':{'title':'WSF/Python StockTrader Login', 'form':form}})) + reponse_post = HttpResponse(html) + return reponse_post + else: + if 'USERNAME' in request.COOKIES and request.COOKIES['USERNAME'] != '': + user_name = request.COOKIES['USERNAME'] + epr = get_bs_epr(request.COOKIES['ENDPOINT']) + if logout_request(user_name, epr): + t = get_template('login.html') + form = LoginForm() + html = t.render(Context({'page':{'title':'WSF/Python StockTrader Login', 'form':form}})) + reponse_post = HttpResponse(html) + reponse_post.delete_cookie('USERNAME') + return reponse_post + else: + return render_to_response('login.html', {'page':{'title':'WSF/Python StockTrader Login', 'error':'<h1>Error occurred</h1>'}}) + else: + t = get_template('login.html') + form = LoginForm() + html = t.render(Context({'page':{'title':'WSF/Python StockTrader Login', 'form':form}})) + reponse_post = HttpResponse(html) + return reponse_post + +def account_view(request): + impact = None + balance = None + + if request.method == 'POST' and 'UPDATEUSERPROFILE' in request.POST: + username = request.COOKIES['USERNAME'] + password = request.POST['PASSWORD'] + fullname = request.POST['FULLNAME'] + address = request.POST['ADDRESS'] + email = request.POST['EMAIL'] + credit_card = request.POST['CREDITCARD'] + epr = get_bs_epr(request.POST['ENDPOINT']) + update_account_profile(username, password, fullname, address, email, credit_card, epr) + + if 'USERNAME' not in request.COOKIES: + return HttpResponseRedirect('/login') + else: + username = request.COOKIES['USERNAME'] + epr = get_bs_epr(request.COOKIES['ENDPOINT']) + orders_return = get_orders(username,epr) + orders = orders_return.getOrders() + if orders is not None: + accnt_sum = get_account_summary(orders) + + account_profile = get_account_profile(username, epr) + account_data = get_account_data(username, epr) + if accnt_sum.getTotalImpact() > 0: + impact = 'loss' + elif accnt_sum.getTotalImpact() < 0: + impact = 'gain' + else: + impact = 'bal' + + if account_data.getBalance() > 0: + balance = 'gain' + elif account_data.getBalance() < 0: + balance = 'loss' + else: + balance = 'bal' + + return render_to_response('account.html', {'page':{'title':'WSF/Python StockTrader Account', 'user_from_cookie':username, 'account_summary':accnt_sum, 'impact':impact, 'orders':orders, 'account_data':account_data, 'balance':balance, 'account_profile':account_profile}}) + +def glossary_view(request): + return render_to_response('glossary.html', {}) + +def quotes_view(request): + buy_return = None + sell_return = None + if 'USERNAME' not in request.COOKIES: + return HttpResponseRedirect('/login') + elif request.method == 'POST' and 'GETQUOTE' in request.POST: + symbol = request.POST['SYMBOLS'] + epr = get_bs_epr(request.COOKIES['ENDPOINT']) + username = request.COOKIES['USERNAME'] + quote_return = get_quote(symbol, epr) + closed_orders = get_closed_orders(username, epr) + return render_to_response('quotes.html', {'page':{'title':'WSF/Python StockTrader Quotes','quote_return':quote_return, 'closed_orders':closed_orders}}) + elif request.method == 'POST' and ( 'BUY' in request.POST or 'SELL' in request.POST): + quantity = request.POST['QUANTITY'] + username = request.COOKIES['USERNAME'] + epr = get_bs_epr(request.COOKIES['ENDPOINT']) + closed_orders = get_closed_orders(username, epr) + is_reply = False + if 'BUY' in request.POST: + symbol = request.POST['SYMBOL'] + buy_return = buy_request(username, symbol, quantity, 0, epr) + if buy_return.getOrderID(): + is_reply = True + return render_to_response('quotes.html', {'page':{'title': 'WSF/Python StockTrader Quotes', 'closed_orders':closed_orders, 'buy_return':buy_return, 'is_reply':is_reply}}) + else: + return render_to_response('quotes.html',{'page':{'title':'WSF/Python StockTrader', 'closed_orders':closed_orders, 'is_reply':is_reply}}) + if 'SELL' in request.POST: + holding_id = request.POST['HOLDINGID'] + sell_return = sell_request(username, holding_id, quantity, epr) + if sell_return.getOrderID(): + is_reply = True + return render_to_response('quotes.html', {'page':{'title':'WSF/Python StockTrader Quotes', 'closed_orders':closed_orders, 'sell_return':sell_return, 'is_reply':is_reply}}) + else: + return render_to_response('quotes.html',{'page':{'title':'WSF/Python StockTrader', 'closed_orders':closed_orders, 'is_reply':is_reply}}) + + epr = get_bs_epr(request.COOKIES['ENDPOINT']) + username= request.COOKIES['USERNAME'] + quotes = get_five_quotes(epr) + closed_orders = get_closed_orders(username, epr) + return render_to_response('quotes.html', {'page':{'title':'WSF/Python StockTrader quotes', 'five_quotes':quotes, 'closed_orders':closed_orders}}) + +def portfolio_view(request): + if 'USERNAME' not in request.COOKIES: + return HttpResponseRedirect('/login') + else: + username = request.COOKIES['USERNAME'] + epr = get_bs_epr(request.COOKIES['ENDPOINT']) + holdings = get_holdings(username, epr) + closed_orders = get_closed_orders(username, epr) + processed_hol = process_holdings(holdings, epr) + return render_to_response('portfolio.html', {'page':{'title':'WSF/Python StockTrader Portfolio','closed_orders':closed_orders, 'holdings':processed_hol}}) + +def home_view(request): + gain_type = 'bal' + if 'USERNAME' not in request.COOKIES: + return HttpResponseRedirect('/login') + else: + username = request.COOKIES['USERNAME'] + epr = get_bs_epr(request.COOKIES['ENDPOINT']) + mrket_summary = get_market_summary(epr) + account_data = get_account_data(username, epr) + holdings = get_holdings(username, epr) + processed_hol = process_holdings(holdings, epr) + sum = processed_hol.market_value + float(account_data.getBalance()) + gain = sum - float(account_data.getOpenBalance()) + gain_per = round((gain/float(account_data.getOpenBalance()))*100, 2) + if gain < 0: + gain_type = 'loss' + elif gain > 0: + gain_type = 'gain' + else: + gain_type = 'bal' + + return render_to_response('home.html', {'page':{'title':'WSF/Python StockTrader Home', 'user':username, 'account_data':account_data, 'holding_info':processed_hol, 'sum':sum, 'gain':gain, 'gain_per':gain_per, 'g_type':gain_type, 'market_summary':mrket_summary}}) + +def confirmation_view(request): + if 'USERNAME' not in request.COOKIES: + return HttpResponseRedirect('/login') + elif request.method == 'POST': + if 'BUY' in request.POST: + symbol = request.POST['SYMBOL'] + quantity = request.POST['QUANTITY'] + price = request.POST['PRICE'] + return render_to_response('confirmation.html', {'page':{'title':'WSF/Python StockTrader Confirmation', 'op':'buy', 'symbol':symbol, 'quantity':quantity, 'price':price}}) + elif 'SELL' in request.POST: + holding_id = request.POST['HOLDINGID'] + quantity = request.POST['QUANTITY'] + symbol = request.POST['SYMBOL'] + return render_to_response('confirmation.html', {'page':{'title':'WSF/Python StockTrader Confirmation', 'op':'sell', 'symbol':symbol, 'quantity':quantity, 'holding_id':holding_id}})