예제 #1
0
        public override bool Initialize(List <IProcessorInput> inputs, string parameters, ILogger logger)
        {
            this.logger = logger;
            ParametersParser parser = CreateParser(parameters);

            call = parser.GetInt("Call");
            put  = parser.GetInt("Put");
            if (call < 0 || call >= inputs.Count)
            {
                return(false);
            }
            if (put < 0 || put >= inputs.Count)
            {
                return(false);
            }
            strike   = parser.GetDouble("Strike");
            type     = parser.GetInt("Type");
            inp_name = parser.GetString("input_name");
            //inp_name_2 = parser.GetString("input_name_2");

            /* if(inp_name_2 == inp_name)
             * {
             *   inp_name_2 += "_n";
             * }*/
            this.inputs = inputs;
            SyntheticFutureInput.AddKey(inp_name);
            //SyntheticFutureInput.AddKey(inp_name_2);
            return(true);
        }
예제 #2
0
        public override bool Initialize(List <IProcessorInput> inputs, string parameters, ILogger logger)
        {
            this.logger = logger;
            ParametersParser parser = CreateParser(parameters);

            //Strike = parser.GetInt("Strike");
            Opt = parser.GetInt("Opt");
            if (Opt < 0 || Opt >= inputs.Count)
            {
                return(false);
            }
            int period = parser.GetInt("period");

            spread_col   = new double[period];
            spread_count = 0;
            if (parser.GetInt("SpreadFilt") == 1)
            {
                filt_spread = true;
            }
            else
            {
                filt_spread = false;
            }
            midle_opt_price = 0;
            koef            = parser.GetDouble("SpreadKoef");
            time_prev_spred = new DateTime();
            this.inputs     = inputs;
            return(true);
        }
예제 #3
0
        public override bool Initialize(List <IProcessorInput> inputs, string parameters, ILogger logger)
        {
            this.logger = logger;
            ParametersParser parser = CreateParser(parameters);

            Strike = parser.GetInt("Strike");
            Fut    = parser.GetInt("Future");
            Put    = parser.GetInt("Put");
            Call   = parser.GetInt("Call");
            if (Call < 0 || Call >= inputs.Count)
            {
                return(false);
            }
            if (Fut < 0 || Fut >= inputs.Count)
            {
                return(false);
            }
            if (Put < 0 || Put >= inputs.Count)
            {
                return(false);
            }
            int period = parser.GetInt("period");

            x = new double[period];
            if (parser.GetInt("SpreadFilt") == 1)
            {
                filt_spread = true;
            }
            else
            {
                filt_spread = false;
            }
            ready                = false;
            spread_col_call      = new double[parser.GetInt("MidPricePutPeriod")];
            koef                 = parser.GetDouble("SpreadKoef");
            spread_col_put       = new double[parser.GetInt("MidPriceCallPeriod")];
            spread_count_call    = 0;
            spread_count_put     = 0;
            midle_opt_price_call = 0;
            midle_opt_price_put  = 0;
            pos                  = 0;
            sumx                 = 0;
            time_prev_gap        = new DateTime();
            time_prev_spred_put  = new DateTime();
            time_prev_spred_call = new DateTime();
            this.inputs          = inputs;
            return(true);
        }
예제 #4
0
        public override bool Initialize(List <IProcessorInput> inputs, string parameters, ILogger logger)
        {
            ClosePositionStopTrade += Stop;
            if (Models.InputItemInteractivBrokerModel.IB == null)
            {
                return(false);
            }
            this.logger = logger;
            ParametersParser parser = CreateParser(parameters);

            zigzagid      = parser.GetInt("ZigZag_ID");
            zigzagidsmall = parser.GetInt("ZigZagSmall_ID");
            if (zigzagid < 0 || zigzagid > Model.Project.Outputs.Count)
            {
                return(false);
            }
            if (zigzagidsmall < 0 || zigzagidsmall > Model.Project.Outputs.Count)
            {
                return(false);
            }
            gappos = parser.GetInt("Gap");
            if (gappos < 0 || gappos > Model.Project.Outputs.Count)
            {
                return(false);
            }
            //Gap = Model.Project.Proccesors[gappos];
            //Gap.ProcessorAction += PositionHandler;
            //ZigZag = Model.Project.Proccesors[zigzagid];
            //ZigZag.ProcessorAction += EventHandler;
            MinValueSmall = new List <ProbaStruct>();
            MaxValueSmall = new List <ProbaStruct>();
            MinValueBig   = new List <ProbaStruct>();
            MaxValueBig   = new List <ProbaStruct>();
            PositionShort = new Position();
            PositionLong  = new Position();
            name          = parser.GetString("Name");
            ratio         = parser.GetDouble("Ratio");
            tradeTerminal = new ModelsAT.BrokerMT(parser.GetInt("tradeTerminalID"));
            tradeTerminal.setBrokerParam("Name", parser.GetString("ServerName"));
            tradeTerminal.SetServer();
            Size = parser.GetInt("Size");
            if (parser.GetInt("IsReal") == 1)
            {
                tradeTerminal.isReal = true;
            }
            if (parser.GetInt("Logg") == 1)
            {
                LoggNeeded = true;
            }
            else
            {
                LoggNeeded = false;
            }
            //if (divergence > size || divergence == 0) return false;
            openlongcloseshort          = false;
            openshortcloselong          = false;
            longlock                    = false;
            shortlock                   = false;
            profit_to_close             = parser.GetInt("TakeProfit") * Math.Pow(10, -Model.Project.Outputs[gappos].Digits);
            lose_to_close               = parser.GetInt("StopLoss") * Math.Pow(10, -Model.Project.Outputs[gappos].Digits);
            convergenceshort            = false;
            convergencelong             = false;
            divergenceshort             = false;
            divergencelong              = false;
            lastvalue                   = LastZigZagValue.NONE;
            all_profit                  = 0;
            openpos                     = OpenPosition.NONE;
            ConvergenMin                = new ProbaStruct();
            ConvergenMax                = new ProbaStruct();
            Model.OutputsInitializeEnd += InitializeHandler;
            Model.LoadSimulation       += LoadSec;
            return(true);
        }
