Exemple #1
0
 public static extern bool ExecuteFormula(int openday, int zq, int sc, String code, FORMULA_TIME begin, FORMULA_TIME end, int type, String name, String errmsg, ref FmFormulaOutput finaloutput, int nLen);
Exemple #2
0
 public static extern bool ExecuteFormulaWithKLineAndFormula(int openday, int zq, int sc, String code,
                                                             FORMULA_TIME begin, FORMULA_TIME end,
                                                             Kline[] kline, Formula f, String errmsg,
                                                             ref FmFormulaOutput finaloutput, int nLen);
Exemple #3
0
 public static extern bool ExecuteFormulaWithExtraConst(int openday, int zq, int sc, String code, FORMULA_TIME begin, FORMULA_TIME end, Kline[] kline, Formula f, FM_FORMULA_EXTRA_CONST[] data, int datalen, ref FmFormulaOutput finaloutput, int nlen, String errmsg);
Exemple #4
0
        public void HistoryDataCallBack(List <OneDayDataRec> list)
        {
            int         listSize  = list.Count;
            EMIndicator indicator = indicators[lbFormula.SelectedIndex];

            indicator.QuoteData.Clear();
            FORMULA_TIME begin, end;

            begin = new FORMULA_TIME();
            end   = new FORMULA_TIME();
            int nlen = list.Count;

            Kline[] klines = new Kline[nlen];
            if (list == null || list.Count <= 0)
            {
                return;
            }
            begin.year  = (ushort)(list[0].Date / 10000);
            begin.month = (byte)((list[0].Date - begin.year * 10000) / 100);
            begin.day   = (byte)(list[0].Date - begin.year * 10000 - begin.month * 100);
            end         = new FORMULA_TIME();
            end.year    = (ushort)(list[nlen - 1].Date / 10000);
            end.month   = (byte)((list[nlen - 1].Date - end.year * 10000) / 100);
            end.day     = (byte)(list[nlen - 1].Date - end.year * 10000 - end.month * 100);
            for (int i = 0; i < nlen; i++)
            {
                klines[i].Date = list[i].Date;
                //不复权
                klines[i].Open   = list[i].Open;
                klines[i].Close  = list[i].Close;
                klines[i].High   = list[i].High;
                klines[i].Low    = list[i].Low;
                klines[i].Value  = list[i].Amount;
                klines[i].Volume = (uint)list[i].Volume;
                klines[i].Time   = list[i].Time;
            }
            String          errmsg = String.Empty;
            FmFormulaOutput output = new FmFormulaOutput();
            Dictionary <int, Dictionary <FieldIndex, String> > dict = DetailData.FieldIndexDataString;

            //执行调用指标公式方法
            if (indicator.Formula.fid <= 0)
            {
                FormulaProxy.ExecuteFormula(list[0].Date, (int)KLINEPERIOD.PERIOD_DAY, 1, txtCode.Text, begin,
                                            end, 0, klines, indicator.IndicatorName, errmsg, ref output, nlen);
            }
            else
            {
                FormulaProxy.ExecuteFormulaWithKLineAndFormula(list[0].Date,
                                                               (int)KLINEPERIOD.PERIOD_DAY, 1, txtCode.Text, begin,
                                                               end, klines, indicator.Formula, errmsg, ref output, nlen);
            }


            for (int n = 0; n < output.outputCount; n++)
            {
                if (output.fmOutput[n].normaloutput.ToInt64() != 0)
                {
                    GetNormalFormulaOutput(indicator, output, nlen, n, 0, MarketType2.MARKET_SZ, KLineCycle.CycleDay);
                }
                else
                {
                    GetFunctionFormulaOutput(indicator, output, nlen, n, 0);
                }
            }
            DataTable dt = new DataTable(indicator.IndicatorName);

            foreach (QuoteDataStru stu in indicator.QuoteData)
            {
                dt.Columns.Add(stu.QuoteName);
            }
            int idx = indicator.QuoteData[0].QuoteDataList.Count;
            int ix  = indicator.QuoteData.Count;

            if (idx > 0)
            {
                for (int i = 0; i < idx; i++)
                {
                    DataRow row = dt.NewRow();
                    dt.Rows.Add(row);
                    for (int j = 0; j < ix; j++)
                    {
                        row[j] = indicator.QuoteData[j].QuoteDataList[i];
                    }
                }
            }
            try
            {
                dgvData.DataSource = dt.DefaultView;
            }
            catch (Exception ex)
            {
                Console.WriteLine("1");
            }
            hisData = "";
        }