describe ai_trades; * +-----------------+--------------------------------------------------+------+-----+---------+----------------+ * | Field | Type | Null | Key | Default | Extra | * +-----------------+--------------------------------------------------+------+-----+---------+----------------+ * | id | int(11) | NO | PRI | NULL | auto_increment | * | trade_id | varchar(100) | NO | UNI | NULL | | * | symbol | varchar(20) | NO | | NULL | | * | creation | datetime | YES | | NULL | | * | entry_date | datetime | YES | | NULL | | * | exit_date | datetime | YES | | NULL | | * | shares | int(11) | NO | | 1 | | * | entry_price | double | NO | | NULL | | * | exit_price | double | YES | | NULL | | * | stop_price | double | YES | | NULL | | * | target_price | double | YES | | NULL | | * | time_stop | datetime | YES | | NULL | | * | exit_reason | enum('open','time_stop','stop_hit','target_hit') | NO | | open | | * | profit | double | NO | | 0 | | * | max_profit | double | NO | | 0 | | * | min_profit | double | NO | | 0 | | * | max_profit_time | datetime | YES | | NULL | | * | min_profit_time | datetime | YES | | NULL | | * | is_long | tinyint(4) | NO | | 1 | | * | winner | tinyint(4) | NO | | 0 | | * | nonexit_profit | double | YES | | NULL | | * | spy_change | double | YES | | NULL | | * | strategy_id | int(11) | YES | | NULL | | * +-----------------+--------------------------------------------------+------+-----+---------+----------------+ * 21 rows in set (0.00 sec) * */ $segment = "main"; if ($_REQUEST['segment'] == "test") { $segment = "test"; } else if ($_REQUEST['segment'] == "aws1") { $segment = "aws1"; } $format = "normal"; if ($_REQUEST['format'] == "profit") { $format = "profit"; } $sql = "SELECT COUNT(*) AS trade_count, SUM(profit) AS normal_profit, SUM(nonexit_profit) AS nonexit_profit, MAX(spy_change) AS spy_change, MAX(DATE(entry_date)) AS last_date FROM ai_trades WHERE DATE(entry_date) = (SELECT MAX(DATE(entry_date)) FROM ai_trades) AND category = '$segment'"; if ($format == "profit") { $sql = "SELECT COUNT(*) AS trade_count, SUM(profit) AS normal_profit, SUM(nonexit_profit) AS nonexit_profit, MAX(spy_change) AS spy_change, MAX(DATE(entry_date)) AS last_date FROM ai_trades WHERE DATE(entry_date) = DATE(NOW()) AND category = '$segment'"; } $result = mysql_query($sql); $table_class = "ai_winning"; $ai_profit_class = "ai_positive"; $spy_class = "spy_positive"; if ($result) { $row = mysql_fetch_assoc($result); $trade_count = $row['trade_count']; $normal_profit = $row['normal_profit']; # risk off profit $nonexit_profit = $row['nonexit_profit']; # risk on profit $best_profit = number_format($normal_profit, 2); $spy_change = number_format($row['spy_change'], 2); $last_date = $row['last_date']; $raw_profit = $normal_profit; if ($nonexit_profit > $normal_profit) { $best_profit = number_format($nonexit_profit, 2); $raw_profit = $nonexit_profit; } if ($best_profit < 0) { $ai_profit_class = "ai_negative"; } if ($best_profit < $spy_change) { $table_class = "ai_losing"; } if ($spy_change < 0) { $spy_class = "spy_negative"; } if ($format == "profit") { $profit_class = "overlay-profit"; if ($raw_profit < 0) { $profit_class = "overlay-loss"; } if ($raw_profit > 10) { $display_profit = "+\$$best_profit"; } else if ($best_profit < -10) { $display_profit = "-\$" . number_format(abs($best_profit), 2); } else if ($best_profit >= 0) { $display_profit = "+ \$$best_profit"; } else { $display_profit = "- \$" . number_format(abs($best_profit), 2); } ?>
AI Trades
AI Profit$
SPY Change$
Trade Date
From cache: $from_cache

"; ?>