예제 #5
0
        public override bool Initialize(List <IProcessorInput> inputs, string parameters, ILogger logger)
        {
            ClosePositionStopTrade += Stop;
            if (Models.InputItemInteractivBrokerModel.IB == null)
            {
                return(false);
            }
            this.logger = logger;
            ParametersParser parser = CreateParser(parameters);

            zigzagid_1 = parser.GetInt("ZigZag_ID1");
            if (zigzagid_1 < 0 || zigzagid_1 > Model.Project.Outputs.Count)
            {
                return(false);
            }
            zigzagid_2 = parser.GetInt("ZigZag_ID2");
            if (zigzagid_2 < 0 || zigzagid_2 > Model.Project.Outputs.Count)
            {
                return(false);
            }
            zigzagid_2_2 = parser.GetInt("ZigZag_ID2_2");
            gappos       = parser.GetInt("Gap");
            if (gappos < 0 || gappos > Model.Project.Outputs.Count)
            {
                return(false);
            }
            int t_t = parser.GetInt("type");

            switch (t_t)
            {
            case (0):
                trader_type = TradeType.STANDART;
                break;

            case (1):
                trader_type = TradeType.IN_OUT;
                break;

            default:
                trader_type = TradeType.ONE_IN_TWO_OUT;
                break;
            }
            //Gap = Model.Project.Proccesors[gappos];
            //Gap.ProcessorAction += PositionHandler;
            //ZigZag = Model.Project.Proccesors[zigzagid];
            //ZigZag.ProcessorAction += EventHandler;
            divergenceOpen    = parser.GetInt("DivergenceOpen");
            divergenceClose   = parser.GetInt("DivergenceClose");
            convergen_counter = parser.GetInt("Convergence");
            if (divergenceOpen < 0 || divergenceClose < 0 || convergen_counter < 0)
            {
                return(false);
            }
            MinValueOpen_1    = new List <ProbaStruct>();
            MaxValueOpen_1    = new List <ProbaStruct>();
            MinValueClose_1   = new List <ProbaStruct>();
            MaxValueClose_1   = new List <ProbaStruct>();
            MinValueOpen_2    = new List <ProbaStruct>();
            MaxValueOpen_2    = new List <ProbaStruct>();
            MinValueClose_2   = new List <ProbaStruct>();
            MaxValueClose_2   = new List <ProbaStruct>();
            MinValueOpen_2_2  = new List <ProbaStruct>();
            MaxValueOpen_2_2  = new List <ProbaStruct>();
            MinValueClose_2_2 = new List <ProbaStruct>();
            MaxValueClose_2_2 = new List <ProbaStruct>();
            PositionShort     = new List <Position>();
            PositionLong      = new List <Position>();
            name            = parser.GetString("Name");
            ratio           = parser.GetDouble("Ratio");
            profit_to_close = parser.GetInt("TakeProfit") * Math.Pow(10, -Model.Project.Outputs[gappos].Digits);
            lose_to_close   = parser.GetInt("StopLoss") * Math.Pow(10, -Model.Project.Outputs[gappos].Digits);
            ratio_exp       = parser.GetDouble("Ratio_O");
            tradeTerminal   = new ModelsAT.BrokerMT(parser.GetInt("tradeTerminalID"));
            tradeTerminal.setBrokerParam("Name", parser.GetString("ServerName"));
            tradeTerminal.SetServer();
            if (parser.GetInt("IsReal") == 1)
            {
                tradeTerminal.isReal = true;
            }
            else
            {
                tradeTerminal.isReal = false;
            }
            if (parser.GetInt("Logg") == 1)
            {
                LoggNeeded = true;
            }
            else
            {
                LoggNeeded = false;
            }
            if (parser.GetInt("Expand") == 1)
            {
                can_expand = true;
            }
            else
            {
                can_expand = false;
            }
            divergence_max_open   = 0;
            divergence_min_open   = 0;
            divergence_max_close  = 0;
            divergence_min_close  = 0;
            openlong              = false;
            openshort             = false;
            closelong             = false;
            expand_position_short = false;
            expand_position_long  = false;
            closeshort            = false;
            lastvalue             = LastZigZagValue.NONE;
            all_profit            = 0;
            openpos       = OpenPosition.NONE;
            convergen_min = 0;
            convergen_max = 0;
            ConvergenMin  = new ProbaStruct();
            ConvergenMax  = new ProbaStruct();
            last_pos      = new LastPosition();
            Model.OutputsInitializeEnd += InitializeHandler;
            Model.LoadSimulation       += LoadSec;
            return(true);
        }