コード例 #1
0
    /// <summary>
    /// 分析历史数据
    /// </summary>
    /// <returns></returns>
    public override async Task RunHistory()
    {
        await base.RunHistory();

        Console.WriteLine(V_Instrument_id + ":分析结果");
        Debugger.Warn(V_Instrument_id + ":分析结果");
        TaticsTestRunner.TestRun(this);
        Console.WriteLine(V_Instrument_id + ":分析历史数据完毕");
        Debugger.Warn(V_Instrument_id + ":分析历史数据完毕");
    }
コード例 #2
0
    /// <summary>
    /// 刷新历史数据
    /// </summary>
    public override async Task RunHistory()
    {
        await base.RunHistory();

        Console.WriteLine(V_Instrument_id + ":分析结果");

        Debugger.Warn(V_Instrument_id + ":分析结果");

        List <float> resultList_add = new List <float>();
        List <float> resultList_mul = new List <float>();

        List <float> klineList_add = new List <float>();
        List <float> klineList_mul = new List <float>();

        int          start    = 150;
        List <KLine> all_data = V_HistoryCache.V_KLineData;

        for (int i = start; i < all_data.Count - start; i++)
        {
            List <KLine> data = all_data.GetRange(all_data.Count - 1 - start - i, start);

            if (V_Cache == null)
            {
                V_Cache = new KLineCache();
            }
            V_Cache.RefreshData(data);

            float result = GetResult();

            if ((MathF.Abs(result) - 0.01f) > 0)
            {
                if (result > 0)
                {
                    resultList_add.Add(result);
                }
                else
                {
                    resultList_mul.Add(result);
                }
            }

            //KLine line = data[0];
            //float p = (line.V_ClosePrice - line.V_OpenPrice) / line.V_OpenPrice * V_Leverage * 100;
            //if (MathF.Abs(p) >= 0.1f)
            //{
            //    if (line.V_OpenPrice > line.V_ClosePrice)
            //    {
            //        //跌
            //        klineList_mul.Add(p);
            //    }
            //    else
            //    {
            //        //涨
            //        klineList_add.Add(p);
            //    }
            //}
        }

        result_add_avg = Util.GetAvg(resultList_add);
        result_mul_avg = Util.GetAvg(resultList_mul);

        resultList_add.AddRange(resultList_mul);

        result_avg = Util.GetAvg(resultList_add);

        TaticsTestRunner.TestRun(this);

        Console.WriteLine(V_Instrument_id + ":分析历史数据完毕");

        Debugger.Warn(V_Instrument_id + ":分析历史数据完毕");
    }