Ejemplo n.º 1
0
function getSMACombined($company, $from = "1900-01-01 00:00:00", $to = null, $dataorg = "json", $periodShort = 20, $periodMedium = 50, $periodLong = 120, $enSignals = false, $host, $db, $user, $pass)
{
    $smaShort = getSMA($company, $from, $to, $dataorg, $periodShort, $enSignals, false, $host, $db, $user, $pass);
    $smaMedium = getSMA($company, $from, $to, $dataorg, $periodMedium, $enSignals, false, $host, $db, $user, $pass);
    $smaLong = getSMA($company, $from, $to, $dataorg, $periodLong, $enSignals, false, $host, $db, $user, $pass);
    $real = getSMA_sub_real($company, $from, $to, $dataorg, $periodShort, $enSignals, $host, $db, $user, $pass);
    if ($smaShort == 0 || $smaMedium == 0 || $smaLong == 0 || $real == 0) {
        return 0;
    }
    $allData = [];
    if (strcasecmp($enSignals, "latest") == 0) {
        //return only the latest signal
        // [timestamp,trade signal]
        $lastSignal = codesword_smaBuySellSignalCombinedLatests($real, $smaShort, $smaMedium, $smaLong, $dataorg);
        return $lastSignal;
    } elseif ($enSignals) {
        $allData = codesword_smaBuySellSignalCombined($real, $smaShort, $smaMedium, $smaLong, $dataorg);
        echo json_encode($allData);
    } else {
        $allData[0] = codesword_smaConsolidate($real, $smaShort, $smaMedium, $smaLong);
        $allData[1] = 0;
        echo json_encode($allData);
    }
}
Ejemplo n.º 2
0
 case 'macd':
     getMACD($company, $fromDate, $toDate, $dataorg, $mysql_host, $mysql_database, $mysql_user, $mysql_password);
     break;
 case 'rsi':
     getRSI($company, $fromDate, $toDate, $dataorg, $mysql_host, $mysql_database, $mysql_user, $mysql_password);
     break;
 case 'stoch':
     getStochasticOscillator($company, $fromDate, $toDate, $dataorg, $mysql_host, $mysql_database, $mysql_user, $mysql_password);
     break;
 case 'obv':
     getOnBalanceVolume($company, $fromDate, $toDate, $dataorg, $mysql_host, $mysql_database, $mysql_user, $mysql_password);
     break;
 case 'sma':
     if (isset($_GET['period'])) {
         $period = $_GET['period'];
         getSMA($company, $fromDate, $toDate, $dataorg, $period, $ensig, true, $mysql_host, $mysql_database, $mysql_user, $mysql_password);
     } else {
         echo "Error: No period selected";
     }
     break;
 case 'smaentryatrstop':
     if (isset($_GET['period']) || $isCmd) {
         $period = isset($_GET['period']) ? $_GET['period'] : $cmdPeriod;
         // $period = $_GET['period'];
         getSMAentryATRstop($company, $fromDate, $toDate, $dataorg, $period, $ensig, true, $enprofit, $mysql_host, $mysql_database, $mysql_user, $mysql_password);
     } else {
         echo "Error: No period selected";
     }
     break;
 case 'ema':
     if (isset($_GET['period'])) {