<?php
error_reporting(E_ALL);
include_once("../classes/database.class.php");
include_once("../classes/neural.class.php");
include_once("../classes/node.class.php");
include_once("../classes/oanda.php");
// Setting up some basic classes
$db = new database();
// Grabbing some basic data
$action = filter_input(INPUT_POST, 'action');
$currency_pair = filter_input(INPUT_POST, 'interest1');
$start_date = filter_input(INPUT_POST, 'interest2');
$time_frame = filter_input(INPUT_POST, 'interest3');
$end_date = filter_input(INPUT_POST, 'interest4');
$unitNumber = filter_input(INPUT_POST, 'interest5');


$output = filter_input(INPUT_POST, 'output');
$inputNodes = array($interest1, $interest2, $interest3);
$outputNode = $output;
// Lets get some switch - casing going
switch($action){

	case "correct":
		neuralNetwork::correct(true);
		break;
	case "incorrect":
		neuralNetwork::incorrect(false);
		break;
	case "calculate":
		$neural = new neuralNetwork($currency_pair, $start_date, $time_frame, $end_date, $unitNumber);
		$neural->calculate($inputNodes);
		break;
	case "delete":
		$deleter = new oandaAPI(); 
		echo $deleter->closeTrades("734010");
		break;
	case "validate":
		break;
	case "select_algo":
		$algo_id = filter_id(INPUT_POST, 'algo_id');
		$neural = new neuralNetwork($currency_pair, $start_date, $time_frame, $end_date, $unitNumber);
		$neural->setAlgo($algo_id);
		$nueral->calculate($inputNodes);
		break;
	case "gen_algo":
		$neural = new neuralNetwork($currency_pair, $start_date, $time_frame, $end_date, $unitNumber);
		$neural->genAlgo($algo_id);
		break;
	case "deleteSingle":
		$deleter = new oandaAPI();
		$id = filter_input(INPUT_POST, 'id');
		echo $deleter->closeIndividualTrade("asdsa", $id);
		break;
	case "modifyRecord":
		echo "filter";
		$id = filter_input(INPUT_POST, 'id');
		$stop_loss = filter_input(INPUT_POST, 'stop_loss');
		$take_profit = filter_input(INPUT_POST, 'take_profit');
		$modifer = new oandaAPI();
		$modifer->modifyIndividualRecord("734010", $id, $stop_loss, $take_profit);

}
?>