Beispiel #1
0
        public chart Get(string id, string ktype)
        {
            var kdata   = new kdatadb().kdata(id, ktype);
            var basic   = new Trade.Db.db().basics(id);
            var since   = Trade.Cfg.Configuration.data.bearcrossbull;
            var k       = kdata.Where(p => p.date >= since).ToArray();
            var macd    = new MACD(kdata.close()).Where(p => p.Date >= since).ToArray();
            var macdvol = new MACD(kdata.volume(100)).Where(p => p.Date >= since).ToArray();
            var ma5     = new MA(kdata.close(), 5).Range(since);
            var ma30    = new MA(kdata.close(), 30).Range(since);
            var ma60    = new MA(kdata.close(), 60).Range(since);
            var ma120   = new MA(kdata.close(), 120).Range(since);
            var chg     = new CHG(kdata.close()).Range(since);
            var bottom  = new BOTTOM(kdata).Range(since);

            return(new chart {
                data = k.Select(p => new object[] { p.date, p.open, p.high, p.low, p.close, chg[p.date] }).ToArray(),
                volume = k.Select(p => new object[] { p.date, p.volume / 100 }).ToArray(),
                macd = macd.Select(p => new object[] { p.Date, p.MACD }).ToArray(),
                dif = macd.Select(p => new object[] { p.Date, p.DIF }).ToArray(),
                dea = macd.Select(p => new object[] { p.Date, p.DEA }).ToArray(),
                macdvol = macdvol.Select(p => new object[] { p.Date, p.MACD }).ToArray(),
                difvol = macdvol.Select(p => new object[] { p.Date, p.DIF }).ToArray(),
                deavol = macdvol.Select(p => new object[] { p.Date, p.DEA }).ToArray(),
                ma5 = ma5.Select(p => new object[] { p.Date, p.Value }).ToArray(),
                ma30 = ma30.Select(p => new object[] { p.Date, p.Value }).ToArray(),
                ma60 = ma60.Select(p => new object[] { p.Date, p.Value }).ToArray(),
                ma120 = ma120.Select(p => new object[] { p.Date, p.Value }).ToArray(),
                code = kdata.Code,
                name = basic.name,
                bottom = bottom.Select(p => new object[] { p.Date, p.Value }).ToArray(),
                keyprices = keyprice(k, id, ktype)
            });
        }
Beispiel #2
0
        public override void Leer(StreamReader lector)
        {
            string[] filas;
            string[] elemsFila;
            int      f = 0;

            cantColumnas = -1;
            filas        = MA.LeerMatriz(lector);
            cantFilas    = filas.Length;
            Filas        = new ParamVector[cantFilas];

            foreach (string fila in filas)
            {
                ParamVector vector = new ParamVector();
                vector.Definicion = Definicion;
                elemsFila         = MA.ObtenerElementosDeLaFila(fila);
                if (cantColumnas == -1)
                {
                    cantColumnas = elemsFila.Length;
                }
                else
                if (elemsFila.Length != cantColumnas)
                {
                    throw new Exception(Mensajes.MatrizTieneFilaEnDeDistintaLongitud(Definicion.Nombre, f));
                }

                VerificarTiposCorrectos(f, elemsFila);
                vector.EstablecerValor(elemsFila);
                Filas[f] = vector;
                f++;
            }
        }
Beispiel #3
0
        protected override void InitPaint()
        {
            base.InitPaint();

            try
            {
                //콤보박스 셋팅
                _flexM.SetDataMap("CD_ACCT", MA.GetCode("CZ_ME_C008"), "CODE", "NAME");

                //상세검색창
                foreach (Form openForm in Application.OpenForms)
                {
                    if (openForm.Name == "P_CZ_ME_SALES_SUB") // 열린 폼의 이름 검사
                    {
                        openForm.Activate();
                        return;
                    }
                }

                P_CZ_ME_SALES_SUB sub = new P_CZ_ME_SALES_SUB();                //WinForm 생성
                sub.TextSendEvent += new P_CZ_ME_SALES_SUB.Form2_EventHandler(frm2_getTextEvent);
                sub.Show();
            }
            catch (Exception ex)
            {
                this.MsgEnd(ex);
            }
        }
