{"size": 1989, "ext": "js", "max_stars_repo_path": "public/js/modules/stocks/stocks-create-backtest/stocks-create-backtest.js", "max_stars_repo_name": "DynamicWebVision/FinancialTrading", "max_stars_repo_stars_event_min_datetime": "2020-03-29T00:31:59.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-18T23:34:08.000Z", "max_issues_repo_path": "public/js/modules/stocks/stocks-create-backtest/stocks-create-backtest.js", "max_issues_repo_name": "DynamicWebVision/FinancialTrading", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "public/js/modules/stocks/stocks-create-backtest/stocks-create-backtest.js", "max_forks_repo_name": "DynamicWebVision/FinancialTrading", "max_forks_repo_forks_event_min_datetime": "2020-03-27T11:14:25.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-18T23:34:19.000Z"}
{"max_stars_count": 3, "max_issues_count": null, "max_forks_count": 3, "avg_line_length": 34.2931034483, "max_line_length": 116, "alphanum_fraction": 0.5077928607}
(function() {
    'use strict';

    angular
        .module('app')
        .controller('StocksCreateBacktest', StocksCreateBacktest);

    function StocksCreateBacktest(StockTechnicalCheck, $http, SweetAlert) {
        var vm = this;
        vm.data = {};
        vm.data.technicalCheckVariables = [];

        vm.stockTechnicalCheck = StockTechnicalCheck;
        vm.stocks = [];

        vm.createBacktest = createBacktest;
        vm.getTcVariables = getTcVariables;

        StockTechnicalCheck.loadAllTechnicalChecks();

        function getTcVariables() {
            StockTechnicalCheck.getTechnicalCheckVariables(vm.data.technical_check).then(function(response) {
                vm.data.technicalCheckVariables = response.data;
            });
        }

        function createBacktest() {
            vm.data.submit = true;
            if (vm.create_form.$valid) {
                vm.data.processing = true;

                $http.post('stocks/back_test', vm.data).success(function(response){

                    vm.data.processing = false;
                    SweetAlert.swal({
                            title: "New Back Test Group Successfully Created with id #"+response.back_test_group_id,
                            text: "Click Clear Form to Clear Form or Cancel to Use Variables for Another Group",
                            type: "success",
                            showCancelButton: true,
                            confirmButtonColor: "#488214",
                            confirmButtonText: "Clear Form",
                            closeOnConfirm: true},
                        function(){
                            //setNewBackTestObject();
                        });
                });
            }
        }

        // function loadStocks() {
        //     $http.get('/stocks/rates_profile').then(function(response) {
        //         vm.stocks = response.data;
        //     });
        // }
        //
        // loadStocks();
    }
})();