From ada6fa471b987ba44750ae5ad603b7292fb2f597 Mon Sep 17 00:00:00 2001 From: Aditya Relangi Date: Sat, 21 Sep 2013 23:38:02 -0500 Subject: [PATCH 1/3] almost finished --- arrayToCSV.php | 60 ++ json2csv.class.php | 85 ++- json2csv.php | 8 +- test.csv | 4 + test.json | 1757 ++++++++++++++++++++++++++++++++++++++++++++ test2.csv | 4 + 6 files changed, 1895 insertions(+), 23 deletions(-) create mode 100644 arrayToCSV.php create mode 100644 test.csv create mode 100644 test.json create mode 100644 test2.csv diff --git a/arrayToCSV.php b/arrayToCSV.php new file mode 100644 index 0000000..638abe4 --- /dev/null +++ b/arrayToCSV.php @@ -0,0 +1,60 @@ + \ No newline at end of file diff --git a/json2csv.class.php b/json2csv.class.php index 20e3c5d..c0d1d32 100644 --- a/json2csv.class.php +++ b/json2csv.class.php @@ -1,42 +1,67 @@ dataArray = json_decode($JSONdata,1); $this->prependColumnNames(); return $this->dataArray; } - function JSONfromFile($file){ - $this->dataArray = json_decode(file_get_contents($file),1); - $this->prependColumnNames(); - return $this->dataArray; + private function isNested($array){ + foreach($array as $data){ + if(is_array($data)){ + return TRUE; + } + } + return FALSE; } - private function prependColumnNames(){ - foreach(array_keys($this->dataArray[0]) as $key){ - $keys[0][$key] = $key; - } - $this->dataArray = array_merge($keys, $this->dataArray); + + private function getAllKeys($array) + { + $result = array(); + $children = array(); + foreach($array as $sub=>$value) { + if(gettype($value)=='array'){ + $children[] = $value; + //$result = array_merge($result,$this->getAllKeys($value)); + }else{ + $result [] = $sub; + } + } + + foreach ($children as $key => $value) { + $result = array_merge($result,$this->getAllKeys($value)); + } + return $result; } - function save2CSV($file){ - if($this->isItNested() || !is_array($this->dataArray)){ - echo "JSON is either invalid or has nested elements."; - } - else{ - $fileIO = fopen($file, 'w+'); - foreach ($this->dataArray as $fields) { - fputcsv($fileIO, $fields); + private function prependColumnNames(){ + $keys = array(); + foreach ($this->dataArray as $key => $value) { + + if($this->isNested($value)){ + $keys[] = $this->getAllKeys($this->dataArray[$key]); + break; } - fclose($fileIO); } + + if(count($keys)==0){ + $keys[] = $this->getAllKeys($this->dataArray[0]); + } + + $this->dataArray = array_merge($keys, $this->dataArray); } + function browserDL($CSVname){ + if($this->isItNested() || !is_array($this->dataArray)){ echo "

JSON is either invalid or has nested elements.

"; } @@ -47,11 +72,33 @@ function browserDL($CSVname){ $output = fopen('php://output', 'w'); foreach ($this->dataArray as $fields) { - fputcsv($output, $fields); + fwrite($output,arrayToCSV($fields)."\n"); } } } + + function JSONfromFile($file){ + $this->dataArray = json_decode(file_get_contents($file),1); + $this->prependColumnNames(); + return $this->dataArray; + } + + + function save2CSV($file){ + + if($this->isItNested() || !is_array($this->dataArray)){ + echo "JSON is either invalid or has nested elements."; + } + else{ + $fileIO = fopen($file, 'w+'); + foreach ($this->dataArray as $fields) { + fputcsv($fileIO, $fields); + } + fclose($fileIO); + } + } + private function isItNested(){ foreach($this->dataArray as $data){ if(is_array($data)){ diff --git a/json2csv.php b/json2csv.php index c5de3ec..a3dbf0c 100644 --- a/json2csv.php +++ b/json2csv.php @@ -21,13 +21,13 @@ $JSON2CSV->savejsonFile2csv($arguments["file"], $filepath); } - elseif($_FILES["file"]["type"] != NULL){ + elseif(($_FILES["file"]["type"]) != NULL){ $JSON2CSV->JSONfromFile($_FILES["file"]["tmp_name"]); - $JSON2CSV->browserDL("JSON2.CSV"); + $JSON2CSV->browserDL(str_replace("json", "csv", $_FILES["file"]["name"])); } elseif($_POST['json'] != NULL){ $JSON2CSV->readJSON($_POST['json']); - $JSON2CSV->browserDL("JSON2.CSV"); + $JSON2CSV->browserDL("JSON.CSV"); } } else{ @@ -38,7 +38,7 @@
-
diff --git a/test.csv b/test.csv new file mode 100644 index 0000000..b2b20ad --- /dev/null +++ b/test.csv @@ -0,0 +1,4 @@ +simulationNum,symbol,underlyingPrice,underlyingIV,forecastPrice,forecastIV,forecastDays,forecastTime,forecastAmount,isEliminated,reasonForElimination,responseTime,profitability,resultAmount,comissionTotal,pathRating,price,strike,time,days_to_expiration,quantity,nodeRating +100,BIDU,138.655,0.498208,137.7072068,0.012470372,3,20130907,2160,1,7,,3.963137865,,,,,,,,, +99,GTAT,6.385,0.623987,6.024596115,-0.970452275,49,20131023,1445,1,7,,3.969872952,,,,,,,,, +95,FSLR,36.875,0.537211,40.16163603,-0.198794657,28,20131002,2306,,-1,4.037657976,682.5133317,2190.2625,15.2625,0.909483618,,37,1380311700,30,-3,0.909483618 diff --git a/test.json b/test.json new file mode 100644 index 0000000..5337277 --- /dev/null +++ b/test.json @@ -0,0 +1,1757 @@ +[ + { + "simulationNum": 1, + "symbol": "BRCD", + "underlyingPrice": 7.515, + "underlyingIV": "0.00001", + "forecastPrice": 7.4516628808745, + "forecastIV": "0.7348473568809507", + "forecastDays": "31", + "forecastTime": "20131005", + "forecastAmount": "7175", + "isEliminated": true, + "reasonForElimination": 0, + "results": null, + "responseTime": 3.853453874588 + }, + { + "simulationNum": 2, + "symbol": "AA", + "underlyingPrice": 7.935, + "underlyingIV": "0.00001", + "forecastPrice": 9.5423367476894, + "forecastIV": "0.06476055389582175", + "forecastDays": "77", + "forecastTime": "20131120", + "forecastAmount": "1390", + "isEliminated": true, + "reasonForElimination": 0, + "results": null, + "responseTime": 0.0065140724182129 + }, + { + "simulationNum": 3, + "symbol": "QCOM", + "underlyingPrice": 66.48, + "underlyingIV": "1.669748", + "forecastPrice": 66.844120689926, + "forecastIV": "1.8791631487013025", + "forecastDays": "63", + "forecastTime": "20131106", + "forecastAmount": "3452", + "isEliminated": true, + "reasonForElimination": 0, + "results": null, + "responseTime": 3.8255550861359 + }, + { + "simulationNum": 4, + "symbol": "TJX", + "underlyingPrice": 52.77, + "underlyingIV": "1.218931", + "forecastPrice": 53.396796568636, + "forecastIV": "0.15677252543244977", + "forecastDays": "79", + "forecastTime": "20131122", + "forecastAmount": "12163", + "isEliminated": true, + "reasonForElimination": 0, + "results": null, + "responseTime": 4.1730380058289 + }, + { + "simulationNum": 5, + "symbol": "AET", + "underlyingPrice": 62.71, + "underlyingIV": "1.192597", + "forecastPrice": 61.577107384842, + "forecastIV": "-0.04006672102544904", + "forecastDays": "12", + "forecastTime": "20130916", + "forecastAmount": "2039", + "isEliminated": true, + "reasonForElimination": 7, + "results": null, + "responseTime": 0.013778924942017 + }, + { + "simulationNum": 6, + "symbol": "BAC", + "underlyingPrice": 14.135, + "underlyingIV": "2.16719", + "forecastPrice": 14.195408625931, + "forecastIV": "0.9112554809823259", + "forecastDays": "34", + "forecastTime": "20131008", + "forecastAmount": "11859", + "isEliminated": true, + "reasonForElimination": 0, + "results": null, + "responseTime": 0.017107009887695 + }, + { + "simulationNum": 7, + "symbol": "DVN", + "underlyingPrice": 57.75, + "underlyingIV": "0.00001", + "forecastPrice": 57.841545378565, + "forecastIV": "0.027656484611995893", + "forecastDays": "4", + "forecastTime": "20130908", + "forecastAmount": "3631", + "isEliminated": true, + "reasonForElimination": 0, + "results": null, + "responseTime": 3.7583498954773 + }, + { + "simulationNum": 8, + "symbol": "FIS", + "underlyingPrice": 44.905, + "underlyingIV": "1.346704", + "forecastPrice": 43.602603467169, + "forecastIV": "-0.05205114190435299", + "forecastDays": "19", + "forecastTime": "20130923", + "forecastAmount": "8558", + "isEliminated": true, + "reasonForElimination": 7, + "results": null, + "responseTime": 3.9549739360809 + }, + { + "simulationNum": 9, + "symbol": "SUNE", + "underlyingPrice": 7.39, + "underlyingIV": "0.00001", + "forecastPrice": 8.6905314291887, + "forecastIV": "0.27277782697907194", + "forecastDays": "53", + "forecastTime": "20131027", + "forecastAmount": "5844", + "isEliminated": true, + "reasonForElimination": 0, + "results": null, + "responseTime": 0.0071079730987549 + }, + { + "simulationNum": 10, + "symbol": "KSS", + "underlyingPrice": 50.27, + "underlyingIV": "0.00001", + "forecastPrice": 45.783694178827, + "forecastIV": "0.16811908373381945", + "forecastDays": "51", + "forecastTime": "20131025", + "forecastAmount": "6088", + "isEliminated": true, + "reasonForElimination": 7, + "results": null, + "responseTime": 0.011107206344604 + }, + { + "simulationNum": 11, + "symbol": "INVN", + "underlyingPrice": 17.47, + "underlyingIV": "2.502673", + "forecastPrice": 17.426804529526, + "forecastIV": "0.04817834941272549", + "forecastDays": "4", + "forecastTime": "20130908", + "forecastAmount": "8039", + "isEliminated": true, + "reasonForElimination": 0, + "results": null, + "responseTime": 0.0075461864471436 + }, + { + "simulationNum": 12, + "symbol": "GIS", + "underlyingPrice": 48.725, + "underlyingIV": "1.041055", + "forecastPrice": 48.200297583126, + "forecastIV": "-0.24021322780493645", + "forecastDays": "42", + "forecastTime": "20131016", + "forecastAmount": "4942", + "isEliminated": true, + "reasonForElimination": 7, + "results": null, + "responseTime": 0.012515068054199 + }, + { + "simulationNum": 13, + "symbol": "NPSP", + "underlyingPrice": 25.455, + "underlyingIV": "0.00001", + "forecastPrice": 18.598844707308, + "forecastIV": "0.4344281532657519", + "forecastDays": "58", + "forecastTime": "20131101", + "forecastAmount": "2657", + "isEliminated": true, + "reasonForElimination": 7, + "results": null, + "responseTime": 4.2060298919678 + }, + { + "simulationNum": 14, + "symbol": "TWX", + "underlyingPrice": 60.905, + "underlyingIV": "1.194517", + "forecastPrice": 53.915259040986, + "forecastIV": "0.4056292061956711", + "forecastDays": "29", + "forecastTime": "20131003", + "forecastAmount": "48433", + "isEliminated": true, + "reasonForElimination": 7, + "results": null, + "responseTime": 4.1895558834076 + }, + { + "simulationNum": 15, + "symbol": "EWJ", + "underlyingPrice": 11.085, + "underlyingIV": "0.27545", + "forecastPrice": 10.002890081589, + "forecastIV": "-1.513149252259489", + "forecastDays": "74", + "forecastTime": "20131117", + "forecastAmount": "21177", + "isEliminated": true, + "reasonForElimination": 7, + "results": null, + "responseTime": 0.01491904258728 + }, + { + "simulationNum": 16, + "symbol": "EZU", + "underlyingPrice": 35.5, + "underlyingIV": "0.469201", + "forecastPrice": 35.773053463701, + "forecastIV": "0.23221417962010502", + "forecastDays": "16", + "forecastTime": "20130920", + "forecastAmount": "2458", + "isEliminated": false, + "reasonForElimination": -1, + "results": { + "profitability": 535.47702780641, + "resultAmount": 2145.2625, + "comissionTotal": 15.2625, + "pathRating": 0.51735265796424, + "results": [ + { + "price": null, + "strike": "35", + "time": 1379736000, + "days_to_expiration": "24", + "quantity": -3, + "nodeRating": 0.51735265796424 + } + ] + }, + "responseTime": 4.2060079574585 + }, + { + "simulationNum": 17, + "symbol": "UNH", + "underlyingPrice": 71.545, + "underlyingIV": "1.088036", + "forecastPrice": 68.198067074057, + "forecastIV": "0.34610210633235516", + "forecastDays": "81", + "forecastTime": "20131124", + "forecastAmount": "1160", + "isEliminated": true, + "reasonForElimination": 7, + "results": null, + "responseTime": 4.2310478687286 + }, + { + "simulationNum": 18, + "symbol": "ABBV", + "underlyingPrice": 42.64, + "underlyingIV": "0.190888", + "forecastPrice": 48.35853142088, + "forecastIV": "-0.22464400086939332", + "forecastDays": "68", + "forecastTime": "20131111", + "forecastAmount": "4269", + "isEliminated": true, + "reasonForElimination": 0, + "results": null, + "responseTime": 3.8867390155792 + }, + { + "simulationNum": 19, + "symbol": "PVA", + "underlyingPrice": 4.75, + "underlyingIV": "0.45282", + "forecastPrice": 4.6419962237685, + "forecastIV": "0.22496898685811997", + "forecastDays": "21", + "forecastTime": "20130925", + "forecastAmount": "4592", + "isEliminated": true, + "reasonForElimination": 7, + "results": null, + "responseTime": 3.8402941226959 + }, + { + "simulationNum": 20, + "symbol": "AVGO", + "underlyingPrice": 38.345, + "underlyingIV": "1.041328", + "forecastPrice": 34.063456314907, + "forecastIV": "0.17067305867876398", + "forecastDays": "61", + "forecastTime": "20131104", + "forecastAmount": "2101", + "isEliminated": true, + "reasonForElimination": 7, + "results": null, + "responseTime": 3.8776648044586 + }, + { + "simulationNum": 21, + "symbol": "FXI", + "underlyingPrice": 35.11, + "underlyingIV": "0.00001", + "forecastPrice": 26.370032170071, + "forecastIV": "-0.4502789113865374", + "forecastDays": "47", + "forecastTime": "20131021", + "forecastAmount": "257600", + "isEliminated": true, + "reasonForElimination": 7, + "results": null, + "responseTime": 3.8954350948334 + }, + { + "simulationNum": 22, + "symbol": "BAX", + "underlyingPrice": 70.615, + "underlyingIV": "1.007063", + "forecastPrice": 67.385922059603, + "forecastIV": "-0.8946661273526726", + "forecastDays": "35", + "forecastTime": "20131009", + "forecastAmount": "3805", + "isEliminated": true, + "reasonForElimination": 7, + "results": null, + "responseTime": 4.2160289287567 + }, + { + "simulationNum": 23, + "symbol": "USO", + "underlyingPrice": 39.15, + "underlyingIV": "0.680847", + "forecastPrice": 39.806037983447, + "forecastIV": "-0.004608341572573414", + "forecastDays": "24", + "forecastTime": "20130928", + "forecastAmount": "3235", + "isEliminated": false, + "reasonForElimination": -1, + "results": { + "profitability": 1039.6006651672, + "resultAmount": 3148.5, + "comissionTotal": 16.5, + "pathRating": 0.89749904920544, + "results": [ + { + "price": null, + "strike": "39", + "time": 1379793540, + "days_to_expiration": "24", + "quantity": -4, + "nodeRating": 0.89749904920544 + } + ] + }, + "responseTime": 4.2632439136505 + }, + { + "simulationNum": 24, + "symbol": "SBUX", + "underlyingPrice": 71.15, + "underlyingIV": "1.124035", + "forecastPrice": 76.153248094104, + "forecastIV": "0.771861610683389", + "forecastDays": "70", + "forecastTime": "20131113", + "forecastAmount": "2393", + "isEliminated": false, + "reasonForElimination": -1, + "results": { + "profitability": 215.54982227179, + "resultAmount": 1435.7875, + "comissionTotal": 12.7875, + "pathRating": 0.86650920977876, + "results": [ + { + "price": null, + "strike": "71", + "time": 1377892740, + "days_to_expiration": "2", + "quantity": -1, + "nodeRating": 0.86650920977876 + } + ] + }, + "responseTime": 4.2171630859375 + }, + { + "simulationNum": 25, + "symbol": "RSO", + "underlyingPrice": 5.9, + "underlyingIV": "0.541087", + "forecastPrice": 5.4162091051252, + "forecastIV": "0.43021448310172183", + "forecastDays": "33", + "forecastTime": "20131007", + "forecastAmount": "342622", + "isEliminated": true, + "reasonForElimination": 7, + "results": null, + "responseTime": 4.1772780418396 + }, + { + "simulationNum": 26, + "symbol": "SSO", + "underlyingPrice": 79.595, + "underlyingIV": "0.928663", + "forecastPrice": 94.84254544432, + "forecastIV": "-0.12296647283651868", + "forecastDays": "75", + "forecastTime": "20131118", + "forecastAmount": "5225", + "isEliminated": false, + "reasonForElimination": -1, + "results": { + "profitability": 624.64379782075, + "resultAmount": 4790.9625, + "comissionTotal": 15.2625, + "pathRating": 0.88516322825689, + "results": [ + { + "price": null, + "strike": "79.5", + "time": 1377889140, + "days_to_expiration": "2", + "quantity": -3, + "nodeRating": 0.88516322825689 + } + ] + }, + "responseTime": 4.2455389499664 + }, + { + "simulationNum": 27, + "symbol": "MO", + "underlyingPrice": 33.585, + "underlyingIV": "0.148941", + "forecastPrice": 37.745259400841, + "forecastIV": "-0.30065229072645305", + "forecastDays": "77", + "forecastTime": "20131120", + "forecastAmount": "2209", + "isEliminated": true, + "reasonForElimination": 0, + "results": null, + "responseTime": 4.2031118869781 + }, + { + "simulationNum": 28, + "symbol": "GRPN", + "underlyingPrice": 10.035, + "underlyingIV": "3.767278", + "forecastPrice": 9.474278564139, + "forecastIV": "-0.011967277131058995", + "forecastDays": "16", + "forecastTime": "20130920", + "forecastAmount": "4738", + "isEliminated": true, + "reasonForElimination": 0, + "results": null, + "responseTime": 4.2113461494446 + }, + { + "simulationNum": 29, + "symbol": "SIRI", + "underlyingPrice": 3.585, + "underlyingIV": "0.575985", + "forecastPrice": 3.2995212466108, + "forecastIV": "0.6461672022847971", + "forecastDays": "63", + "forecastTime": "20131106", + "forecastAmount": "3481", + "isEliminated": true, + "reasonForElimination": 7, + "results": null, + "responseTime": 4.1843540668488 + }, + { + "simulationNum": 30, + "symbol": "DDD", + "underlyingPrice": 50.375, + "underlyingIV": "0.00001", + "forecastPrice": 47.310376300966, + "forecastIV": "0.83304376304809", + "forecastDays": "48", + "forecastTime": "20131022", + "forecastAmount": "3487", + "isEliminated": true, + "reasonForElimination": 7, + "results": null, + "responseTime": 4.0859730243683 + }, + { + "simulationNum": 31, + "symbol": "LNG", + "underlyingPrice": 28.615, + "underlyingIV": "1.267604", + "forecastPrice": 27.233075489587, + "forecastIV": "0.30443992600965963", + "forecastDays": "15", + "forecastTime": "20130919", + "forecastAmount": "54721", + "isEliminated": true, + "reasonForElimination": 7, + "results": null, + "responseTime": 4.0790328979492 + }, + { + "simulationNum": 32, + "symbol": "VWO", + "underlyingPrice": 37.195, + "underlyingIV": "0.00001", + "forecastPrice": 37.607560156415, + "forecastIV": "0.3982780709462948", + "forecastDays": "24", + "forecastTime": "20130928", + "forecastAmount": "3098", + "isEliminated": true, + "reasonForElimination": 0, + "results": null, + "responseTime": 0.015713930130005 + }, + { + "simulationNum": 33, + "symbol": "BRCM", + "underlyingPrice": 24.92, + "underlyingIV": "0.00001", + "forecastPrice": 27.088886970943, + "forecastIV": "-0.20601618088317103", + "forecastDays": "54", + "forecastTime": "20131028", + "forecastAmount": "6302", + "isEliminated": true, + "reasonForElimination": 0, + "results": null, + "responseTime": 4.0882520675659 + }, + { + "simulationNum": 34, + "symbol": "RAD", + "underlyingPrice": 3.355, + "underlyingIV": "1.256817", + "forecastPrice": 2.9221537292564, + "forecastIV": "0.2000779400773141", + "forecastDays": "28", + "forecastTime": "20131002", + "forecastAmount": "6023", + "isEliminated": true, + "reasonForElimination": 7, + "results": null, + "responseTime": 4.0630691051483 + }, + { + "simulationNum": 35, + "symbol": "IBM", + "underlyingPrice": 182.07, + "underlyingIV": "0.00001", + "forecastPrice": 182.03402973284, + "forecastIV": "-0.3107974902959689", + "forecastDays": "20", + "forecastTime": "20130924", + "forecastAmount": "9718", + "isEliminated": true, + "reasonForElimination": 0, + "results": null, + "responseTime": 4.0727751255035 + }, + { + "simulationNum": 36, + "symbol": "ONNN", + "underlyingPrice": 7.22, + "underlyingIV": "1.305182", + "forecastPrice": 6.4646153357584, + "forecastIV": "0.43400587586995676", + "forecastDays": "35", + "forecastTime": "20131009", + "forecastAmount": "2323", + "isEliminated": true, + "reasonForElimination": 7, + "results": null, + "responseTime": 4.0125360488892 + }, + { + "simulationNum": 37, + "symbol": "RLGY", + "underlyingPrice": 42.55, + "underlyingIV": "0.488903", + "forecastPrice": 35.568159920278, + "forecastIV": "0.366217058450128", + "forecastDays": "63", + "forecastTime": "20131106", + "forecastAmount": "36274", + "isEliminated": true, + "reasonForElimination": 7, + "results": null, + "responseTime": 3.8940970897675 + }, + { + "simulationNum": 38, + "symbol": "CHK", + "underlyingPrice": 26.34, + "underlyingIV": "3.16667", + "forecastPrice": 25.970242815152, + "forecastIV": "0.46588909228465514", + "forecastDays": "60", + "forecastTime": "20131103", + "forecastAmount": "26795", + "isEliminated": true, + "reasonForElimination": 0, + "results": null, + "responseTime": 3.9119720458984 + }, + { + "simulationNum": 39, + "symbol": "GMCR", + "underlyingPrice": 86.88, + "underlyingIV": "2.785518", + "forecastPrice": 82.526376129233, + "forecastIV": "0.09749239683202002", + "forecastDays": "35", + "forecastTime": "20131009", + "forecastAmount": "18288", + "isEliminated": true, + "reasonForElimination": 0, + "results": null, + "responseTime": 3.9561188220978 + }, + { + "simulationNum": 40, + "symbol": "DF", + "underlyingPrice": 18.955, + "underlyingIV": "0.352134", + "forecastPrice": 20.304742533242, + "forecastIV": "-0.79965115212839", + "forecastDays": "31", + "forecastTime": "20131005", + "forecastAmount": "2017", + "isEliminated": true, + "reasonForElimination": 0, + "results": null, + "responseTime": 3.9491629600525 + }, + { + "simulationNum": 41, + "symbol": "XME", + "underlyingPrice": 36.485, + "underlyingIV": "0.00001", + "forecastPrice": 38.168286025483, + "forecastIV": "-0.25343446049672735", + "forecastDays": "31", + "forecastTime": "20131005", + "forecastAmount": "2366", + "isEliminated": true, + "reasonForElimination": 0, + "results": null, + "responseTime": 3.9165709018707 + }, + { + "simulationNum": 42, + "symbol": "CHK", + "underlyingPrice": 26.34, + "underlyingIV": "3.16667", + "forecastPrice": 23.654514756345, + "forecastIV": "1.5535509801893075", + "forecastDays": "77", + "forecastTime": "20131120", + "forecastAmount": "17878", + "isEliminated": true, + "reasonForElimination": 0, + "results": null, + "responseTime": 0.016528129577637 + }, + { + "simulationNum": 43, + "symbol": "NBR", + "underlyingPrice": 15.7, + "underlyingIV": "0.562626", + "forecastPrice": 16.867297470379, + "forecastIV": "-0.5433489341728446", + "forecastDays": "27", + "forecastTime": "20131001", + "forecastAmount": "10666", + "isEliminated": false, + "reasonForElimination": -1, + "results": { + "profitability": 3892.7834337203, + "resultAmount": 10565.3375, + "comissionTotal": 57.3375, + "pathRating": 0.70212656003453, + "results": [ + { + "price": null, + "strike": "16", + "time": 1379771520, + "days_to_expiration": "24", + "quantity": -37, + "nodeRating": 0.70212656003453 + } + ] + }, + "responseTime": 4.0782918930054 + }, + { + "simulationNum": 44, + "symbol": "BAC", + "underlyingPrice": 14.135, + "underlyingIV": "2.16719", + "forecastPrice": 14.710764711411, + "forecastIV": "0.4236184550981409", + "forecastDays": "47", + "forecastTime": "20131021", + "forecastAmount": "3649", + "isEliminated": true, + "reasonForElimination": 0, + "results": null, + "responseTime": 0.01314902305603 + }, + { + "simulationNum": 45, + "symbol": "VTI", + "underlyingPrice": 85.105, + "underlyingIV": "1.233343", + "forecastPrice": 84.455946348836, + "forecastIV": "0.09909530196948554", + "forecastDays": "7", + "forecastTime": "20130911", + "forecastAmount": "11465", + "isEliminated": true, + "reasonForElimination": 7, + "results": null, + "responseTime": 4.0929718017578 + }, + { + "simulationNum": 46, + "symbol": "WLT", + "underlyingPrice": 13.025, + "underlyingIV": "0.00001", + "forecastPrice": 13.025634158455, + "forecastIV": "-0.09549263776366691", + "forecastDays": "1", + "forecastTime": "20130905", + "forecastAmount": "19938", + "isEliminated": true, + "reasonForElimination": 0, + "results": null, + "responseTime": 4.0910828113556 + }, + { + "simulationNum": 47, + "symbol": "TXT", + "underlyingPrice": 26.78, + "underlyingIV": "0.00001", + "forecastPrice": 28.410591675222, + "forecastIV": "-0.07300206225018949", + "forecastDays": "77", + "forecastTime": "20131120", + "forecastAmount": "5603", + "isEliminated": true, + "reasonForElimination": 0, + "results": null, + "responseTime": 3.9316411018372 + }, + { + "simulationNum": 48, + "symbol": "SUNE", + "underlyingPrice": 7.39, + "underlyingIV": "0.00001", + "forecastPrice": 6.8127380608218, + "forecastIV": "0.7919080694017354", + "forecastDays": "24", + "forecastTime": "20130928", + "forecastAmount": "5165", + "isEliminated": true, + "reasonForElimination": 7, + "results": null, + "responseTime": 0.0098412036895752 + }, + { + "simulationNum": 49, + "symbol": "TSLA", + "underlyingPrice": 166.17, + "underlyingIV": "0.666946", + "forecastPrice": 182.45271554464, + "forecastIV": "1.877748587090792", + "forecastDays": "69", + "forecastTime": "20131112", + "forecastAmount": "10136", + "isEliminated": false, + "reasonForElimination": -1, + "results": { + "profitability": 4776.8908537024, + "resultAmount": 9985.4625, + "comissionTotal": 15.2625, + "pathRating": 0.81720968123379, + "results": [ + { + "price": null, + "strike": "165", + "time": 1382212560, + "days_to_expiration": "52", + "quantity": -3, + "nodeRating": 0.81720968123379 + } + ] + }, + "responseTime": 4.2338669300079 + }, + { + "simulationNum": 50, + "symbol": "PVA", + "underlyingPrice": 4.75, + "underlyingIV": "0.45282", + "forecastPrice": 5.6770655803829, + "forecastIV": "-1.0927756680798064", + "forecastDays": "66", + "forecastTime": "20131109", + "forecastAmount": "3276", + "isEliminated": true, + "reasonForElimination": 0, + "results": null, + "responseTime": 0.0015318393707275 + }, + { + "simulationNum": 51, + "symbol": "F", + "underlyingPrice": 16.03, + "underlyingIV": "0.00001", + "forecastPrice": 16.648484673552, + "forecastIV": "-0.1371834974633271", + "forecastDays": "11", + "forecastTime": "20130915", + "forecastAmount": "4055", + "isEliminated": true, + "reasonForElimination": 0, + "results": null, + "responseTime": 0.013460159301758 + }, + { + "simulationNum": 52, + "symbol": "VLO", + "underlyingPrice": 35.725, + "underlyingIV": "0.270007", + "forecastPrice": 37.025927754132, + "forecastIV": "-0.23280173831125908", + "forecastDays": "26", + "forecastTime": "20130930", + "forecastAmount": "2925", + "isEliminated": true, + "reasonForElimination": 0, + "results": null, + "responseTime": 4.0940380096436 + }, + { + "simulationNum": 53, + "symbol": "MOVE", + "underlyingPrice": 14.665, + "underlyingIV": "0.00001", + "forecastPrice": 15.16372339007, + "forecastIV": "1.8379563457045656", + "forecastDays": "73", + "forecastTime": "20131116", + "forecastAmount": "8711", + "isEliminated": true, + "reasonForElimination": 0, + "results": null, + "responseTime": 4.0650429725647 + }, + { + "simulationNum": 54, + "symbol": "GOOG", + "underlyingPrice": 849.27, + "underlyingIV": "0.705519", + "forecastPrice": 837.03747456737, + "forecastIV": "0.3135816621495247", + "forecastDays": "8", + "forecastTime": "20130912", + "forecastAmount": "3228", + "isEliminated": true, + "reasonForElimination": 7, + "results": null, + "responseTime": 4.1119258403778 + }, + { + "simulationNum": 55, + "symbol": "XLU", + "underlyingPrice": 37.48, + "underlyingIV": "0.864624", + "forecastPrice": 40.565146115277, + "forecastIV": "-0.4301542730228743", + "forecastDays": "25", + "forecastTime": "20130929", + "forecastAmount": "2139", + "isEliminated": false, + "reasonForElimination": -1, + "results": { + "profitability": 672.73214413529, + "resultAmount": 1513.225, + "comissionTotal": 14.025, + "pathRating": 0.76538062075385, + "results": [ + { + "price": null, + "strike": "37", + "time": 1380301140, + "days_to_expiration": "30", + "quantity": -2, + "nodeRating": 0.76538062075385 + } + ] + }, + "responseTime": 3.9197208881378 + }, + { + "simulationNum": 56, + "symbol": "FB", + "underlyingPrice": 40.515, + "underlyingIV": "1.306589", + "forecastPrice": 36.921619436698, + "forecastIV": "0.15718020063124594", + "forecastDays": "50", + "forecastTime": "20131024", + "forecastAmount": "53519", + "isEliminated": true, + "reasonForElimination": 0, + "results": null, + "responseTime": 0.027608156204224 + }, + { + "simulationNum": 57, + "symbol": "GDX", + "underlyingPrice": 28.415, + "underlyingIV": "0.00001", + "forecastPrice": 31.988118284322, + "forecastIV": "-0.5344142053124867", + "forecastDays": "49", + "forecastTime": "20131023", + "forecastAmount": "3724", + "isEliminated": true, + "reasonForElimination": 0, + "results": null, + "responseTime": 4.0311560630798 + }, + { + "simulationNum": 58, + "symbol": "PEP", + "underlyingPrice": 79.335, + "underlyingIV": "0.658389", + "forecastPrice": 71.379550226819, + "forecastIV": "-0.05713409608531281", + "forecastDays": "43", + "forecastTime": "20131017", + "forecastAmount": "4644", + "isEliminated": true, + "reasonForElimination": 7, + "results": null, + "responseTime": 3.9086668491364 + }, + { + "simulationNum": 59, + "symbol": "GPOR", + "underlyingPrice": 59.73, + "underlyingIV": "1.164064", + "forecastPrice": 57.405479050946, + "forecastIV": "0.2593070985630872", + "forecastDays": "13", + "forecastTime": "20130917", + "forecastAmount": "4297", + "isEliminated": true, + "reasonForElimination": 7, + "results": null, + "responseTime": 3.9329929351807 + }, + { + "simulationNum": 60, + "symbol": "CSC", + "underlyingPrice": 49.935, + "underlyingIV": "1.368271", + "forecastPrice": 52.962596722513, + "forecastIV": "-0.8011229496786139", + "forecastDays": "41", + "forecastTime": "20131015", + "forecastAmount": "4608", + "isEliminated": true, + "reasonForElimination": 0, + "results": null, + "responseTime": 4.0655331611633 + }, + { + "simulationNum": 61, + "symbol": "EEM", + "underlyingPrice": 37.42, + "underlyingIV": "0.00001", + "forecastPrice": 38.556279731255, + "forecastIV": "0.10047195109970866", + "forecastDays": "37", + "forecastTime": "20131011", + "forecastAmount": "37926", + "isEliminated": true, + "reasonForElimination": 0, + "results": null, + "responseTime": 0.035956144332886 + }, + { + "simulationNum": 62, + "symbol": "BAC", + "underlyingPrice": 14.135, + "underlyingIV": "2.16719", + "forecastPrice": 15.004956840132, + "forecastIV": "0.31368127846225163", + "forecastDays": "77", + "forecastTime": "20131120", + "forecastAmount": "3684", + "isEliminated": true, + "reasonForElimination": 0, + "results": null, + "responseTime": 0.01463794708252 + }, + { + "simulationNum": 63, + "symbol": "NEM", + "underlyingPrice": 31.365, + "underlyingIV": "0.00001", + "forecastPrice": 32.30343782782, + "forecastIV": "-0.5083502626705839", + "forecastDays": "14", + "forecastTime": "20130918", + "forecastAmount": "1952", + "isEliminated": true, + "reasonForElimination": 0, + "results": null, + "responseTime": 4.0545301437378 + }, + { + "simulationNum": 64, + "symbol": "RWM", + "underlyingPrice": 19.665, + "underlyingIV": "0.534323", + "forecastPrice": 20.367613736554, + "forecastIV": "-0.30045708688663575", + "forecastDays": "22", + "forecastTime": "20130926", + "forecastAmount": "2389", + "isEliminated": false, + "reasonForElimination": -1, + "results": { + "profitability": 734.59919985072, + "resultAmount": 2177.775, + "comissionTotal": 18.975, + "pathRating": 0.48675096807547, + "results": [ + { + "price": null, + "strike": "20", + "time": 1379736000, + "days_to_expiration": "24", + "quantity": -6, + "nodeRating": 0.48675096807547 + } + ] + }, + "responseTime": 4.0884051322937 + }, + { + "simulationNum": 65, + "symbol": "CAG", + "underlyingPrice": 33.98, + "underlyingIV": "1.082056", + "forecastPrice": 37.42345590099, + "forecastIV": "-1.7251451604320946", + "forecastDays": "58", + "forecastTime": "20131101", + "forecastAmount": "2277", + "isEliminated": false, + "reasonForElimination": -1, + "results": { + "profitability": 1635.4897129741, + "resultAmount": 2048.0625, + "comissionTotal": 15.2625, + "pathRating": 0.96857875051433, + "results": [ + { + "price": null, + "strike": "34", + "time": 1382208900, + "days_to_expiration": "52", + "quantity": -3, + "nodeRating": 0.96857875051433 + } + ] + }, + "responseTime": 4.0305600166321 + }, + { + "simulationNum": 66, + "symbol": "XLP", + "underlyingPrice": 39.21, + "underlyingIV": "0.88513", + "forecastPrice": 35.579174549048, + "forecastIV": "0.6575220830961113", + "forecastDays": "30", + "forecastTime": "20131004", + "forecastAmount": "2014", + "isEliminated": true, + "reasonForElimination": 7, + "results": null, + "responseTime": 4.1055219173431 + }, + { + "simulationNum": 67, + "symbol": "QID", + "underlyingPrice": 21.01, + "underlyingIV": "0.518836", + "forecastPrice": 19.871815958288, + "forecastIV": "0.9367394827056676", + "forecastDays": "58", + "forecastTime": "20131101", + "forecastAmount": "2047", + "isEliminated": true, + "reasonForElimination": 7, + "results": null, + "responseTime": 4.0178039073944 + }, + { + "simulationNum": 68, + "symbol": "MRO", + "underlyingPrice": 34.555, + "underlyingIV": "0.752113", + "forecastPrice": 33.348422999047, + "forecastIV": "0.007265865190554069", + "forecastDays": "14", + "forecastTime": "20130918", + "forecastAmount": "2026", + "isEliminated": true, + "reasonForElimination": 7, + "results": null, + "responseTime": 4.030345916748 + }, + { + "simulationNum": 69, + "symbol": "KIM", + "underlyingPrice": 20.105, + "underlyingIV": "0.00001", + "forecastPrice": 19.112918309839, + "forecastIV": "0.5500190722407214", + "forecastDays": "46", + "forecastTime": "20131020", + "forecastAmount": "10204", + "isEliminated": true, + "reasonForElimination": 7, + "results": null, + "responseTime": 3.9435579776764 + }, + { + "simulationNum": 70, + "symbol": "WFM", + "underlyingPrice": 52.055, + "underlyingIV": "0.00001", + "forecastPrice": 51.50594128301, + "forecastIV": "-2.0580711628269492", + "forecastDays": "80", + "forecastTime": "20131123", + "forecastAmount": "8182", + "isEliminated": true, + "reasonForElimination": 0, + "results": null, + "responseTime": 4.0115628242493 + }, + { + "simulationNum": 71, + "symbol": "FL", + "underlyingPrice": 32.535, + "underlyingIV": "0.182756", + "forecastPrice": 25.552000043305, + "forecastIV": "-0.01645401288356163", + "forecastDays": "69", + "forecastTime": "20131112", + "forecastAmount": "16320", + "isEliminated": true, + "reasonForElimination": 7, + "results": null, + "responseTime": 4.0094561576843 + }, + { + "simulationNum": 72, + "symbol": "BAC", + "underlyingPrice": 14.135, + "underlyingIV": "2.16719", + "forecastPrice": 13.377782137618, + "forecastIV": "0.23989610745989715", + "forecastDays": "71", + "forecastTime": "20131114", + "forecastAmount": "3609", + "isEliminated": true, + "reasonForElimination": 0, + "results": null, + "responseTime": 0.013402223587036 + }, + { + "simulationNum": 73, + "symbol": "HOV", + "underlyingPrice": 5.18, + "underlyingIV": "0.751747", + "forecastPrice": 5.5931539111144, + "forecastIV": "0.36730285669353324", + "forecastDays": "39", + "forecastTime": "20131013", + "forecastAmount": "14800", + "isEliminated": false, + "reasonForElimination": -1, + "results": { + "profitability": 4105.9458998357, + "resultAmount": 14688.8, + "comissionTotal": 184.8, + "pathRating": 0.62873295587217, + "results": [ + { + "price": null, + "strike": "5", + "time": 1379777460, + "days_to_expiration": "24", + "quantity": -140, + "nodeRating": 0.62873295587217 + } + ] + }, + "responseTime": 4.031760931015 + }, + { + "simulationNum": 74, + "symbol": "GOOG", + "underlyingPrice": 849.27, + "underlyingIV": "0.705519", + "forecastPrice": 903.25476553002, + "forecastIV": "-0.9855754034189413", + "forecastDays": "37", + "forecastTime": "20131011", + "forecastAmount": "5860", + "isEliminated": true, + "reasonForElimination": 8, + "results": null, + "responseTime": 0.20778703689575 + }, + { + "simulationNum": 75, + "symbol": "JCP", + "underlyingPrice": 12.775, + "underlyingIV": "0.676844", + "forecastPrice": 15.149858657564, + "forecastIV": "0.1117280264530377", + "forecastDays": "67", + "forecastTime": "20131110", + "forecastAmount": "22842", + "isEliminated": false, + "reasonForElimination": -1, + "results": { + "profitability": 27108.399775847, + "resultAmount": 22732.5875, + "comissionTotal": 131.5875, + "pathRating": 0.71623490216759, + "results": [ + { + "price": null, + "strike": "13", + "time": 1384631940, + "days_to_expiration": "80", + "quantity": -97, + "nodeRating": 0.71623490216759 + } + ] + }, + "responseTime": 0.039318799972534 + }, + { + "simulationNum": 76, + "symbol": "ATML", + "underlyingPrice": 7.385, + "underlyingIV": "0.00001", + "forecastPrice": 7.2700297925289, + "forecastIV": "0.23132407221400625", + "forecastDays": "14", + "forecastTime": "20130918", + "forecastAmount": "5027", + "isEliminated": true, + "reasonForElimination": 0, + "results": null, + "responseTime": 3.9483160972595 + }, + { + "simulationNum": 77, + "symbol": "VRSN", + "underlyingPrice": 48.385, + "underlyingIV": "0.396445", + "forecastPrice": 51.988525799968, + "forecastIV": "0.3453435387331433", + "forecastDays": "24", + "forecastTime": "20130928", + "forecastAmount": "7043", + "isEliminated": true, + "reasonForElimination": 0, + "results": null, + "responseTime": 4.0710430145264 + }, + { + "simulationNum": 78, + "symbol": "LVS", + "underlyingPrice": 56, + "underlyingIV": "1.092639", + "forecastPrice": 60.023485551875, + "forecastIV": "2.311087422841014", + "forecastDays": "60", + "forecastTime": "20131103", + "forecastAmount": "13430", + "isEliminated": false, + "reasonForElimination": -1, + "results": { + "profitability": 1961.3527156013, + "resultAmount": 12345.1625, + "comissionTotal": 25.1625, + "pathRating": 0.93094022033398, + "results": [ + { + "price": null, + "strike": "56", + "time": 1377892500, + "days_to_expiration": "2", + "quantity": -11, + "nodeRating": 0.93094022033398 + } + ] + }, + "responseTime": 4.0079569816589 + }, + { + "simulationNum": 79, + "symbol": "CB", + "underlyingPrice": 83.42, + "underlyingIV": "0.837066", + "forecastPrice": 87.343286876976, + "forecastIV": "0.3950712968341355", + "forecastDays": "40", + "forecastTime": "20131014", + "forecastAmount": "3467", + "isEliminated": false, + "reasonForElimination": -1, + "results": { + "profitability": 1587.1368394769, + "resultAmount": 3034.825, + "comissionTotal": 14.025, + "pathRating": 0.68823766286032, + "results": [ + { + "price": null, + "strike": "85", + "time": 1379771880, + "days_to_expiration": "24", + "quantity": -2, + "nodeRating": 0.68823766286032 + } + ] + }, + "responseTime": 3.9271230697632 + }, + { + "simulationNum": 80, + "symbol": "JWN", + "underlyingPrice": 56.59, + "underlyingIV": "0.00001", + "forecastPrice": 51.592248015337, + "forecastIV": "0.5661985545334639", + "forecastDays": "47", + "forecastTime": "20131021", + "forecastAmount": "2726", + "isEliminated": true, + "reasonForElimination": 7, + "results": null, + "responseTime": 3.9663770198822 + }, + { + "simulationNum": 81, + "symbol": "YHOO", + "underlyingPrice": 27.055, + "underlyingIV": "0.910483", + "forecastPrice": 21.791479077533, + "forecastIV": "0.6444377700447245", + "forecastDays": "37", + "forecastTime": "20131011", + "forecastAmount": "1434", + "isEliminated": true, + "reasonForElimination": 7, + "results": null, + "responseTime": 0.022291898727417 + }, + { + "simulationNum": 82, + "symbol": "JAZZ", + "underlyingPrice": 85.2, + "underlyingIV": "0.00001", + "forecastPrice": 87.150891302316, + "forecastIV": "-0.6039984043990263", + "forecastDays": "50", + "forecastTime": "20131024", + "forecastAmount": "3214", + "isEliminated": true, + "reasonForElimination": 0, + "results": null, + "responseTime": 3.939658164978 + }, + { + "simulationNum": 83, + "symbol": "SPY", + "underlyingPrice": 163.725, + "underlyingIV": "2.299871", + "forecastPrice": 159.46436052579, + "forecastIV": "1.3765573817546852", + "forecastDays": "72", + "forecastTime": "20131115", + "forecastAmount": "14821", + "isEliminated": true, + "reasonForElimination": 0, + "results": null, + "responseTime": 4.0146307945251 + }, + { + "simulationNum": 84, + "symbol": "ZNGA", + "underlyingPrice": 2.86, + "underlyingIV": "0.850998", + "forecastPrice": 3.0635253165936, + "forecastIV": "-1.0891774054186047", + "forecastDays": "62", + "forecastTime": "20131105", + "forecastAmount": "1345", + "isEliminated": false, + "reasonForElimination": -1, + "results": { + "profitability": 1374.1637647425, + "resultAmount": 1292.4875, + "comissionTotal": 42.4875, + "pathRating": 0.62357382977327, + "results": [ + { + "price": null, + "strike": "3", + "time": 1384631700, + "days_to_expiration": "80", + "quantity": -25, + "nodeRating": 0.62357382977327 + } + ] + }, + "responseTime": 0.014007806777954 + }, + { + "simulationNum": 85, + "symbol": "FB", + "underlyingPrice": 40.515, + "underlyingIV": "1.306589", + "forecastPrice": 46.824318162537, + "forecastIV": "-1.0748474539483617", + "forecastDays": "71", + "forecastTime": "20131114", + "forecastAmount": "4137", + "isEliminated": true, + "reasonForElimination": 0, + "results": null, + "responseTime": 0.027776956558228 + }, + { + "simulationNum": 86, + "symbol": "JCP", + "underlyingPrice": 12.775, + "underlyingIV": "0.676844", + "forecastPrice": 9.811230729918, + "forecastIV": "0.07462026982915576", + "forecastDays": "38", + "forecastTime": "20131012", + "forecastAmount": "2904", + "isEliminated": true, + "reasonForElimination": 7, + "results": null, + "responseTime": 0.027383089065552 + }, + { + "simulationNum": 87, + "symbol": "MXIM", + "underlyingPrice": 27.66, + "underlyingIV": "0.00001", + "forecastPrice": 28.651197788334, + "forecastIV": "2.1762918279405405", + "forecastDays": "56", + "forecastTime": "20131030", + "forecastAmount": "3241", + "isEliminated": true, + "reasonForElimination": 0, + "results": null, + "responseTime": 3.9160158634186 + }, + { + "simulationNum": 88, + "symbol": "FB", + "underlyingPrice": 40.515, + "underlyingIV": "1.306589", + "forecastPrice": 41.413222733402, + "forecastIV": "0.1395024701693393", + "forecastDays": "14", + "forecastTime": "20130918", + "forecastAmount": "6454", + "isEliminated": false, + "reasonForElimination": -1, + "results": { + "profitability": 3057.6318156744, + "resultAmount": 5692.3125, + "comissionTotal": 20.2125, + "pathRating": 0.98413607265344, + "results": [ + { + "price": null, + "strike": "40.5", + "time": 1379098500, + "days_to_expiration": "16", + "quantity": -7, + "nodeRating": 0.98413607265344 + } + ] + }, + "responseTime": 0.064554929733276 + }, + { + "simulationNum": 89, + "symbol": "GRPN", + "underlyingPrice": 10.035, + "underlyingIV": "3.767278", + "forecastPrice": 9.1358509692409, + "forecastIV": "0.042936425847793", + "forecastDays": "72", + "forecastTime": "20131115", + "forecastAmount": "8107", + "isEliminated": true, + "reasonForElimination": 0, + "results": null, + "responseTime": 0.0083680152893066 + }, + { + "simulationNum": 90, + "symbol": "INTC", + "underlyingPrice": 22.275, + "underlyingIV": "0.00001", + "forecastPrice": 23.342308675634, + "forecastIV": "-0.6646516820091103", + "forecastDays": "55", + "forecastTime": "20131029", + "forecastAmount": "32205", + "isEliminated": true, + "reasonForElimination": 0, + "results": null, + "responseTime": 3.9807431697845 + }, + { + "simulationNum": 91, + "symbol": "HST", + "underlyingPrice": 17.12, + "underlyingIV": "0.242021", + "forecastPrice": 16.961782708576, + "forecastIV": "-0.5237089412408089", + "forecastDays": "49", + "forecastTime": "20131023", + "forecastAmount": "3611", + "isEliminated": true, + "reasonForElimination": 7, + "results": null, + "responseTime": 4.0207300186157 + }, + { + "simulationNum": 92, + "symbol": "ACAD", + "underlyingPrice": 20.05, + "underlyingIV": "0.00001", + "forecastPrice": 18.121106159417, + "forecastIV": "0.43249688104771544", + "forecastDays": "35", + "forecastTime": "20131009", + "forecastAmount": "4116", + "isEliminated": true, + "reasonForElimination": 7, + "results": null, + "responseTime": 3.9551689624786 + }, + { + "simulationNum": 93, + "symbol": "HPQ", + "underlyingPrice": 22.62, + "underlyingIV": "1.592611", + "forecastPrice": 21.602136581774, + "forecastIV": "1.1167140020078", + "forecastDays": "71", + "forecastTime": "20131114", + "forecastAmount": "4116", + "isEliminated": true, + "reasonForElimination": 0, + "results": null, + "responseTime": 3.9768650531769 + }, + { + "simulationNum": 94, + "symbol": "BEN", + "underlyingPrice": 45.265, + "underlyingIV": "1.069404", + "forecastPrice": 45.143682638403, + "forecastIV": "-0.09304621170360688", + "forecastDays": "8", + "forecastTime": "20130912", + "forecastAmount": "4640", + "isEliminated": true, + "reasonForElimination": 7, + "results": null, + "responseTime": 3.9585158824921 + }, + { + "simulationNum": 95, + "symbol": "FSLR", + "underlyingPrice": 36.875, + "underlyingIV": "0.537211", + "forecastPrice": 40.161636029817, + "forecastIV": "-0.19879465653218326", + "forecastDays": "28", + "forecastTime": "20131002", + "forecastAmount": "2306", + "isEliminated": false, + "reasonForElimination": -1, + "results": { + "profitability": 682.51333167151, + "resultAmount": 2190.2625, + "comissionTotal": 15.2625, + "pathRating": 0.90948361810435, + "results": [ + { + "price": null, + "strike": "37", + "time": 1380311700, + "days_to_expiration": "30", + "quantity": -3, + "nodeRating": 0.90948361810435 + } + ] + }, + "responseTime": 4.0376579761505 + }, + { + "simulationNum": 96, + "symbol": "OPTR", + "underlyingPrice": 12.525, + "underlyingIV": "0.574072", + "forecastPrice": 11.461418541899, + "forecastIV": "1.3751353396276105", + "forecastDays": "35", + "forecastTime": "20131009", + "forecastAmount": "13167", + "isEliminated": true, + "reasonForElimination": 7, + "results": null, + "responseTime": 3.9547390937805 + }, + { + "simulationNum": 97, + "symbol": "DXJ", + "underlyingPrice": 44.51, + "underlyingIV": "0.00001", + "forecastPrice": 50.569779687196, + "forecastIV": "-0.10003916859772985", + "forecastDays": "53", + "forecastTime": "20131027", + "forecastAmount": "16435", + "isEliminated": true, + "reasonForElimination": 0, + "results": null, + "responseTime": 3.8569738864899 + }, + { + "simulationNum": 98, + "symbol": "EWJ", + "underlyingPrice": 11.085, + "underlyingIV": "0.27545", + "forecastPrice": 10.95260248423, + "forecastIV": "0.5338758368238052", + "forecastDays": "31", + "forecastTime": "20131005", + "forecastAmount": "1650", + "isEliminated": true, + "reasonForElimination": 7, + "results": null, + "responseTime": 0.015342950820923 + }, + { + "simulationNum": 99, + "symbol": "GTAT", + "underlyingPrice": 6.385, + "underlyingIV": "0.623987", + "forecastPrice": 6.0245961151749, + "forecastIV": "-0.9704522750076419", + "forecastDays": "49", + "forecastTime": "20131023", + "forecastAmount": "1445", + "isEliminated": true, + "reasonForElimination": 7, + "results": null, + "responseTime": 3.9698729515076 + }, + { + "simulationNum": 100, + "symbol": "BIDU", + "underlyingPrice": 138.655, + "underlyingIV": "0.498208", + "forecastPrice": 137.7072067857, + "forecastIV": "0.012470372287573292", + "forecastDays": "3", + "forecastTime": "20130907", + "forecastAmount": "2160", + "isEliminated": true, + "reasonForElimination": 7, + "results": null, + "responseTime": 3.9631378650665 + }, + { + "simulationNum": 101, + "symbol": "", + "underlyingPrice": 0, + "underlyingIV": "null", + "forecastPrice": 0, + "forecastIV": "null", + "forecastDays": "null", + "forecastTime": "20130904", + "forecastAmount": "null", + "isEliminated": true, + "reasonForElimination": 2, + "results": "null", + "responseTime": 3.9984579086304 + } +] \ No newline at end of file diff --git a/test2.csv b/test2.csv new file mode 100644 index 0000000..0bcce6e --- /dev/null +++ b/test2.csv @@ -0,0 +1,4 @@ +simulationNum,symbol,underlyingPrice,underlyingIV,forecastPrice,forecastIV,forecastDays,forecastTime,forecastAmount,isEliminated,reasonForElimination,responseTime,profitability,resultAmount,comissionTotal,pathRating,price,strike,time,days_to_expiration,quantity,nodeRating,price,strike,time,days_to_expiration,quantity,nodeRating, +1,BRCD,7.515,0.00001,7.4516628808745,0.7348473568809507,31,20131005,7175,1,0,novalue,3.853453874588, +2,AA,7.935,0.00001,9.5423367476894,0.06476055389582175,77,20131120,1390,1,0,novalue,0.0065140724182129, +16,EZU,35.5,0.469201,35.773053463701,0.23221417962010502,16,20130920,2458,,-1,4.2060079574585,535.47702780641,2145.2625,15.2625,0.51735265796424,novalue,35,1379736000,24,-3,0.51735265796424,novalue,35,1379736000,24,-3,0.51735265796424, \ No newline at end of file From ba7634d64ca4072426166abc4e5ac69685d1c1dd Mon Sep 17 00:00:00 2001 From: Aditya Relangi Date: Sun, 22 Sep 2013 00:14:51 -0500 Subject: [PATCH 2/3] added index. error notification changed --- index.html | 2 ++ json2csv.class.php | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 index.html diff --git a/index.html b/index.html new file mode 100644 index 0000000..b26573f --- /dev/null +++ b/index.html @@ -0,0 +1,2 @@ +JSON 2 CSV + Click here to convert your json to csv \ No newline at end of file diff --git a/json2csv.class.php b/json2csv.class.php index c0d1d32..635fd66 100644 --- a/json2csv.class.php +++ b/json2csv.class.php @@ -63,7 +63,7 @@ private function prependColumnNames(){ function browserDL($CSVname){ if($this->isItNested() || !is_array($this->dataArray)){ - echo "

JSON is either invalid or has nested elements.

"; + echo "

JSON is either invalid or you encountered an edge case I missed. Please let me know at arelangi@gmail.com

"; } else{ header("Content-Type: text/csv; charset=utf-8"); @@ -88,7 +88,7 @@ function JSONfromFile($file){ function save2CSV($file){ if($this->isItNested() || !is_array($this->dataArray)){ - echo "JSON is either invalid or has nested elements."; + echo "

JSON is either invalid or you encountered an edge case I missed. Please let me know at arelangi@gmail.com

"; } else{ $fileIO = fopen($file, 'w+'); From 9189d7a870b1572f991bd397cf98f2eb29b52bb1 Mon Sep 17 00:00:00 2001 From: Aditya Relangi Date: Tue, 7 Jan 2014 13:51:25 -0600 Subject: [PATCH 3/3] changes for memory --- json2csv.class.php | 21 ++++++++++++++------- json2csv.php | 5 +++++ test.csv | 4 ---- test.php | 34 ++++++++++++++++++++++++++++++++++ test2.csv | 4 ---- 5 files changed, 53 insertions(+), 15 deletions(-) delete mode 100644 test.csv create mode 100644 test.php delete mode 100644 test2.csv diff --git a/json2csv.class.php b/json2csv.class.php index 635fd66..5a03f97 100644 --- a/json2csv.class.php +++ b/json2csv.class.php @@ -2,19 +2,21 @@ require_once('arrayToCSV.php'); +ini_set('memory_limit', '-1'); + + class JSON2CSVutil{ public $dataArray; public $isNested = FALSE; function readJSON($JSONdata){ - $this->dataArray = json_decode($JSONdata,1); $this->prependColumnNames(); return $this->dataArray; } - private function isNested($array){ + function isNested($array){ foreach($array as $data){ if(is_array($data)){ return TRUE; @@ -24,8 +26,7 @@ private function isNested($array){ } - private function getAllKeys($array) - { + function getAllKeys($array){ $result = array(); $children = array(); foreach($array as $sub=>$value) { @@ -43,7 +44,7 @@ private function getAllKeys($array) return $result; } - private function prependColumnNames(){ + function prependColumnNames(){ $keys = array(); foreach ($this->dataArray as $key => $value) { @@ -79,7 +80,9 @@ function browserDL($CSVname){ function JSONfromFile($file){ - $this->dataArray = json_decode(file_get_contents($file),1); + + + $this->dataArray = json_decode(file_get_contents($file),TRUE); $this->prependColumnNames(); return $this->dataArray; } @@ -91,6 +94,10 @@ function save2CSV($file){ echo "

JSON is either invalid or you encountered an edge case I missed. Please let me know at arelangi@gmail.com

"; } else{ + + echo 'orey '.$file; + ob_flush(); + $fileIO = fopen($file, 'w+'); foreach ($this->dataArray as $fields) { fputcsv($fileIO, $fields); @@ -99,7 +106,7 @@ function save2CSV($file){ } } - private function isItNested(){ + function isItNested(){ foreach($this->dataArray as $data){ if(is_array($data)){ $isNested = TRUE; diff --git a/json2csv.php b/json2csv.php index a3dbf0c..1d91236 100644 --- a/json2csv.php +++ b/json2csv.php @@ -1,5 +1,7 @@ savejsonFile2csv($arguments["file"], $filepath); } elseif(($_FILES["file"]["type"]) != NULL){ + $JSON2CSV->JSONfromFile($_FILES["file"]["tmp_name"]); $JSON2CSV->browserDL(str_replace("json", "csv", $_FILES["file"]["name"])); } elseif($_POST['json'] != NULL){ + $JSON2CSV->readJSON($_POST['json']); $JSON2CSV->browserDL("JSON.CSV"); } diff --git a/test.csv b/test.csv deleted file mode 100644 index b2b20ad..0000000 --- a/test.csv +++ /dev/null @@ -1,4 +0,0 @@ -simulationNum,symbol,underlyingPrice,underlyingIV,forecastPrice,forecastIV,forecastDays,forecastTime,forecastAmount,isEliminated,reasonForElimination,responseTime,profitability,resultAmount,comissionTotal,pathRating,price,strike,time,days_to_expiration,quantity,nodeRating -100,BIDU,138.655,0.498208,137.7072068,0.012470372,3,20130907,2160,1,7,,3.963137865,,,,,,,,, -99,GTAT,6.385,0.623987,6.024596115,-0.970452275,49,20131023,1445,1,7,,3.969872952,,,,,,,,, -95,FSLR,36.875,0.537211,40.16163603,-0.198794657,28,20131002,2306,,-1,4.037657976,682.5133317,2190.2625,15.2625,0.909483618,,37,1380311700,30,-3,0.909483618 diff --git a/test.php b/test.php new file mode 100644 index 0000000..cb638db --- /dev/null +++ b/test.php @@ -0,0 +1,34 @@ +dataArray = json_decode(file_get_contents($file),1); + $JSON2CSV->prependColumnNames(); + //return $this->dataArray; + + $CSVname ="babji.csv"; + + if($JSON2CSV->isItNested() || !is_array($JSON2CSV->dataArray)){ + echo "

JSON is either invalid or you encountered an edge case I missed. Please let me know at arelangi@gmail.com

"; + } + else{ + header("Content-Type: text/csv; charset=utf-8"); + header("Content-Disposition: attachment; filename=$CSVname"); + + $output = fopen('php://output', 'w'); + + foreach ($JSON2CSV->dataArray as $fields) { + fwrite($output,arrayToCSV($fields)."\n"); + } + } + +?> \ No newline at end of file diff --git a/test2.csv b/test2.csv deleted file mode 100644 index 0bcce6e..0000000 --- a/test2.csv +++ /dev/null @@ -1,4 +0,0 @@ -simulationNum,symbol,underlyingPrice,underlyingIV,forecastPrice,forecastIV,forecastDays,forecastTime,forecastAmount,isEliminated,reasonForElimination,responseTime,profitability,resultAmount,comissionTotal,pathRating,price,strike,time,days_to_expiration,quantity,nodeRating,price,strike,time,days_to_expiration,quantity,nodeRating, -1,BRCD,7.515,0.00001,7.4516628808745,0.7348473568809507,31,20131005,7175,1,0,novalue,3.853453874588, -2,AA,7.935,0.00001,9.5423367476894,0.06476055389582175,77,20131120,1390,1,0,novalue,0.0065140724182129, -16,EZU,35.5,0.469201,35.773053463701,0.23221417962010502,16,20130920,2458,,-1,4.2060079574585,535.47702780641,2145.2625,15.2625,0.51735265796424,novalue,35,1379736000,24,-3,0.51735265796424,novalue,35,1379736000,24,-3,0.51735265796424, \ No newline at end of file