Beispiel #4
0
    public static float GetBoll(int length, List <KLine> data, out float upValue, out float lowValue)
    {
        float midValue = MA.GetMA(length, data);

        List <double> mulList = new List <double>();

        for (int i = 0; i < length; i++)
        {
            KLine line = data[i];
            mulList.Add(Math.Pow(line.V_ClosePrice - midValue, 2));
        }

        //标准差
        double sd = Math.Sqrt(mulList.Average());


        //上轨
        upValue = midValue + 2 * (float)sd;


        //下轨
        lowValue = midValue - 2 * (float)sd;

        return(midValue);
    }
Beispiel #5
0
        protected override void InitPaint()
        {
            base.InitPaint();

            Grant.CanDelete = false;
            Grant.CanAdd    = false;
            Grant.CanPrint  = false;

            DateTime time = Global.MainFrame.GetDateTimeToday();

            toyear = time.ToString("yyyy") + "0101";

            dt일자.StartDate = DateTime.ParseExact(toyear, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture);
            dt일자.EndDate   = DateTime.ParseExact(toyear, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture);

            //콤보박스 셋팅
            //DataTable dt계정코드 = _biz.Get계정코드();
            //_flexM.SetDataMap("CD_ACCT", dt계정코드.Copy(), "CODE", "NAME");
            _flexM.SetDataMap("ME_TRADE_TYPE", MA.GetCode("CZ_ME_C004"), "CODE", "NAME");
            //_flexM.SetDataMap("ME_TRADE_TYPE", MA.GetCode("CZ_ME_C004"), "CODE", "NAME");

            btn전표처리.Click += new EventHandler(btn전표처리_Click);
            btn전표삭제.Click += new EventHandler(btn전표삭제_Click);

            rdo전체.CheckedChanged  += new EventHandler(radioButton_CheckedChanged);
            rdo미처리.CheckedChanged += new EventHandler(radioButton_CheckedChanged);
            rdo처리.CheckedChanged  += new EventHandler(radioButton_CheckedChanged);
            rdo변경.CheckedChanged  += new EventHandler(radioButton_CheckedChanged);
            rdo수기.CheckedChanged  += new EventHandler(radioButton_CheckedChanged);

            rdo_idx = "전체";
        }
        private Stock_Report GetStockReportData(Stock stock)
        {
            try
            {
                List <Candel> candels = stock.Stock_Quote.Select(sq => new Candel()
                {
                    Date    = sq.date_round,
                    Close   = sq.closing,
                    Maximun = sq.maximun,
                    Minimun = sq.minimun,
                    Open    = sq.opening,
                    Visible = true,
                    Volume  = (double)sq.volume
                }).ToList();

                if (candels.Any())
                {
                    MA       ma20                   = new MA(candels, 20, "");
                    MA       ma50                   = new MA(candels, 50, "");
                    MA       ma200                  = new MA(candels, 200, "");
                    EMA      ema12                  = new EMA(candels, 12, "", false);
                    EMA      ema20                  = new EMA(candels, 20, "", false);
                    EMA      ema26                  = new EMA(candels, 26, "", false);
                    RSI      rsi14                  = new RSI(candels, 14, 0, 0, "", "");
                    Momentum momentum12             = new Momentum(candels, 12, "", "");
                    StochasticOscillatorFast soFast = new StochasticOscillatorFast(candels, 14, 0, 0, "", "", "");
                    MACD           macd1226         = new MACD(candels, 12, 26, 9, "", "");
                    BoolingerBands boolinger20      = new BoolingerBands(candels, 20, "");
                    WilliansR      williansr14      = new WilliansR(candels, 14, 0, 0, "", "", "");

                    Stock_Report result = new Stock_Report();
                    result.Stock_ID   = stock.Id;
                    result.Price      = stock.Stock_Quote.Last().closing;
                    result.Date_Round = stock.Stock_Quote.Last().date_round;
                    result.MA20       = ma20.Series[0].Data.Last().Value;
                    result.MA50       = ma50.Series[0].Data.Last().Value;
                    result.MA200      = ma200.Series[0].Data.Last().Value;
                    result.RSI14      = rsi14.Series[0].Data.Last().Value;
                    result.Momentum12 = momentum12.Series[0].Data.Last().Value;
                    result.SOFast_k14 = (soFast.Series[0].Data.Any()) ? soFast.Series[0].Data.Last().Value : 0;
                    result.SOFast_d3  = (soFast.Series[1].Data.Any()) ? soFast.Series[1].Data.Last().Value : 0;
                    result.EMA12      = ema12.Series[0].Data.Last().Value;
                    result.EMA26      = ema26.Series[0].Data.Last().Value;
                    result.MACD2612   = macd1226.Series[0].Data.Last().Value;
                    result.MA9        = macd1226.Series[1].Data.Last().Value;
                    result.EMA20      = ema20.Series[0].Data.Last().Value;
                    result.BoolUP     = boolinger20.Series[1].Data.Last().Value;
                    result.BoolLOW    = boolinger20.Series[2].Data.Last().Value;
                    result.WilliansR  = (williansr14.Series[0].Data.Any()) ? williansr14.Series[0].Data.Last().Value : 0;

                    return(result);
                }
                return(null);
            }

            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #7
0
        public double GetIndex(DateTime targetDate)
        {
            MA ma_10 = new MA(10);
            MA ma_long = new MA(50);

            DateTime pivot = GetNearestDate(targetDate);

            SetData(ma_10, pivot, 10);
            SetData(ma_long, pivot, 50);

            List<double> ma_10_diff = MathUtil.GetDiffData(ma_10.GetData());
            List<double> ma_long_diff = MathUtil.GetDiffData(ma_long.GetData());

            double vol_10 = MathUtil.GetYearVol(ma_10_diff);
            double vol_long = MathUtil.GetYearVol(ma_long_diff);

            double rawValue = vol_long / (vol_10 + 0.0000005);

            if (double.IsNaN(rawValue))
            {
                rawValue = 1.0;
                return rawValue;
            }

            return MathUtil.CapAndFloor(rawValue);
        }
Beispiel #8
0
        public async Task <ActionResult <MA> > PostMA(MA item)
        {
            _context.MA.Add(item);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetMA), new { id = item.id }, item));
        }
