Esempio n. 1
0
        public override double Process(DateTime time)
        {
            bool flag = true;
            //double mean;
            double spread, spread_midle, spread_howmuch;

            if (filt_spread)
            {
                if (GapWorker.spread_worker(/*time, ref time_prev_spred, */ ref spread_col, ref spread_count, koef, inputs[Opt], out spread, out spread_midle, out spread_howmuch))
                {
                    flag = false;
                }
            }
            if (flag)
            {
                midle_opt_price = (inputs[Opt].Ask + inputs[Opt].Bid) / 2;
            }
            if (midle_opt_price > inputs[Opt].Ask || midle_opt_price < inputs[Opt].Bid)
            {
                midle_opt_price = (inputs[Opt].Ask + inputs[Opt].Bid) / 2;
                Array.Clear(spread_col, 0, spread_col.Length);
            }
            //ProcessorAction?.Invoke(new object[] { flag, midle_opt_price });
            return(midle_opt_price);
        }
Esempio n. 2
0
        public override double Process(DateTime time)
        {
            bool   flag = true;
            double mean;
            double spread, spread_midle, spread_howmuch;

            if (filt_spread)
            {
                if (GapWorker.spread_worker(ref spread_col_call, ref spread_count_call, koef, inputs[Call], out spread, out spread_midle, out spread_howmuch))
                {
                    //logger.LogEvent(time, "Спред опционна Call " + spread + " вырос более чем в " + spread_howmuch + " раза от среднего спреда " + spread_midle);
                    flag = false;
                }
                if (GapWorker.spread_worker(ref spread_col_put, ref spread_count_put, koef, inputs[Put], out spread, out spread_midle, out spread_howmuch))
                {
                    //logger.LogEvent(time, "Спред опционна Put " + spread + " вырос более чем в " + spread_howmuch + " раза от среднего спреда " + spread_midle);
                    flag = false;
                }
            }
            if (flag)
            {
                midle_opt_price_put  = (inputs[Put].Ask + inputs[Put].Bid) / 2;
                midle_opt_price_call = (inputs[Call].Ask + inputs[Call].Bid) / 2;
            }
            if (midle_opt_price_put > inputs[Put].Ask || midle_opt_price_put < inputs[Put].Bid)
            {
                midle_opt_price_put = (inputs[Put].Ask + inputs[Put].Bid) / 2;
                Array.Clear(spread_col_put, 0, spread_col_put.Length);
            }
            if (midle_opt_price_call > inputs[Call].Ask || midle_opt_price_call < inputs[Call].Bid)
            {
                midle_opt_price_call = (inputs[Call].Ask + inputs[Call].Bid) / 2;
                Array.Clear(spread_col_call, 0, spread_col_call.Length);
            }
            double pt = inputs[Fut].Point;

            if (pt <= 0)
            {
                pt = 1.0;
            }
            double gap = (Strike - midle_opt_price_put + midle_opt_price_call - (inputs[Fut].Bid + inputs[Fut].Ask) / 2) / pt;
            double midle_gap;
            bool   flag2 = GapWorker.new_gap(ref x, ref pos, ref ready, gap, out midle_gap);

            gap -= midle_gap;
            flag = flag & flag2;
            ProcessorAction?.Invoke(new object[] { gap, inputs[Fut].Ask, inputs[Fut].Bid, time });
            return(gap);
        }