Building a distributed PSE

Over the last couple of years, I’ve been invested in building a distributed problem solving environment (PSE). I offer a simplified application here in the hopes that the general ideas can be useful to someone.

What has also initiated a desire to see this released is my wife’s iPhone with its addictive applications. On the downside, there is a serious lack of real estate and unless I convert to Mac I can’t get my hands on the SDK. However, coupling the iPhone’s portability with a personal server running traditional applications makes for a cheap and powerful PSE. Computational tasks and data storage can take place server side with the iPhone serving as a very pleasing web portal.

pse_fig

There are plenty of applications of these ideas to the sciences, for someone with a modicum of talent and vision. For the purposes of this example I’m going to use free financial data and the computational task will be options pricing under the Black Scholes model for European contracts. I’ve taken a data source at random, and I have no idea if there is a European style options contract available. Also realize that there is potentially unlimited risk associated with options, and it is widely held that the traditional theory is naïve and at worst downright wrong, particularly when using historical data to calculate volatility. So use this example under advisement…and as always, please be careful with curl, don’t get yourself banned 🙂

  1. Set up MySQL + Apache + PHP on a server
  2. Create Database + table on server:
  3. //invoke mysql (as root)
    >mysql –u root –p
    //create database
    >create database tech_stock;
    //extend permission to user bill with password *****
    >GRANT ALL ON tech_stock.* TO bill@localhost IDENTIFIED BY “*****“;
    //quit;
    >quit;
    //as user, invoke mysql as before; select database
    >mysql tech_stock –u bill –p
    //create a table
    >create table tech_A( n_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, date VARCHAR(8), open FLOAT,
    high FLOAT, low FLOAT, close FLOAT, volume FLOAT);
    //check it exists
    >DESCRIBE tech_A;
    //logout
    >quit;

  4. Write a shell script to grab data:
  5. #!/bin/sh
    # data update/download wjb 02/08
    Month=$(date +%b)
    Day=$(date +%d)
    Year=$(date +%G)
    str1=”http://finance.google.com/finance/historical?cid=659815&startdate=Feb+10%2C+2008&enddate=”
    str2=”%2C+”$Year”&output=csv”
    curl $str1$Month”+”$Day$str2 > tech_A.csv
    exit #cheerio

  6. Make a html portal:
  7. <html><body style=”font-family:verdana”>
    <title>PSE Demo</title>
    <form action=”main.php” method=”post” enctype=”multipart/form-data”>
    <font size=”5″ style=”color:blue”>Data Processing Portal<br>
    <table style=”background-color:blue”>
    <tr><td><font color=”white”>Password:</font> </td>
    <td><input type=”password” name=”pswd” /> </td></tr>
    <tr><td><font color=”white”>Email: </font></td>
    <td><input type=”text” name=”email” /> </td></tr>
    <tr><td><input type=”submit” name=”cmdupload” value=”Submit” /></tr></td>
    </table>
    </form>
    <br>
    <font size=”1″>
    Collaboratory for SDE data modeling <br>
    </font>
    </body></html>

more to come…

Advertisements