Beispiel #9
0
    void Awake()
    {
        if (control == null)
        {
            control = GameObject.Find("board").GetComponent <SystemControl>();
        }

        netPlayer = transform.parent.gameObject.GetComponent <NetPlayer>();

        if (!chessMap.ContainsKey(gameObject.name))
        {
            chessMap.Add(gameObject.name, gameObject);
        }
        else
        {
            chessMap[gameObject.name] = gameObject;
        }

        coord.Set(initCoordRow, initCoordCol);

        switch (chessTypeId)
        {
        case ChessTypeId.Empty:
            chessType = Empty.GetChessType();
            break;

        case ChessTypeId.JIANG:
            chessType = JIANG.GetChessType();
            break;

        case ChessTypeId.SHI:
            chessType = SHI.GetChessType();
            break;

        case ChessTypeId.XIANG:
            chessType = XIANG.GetChessType();
            break;

        case ChessTypeId.MA:
            chessType = MA.GetChessType();
            break;

        case ChessTypeId.CHE:
            chessType = CHE.GetChessType();
            break;

        case ChessTypeId.PAO:
            chessType = PAO.GetChessType();
            break;

        case ChessTypeId.BING:
            chessType = BING.GetChessType();
            break;

        default:
            chessType = Empty.GetChessType();
            break;
        }
    }
Beispiel #10
0
        public void SmaSingle_SimpleValues_Calculated()
        {
            var ma = new MA();

            var result = Math.Round(ma.SmaSingle(data, 10).Value, 4);

            Assert.Equal(44.4513D, result);
        }
Beispiel #11
0
 public void FDE_PrintStats()
 {
     Console.WriteLine();
     Console.WriteLine("INT:{0}   REF:{1}   TECH:{2}", INT.ToString(), REF.ToString(), TECH.ToString());
     Console.WriteLine("COOL:{0}  ATTR:{1}  LUCK:{2}", COOL.ToString(), ATTR.ToString(), LUCK.ToString());
     Console.WriteLine("MA:{0}    BODY:{1}  EMP:{2}", MA.ToString(), BODY.ToString(), EMP.ToString());
     Console.WriteLine();
 }
Beispiel #12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("synthetic-access") @Override public com.opengamma.strata.collect.array.DoubleMatrix apply(com.opengamma.strata.collect.array.DoubleArray yStar)
            public override DoubleMatrix apply(DoubleArray yStar)
            {
                DoubleArray  y    = outerInstance._transform.inverseTransform(yStar);
                DoubleMatrix h    = jac(y);
                DoubleMatrix invJ = outerInstance._transform.inverseJacobian(yStar);

                return((DoubleMatrix)MA.multiply(h, invJ));
            }
Beispiel #13
0
        public void SmaSingle_PeriodBiggerThanDataSize_ReturnNull()
        {
            var ma = new MA();

            var result = ma.SmaSingle(data, 1000);

            Assert.Null(result);
        }
Beispiel #14
0
 //Lee el nombre de la prueba
 public void LeerNombre(StreamReader lector)
 {
     string[] nombrePrueba = MA.Leer(lector);
     if (nombrePrueba.Length != 1)
     {
         throw new Exception(Mensajes.NombrePruebaNoPermitido);
     }
     Nombre = nombrePrueba[0];
 }
Beispiel #15
0
        public override void PedirMemoria(EscritorC escritor)
        {
            string pedido;
            int    cantMemoria;

            cantMemoria = Longitud * MA.CuantosBytes(Definicion.Tipo);
            pedido      = Definicion.Nombre + " = " + "malloc2( " + cantMemoria + " ,true);";
            escritor.WriteLine(pedido);
        }
Beispiel #16
0
        public void Sma_PeriodBiggerThanDataSize_ReturnNull()
        {
            var ma = new MA();

            double?[] result   = ma.SMA(data, 300);
            double?[] expected = { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null };

            Assert.Equal(expected, result);
        }
Beispiel #17
0
        protected override void InitPaint()
        {
            base.InitPaint();

            // 추가할 필요가 없으므로 false 처리
            Grant.CanAdd = false;

            // 사업자 정보 탭 일 때 매체 조회조건을 enabled false 시킨다.
            txt명.Enabled = false;

            조회조건체크(true);

            // 처음 페이지 열면 탭이 사업자 정보이므로
            tab_index = "0";

            // 콤보박스 셋팅 부분
            _flexM_T1.SetDataMap("grade", MA.GetCode("CZ_ME_C002"), "CODE", "NAME");
            _flexD_T1.SetDataMap("corpflag", MA.GetCode("CZ_ME_C001"), "CODE", "NAME");
            _flexM_T2.SetDataMap("corpflag", MA.GetCode("CZ_ME_C001"), "CODE", "NAME");
            _flexM_T3.SetDataMap("corpflag", MA.GetCode("CZ_ME_C001"), "CODE", "NAME");
            _flexM_T4.SetDataMap("corpflag", MA.GetCode("CZ_ME_C001"), "CODE", "NAME");
            _flexM_T5.SetDataMap("corpflag", MA.GetCode("CZ_ME_C001"), "CODE", "NAME");

            //DataTable dt매체구분 = _biz.Get매체구분();
            //_flexM_T2.SetDataMap("cd_mediagr", dt매체구분.Copy(), "CODE", "NAME");
            _flexM_T2.SetDataMap("me_type", MA.GetCode("CZ_ME_C007", true), "CODE", "NAME");
            _flexM_T2.SetDataMap("me_attr", MA.GetCode("CZ_ME_C006", true), "CODE", "NAME");

            this.DataChanged += new EventHandler(Page_DataChanged);

            if (rdoDz2.Checked == true)
            {
                rdo_index = "1";
            }
            else if (rdoDz3.Checked == true)
            {
                rdo_index = "2";
            }
            else
            {
                rdo_index = "0";
            }

            if (rdoYn2.Checked == true)
            {
                rdo_yn = "Y";
            }
            else if (rdoYn3.Checked == true)
            {
                rdo_yn = "N";
            }
            else
            {
                rdo_yn = "";
            }
        }
Beispiel #18
0
        public void SmaSingle_PeriodZeroOrLess_ReturnNull()
        {
            var ma = new MA();

            var result  = ma.SmaSingle(data, 0);
            var result2 = ma.SmaSingle(data, -10);

            Assert.Null(result);
            Assert.Null(result2);
        }
Beispiel #19
0
        public override bool InitIndicators(String[] strInstruments)
        {
            ma = new MA(5, 10, 20, 30, 60);
            //SaveIndicator (ma, strInstruments[0]);
            macd = new MACD(12, 24, 1);
            //SaveIndicator (macd, strInstruments[1]);


            return(true);
        }
Beispiel #20
0
        public void EmaSingle_NullData_ReturnNull()
        {
            //Given
            var ma = new MA();

            //When
            var result = ma.EmaSingle(null, 1000);

            //Then
            Assert.Null(result);
        }
Beispiel #21
0
        public void EmaSingle_PeriodBiggerThanDataLength_ReturnNull()
        {
            //Given
            var ma = new MA();

            //When
            var result = ma.EmaSingle(data2, 1000);

            //Then
            Assert.Null(result);
        }
Beispiel #22
0
        public void EmaSingle_SimpleValues_Calculated()
        {
            //Given
            var ma = new MA();

            //When
            var result = Math.Round(ma.EmaSingle(data2, 5).Value, 2);

            //Then
            Assert.Equal(1328.45D, result);
        }
Beispiel #23
0
        public void Sma_SimpleValues_calculated()
        {
            var ma = new MA();

            double[] result     = ma.SMA(data, 3).Where(x => x != null).Select(x => Math.Round(x.Value, 4)).ToArray();
            int      nullCounts = ma.SMA(data, 3).Where(x => x == null).Count();

            double[] expected = { 45.9763, 45.8466, 46.0028, 45.9397, 45.7835, 45.4544, 45.1155, 44.7499, 44.2555, 44.03, 43.9508, 44.1929, 44.2493, 44.3289 };
            Assert.Equal(expected, result);
            Assert.Equal(2, nullCounts);
        }
Beispiel #24
0
        public override void PedirMemoria(EscritorC escritor)
        {
            string pedido;
            int    cantMemoria;

            if (Definicion.Tipo != Tipo.CadenaC && Definicion.Tipo != Tipo.CadenaPascal)
            {
                cantMemoria = MA.CuantosBytes(Definicion.Tipo);
                pedido      = Definicion.Nombre + " = " + "malloc2( " + cantMemoria + ",true );";
                escritor.WriteLine(pedido);
            }
        }
Beispiel #25
0
 public override void PoolRecycle()
 {
     base.PoolRecycle();
     Weapon?.PoolRecycle();
     Weapon = null;
     Shield?.PoolRecycle();
     Shield = null;
     Pack?.PoolRecycle();
     Pack = null;
     MA?.PoolRecycle();
     MA = null;
 }
Beispiel #26
0
        public override void Calculate(int index)
        {
            var idx   = index + Instrument.IdxFirst;
            var mcs   = Instrument.EMATrueRange(idx - Periods, idx);
            var extrp = MA.Extrapolate(1, Periods, idx_: idx);
            var slope = extrp != null ? ((Monic)extrp.Curve).A : MA.FirstDerivative(idx);
            var ma    = MA[idx];

            MA0[index] = ma;
            Top[index] = ma + Distance * mcs + SlopeWeight * slope;
            Bot[index] = ma - Distance * mcs + SlopeWeight * slope;
        }
Beispiel #27
0
        public float GetAllPrice()
        {
            int length = Math.Min(5, dayData.V_KLineData.Count);

            float p = MA.GetMA(length, dayData.V_KLineData);

            List <float> vol = dayData.V_KLineData.Select((data) => data.V_Vol).ToList();

            float v = MA.GetMA(length, vol);

            return(p * v);
        }
Beispiel #28
0
        public void EmaSingle_PeriodZeroOrLess_ReturnNull()
        {
            //Given
            var ma = new MA();

            //When
            var result  = ma.EmaSingle(data2, 0);
            var result2 = ma.EmaSingle(data2, -10);

            //Then
            Assert.Null(result);
            Assert.Null(result2);
        }
Beispiel #29
0
 public override void Leer(StreamReader lector)
 {
     string[] parametros;
     try
     {
         parametros = MA.Leer(lector);
     }
     catch (Exception e)
     {
         throw new Exception(Mensajes.ErrorAlLeerParametro(Definicion.Nombre, e));
     }
     EstablecerValor(parametros);
 }
        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
            diff.Set(High[0] - Low[0]);

            double middle = EMA(Input, length)[0];
            double offset = EMA(diff, length)[0] * bandFactor;

            upper.Set(middle + offset);
            lower.Set(middle - offset);

            DrawRegion(regiontag, CurrentBar, 0, upper, lower, Plots[0].Pen.Color, Plots[0].Pen.Color, opacity);
            MA.Set(middle);
        }
Beispiel #31
0
 public void LeerFinDePrueba(StreamReader lector)
 {
     string[] finPrueba;
     finPrueba = MA.Leer(lector);
     if (finPrueba.Length != 1)
     {
         throw new Exception(Mensajes.FinDePruebaIncorrecto);
     }
     if (finPrueba[0] != "FinDePrueba")
     {
         throw new Exception(Mensajes.FinDePruebaIncorrecto);
     }
 }
Beispiel #32
0
        void SetData(MA ma, DateTime pivot, int n)
        {
            DateTime cur = pivot;
            int count = 0;

            while (true)
            {
                if (count >= n)
                {
                    break;
                }

                if (_data.ContainsKey(cur))
                {
                    double value = _data[cur];
                    ma.Add(value);
                    ++count;
                }

                cur = GetNearestDate(cur.AddDays(-1));
            }
        }