Beispiel #1
0
        public void SetSourceData(
            string itemCode
            , TimeIntervalEnum timeInterval
            , LitePurushaPrakriti entity)
        {
            Task.Factory.StartNew(() =>
            {
                PurushaPrakriti pp = new PurushaPrakriti();
                pp.MappingProperty(entity);

                try
                {
                    pp.Interval = (int)timeInterval;
                    pp.Create();
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex.Message);
                }
            });
        }
Beispiel #2
0
        public List <LitePurushaPrakriti> GetSourceData(
            string itemCode
            , TimeIntervalEnum timeInterval
            , string startDate = null
            , string endDate   = null
            , int cnt          = 0)
        {
            List <LitePurushaPrakriti> list = new List <LitePurushaPrakriti>();

            PurushaPrakriti pp = new PurushaPrakriti();

            pp.Item         = itemCode;
            pp.Interval     = (int)timeInterval;
            pp.StartDate    = startDate == null ? "" : startDate;
            pp.EndDate      = endDate == null ? "" : endDate;
            pp.DisplayCount = cnt;
            try
            {
                Entities entities = (Entities)pp.Collect();

                foreach (var m in entities.Cast <PurushaPrakriti>())
                {
                    var n = new LitePurushaPrakriti(
                        m.OpenVal, m.HighVal, m.LowVal, m.CloseVal, m.Volume, m.DT
                        );

                    list.Add(n);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }

            return(list);
        }
Beispiel #3
0
        public void GetSise(CurrentPrice price = null)
        {
            try
            {
                if (candle != null && price != null)
                {
                    var nextTime = candle.DTime.AddMinutes(EnumUtil.GetIntervalValueToMinutes(ruleInfo.TimeType));

                    if (price.DTime < nextTime)
                    {
                        return;
                    }
                }

                PurushaPrakriti pp = new PurushaPrakriti();
                pp.Item         = ruleInfo.Item;
                pp.Interval     = (int)EnumUtil.GetTimeIntervalValue(ruleInfo.TimeType);
                pp.DisplayCount = 5;
                try
                {
                    Entities entities           = (Entities)pp.Collect(new Query("USP_PP_SIMPLE_LST"));
                    List <PurushaPrakriti> list = entities.Cast <PurushaPrakriti>().ToList();

                    List <int> ticks = new List <int>();
                    foreach (var k in list.GetRange(1, 4))
                    {
                        int tick = PriceTick.GetTickDiff(ItemCode
                                                         , Convert.ToDouble(k.OpenVal)
                                                         , Convert.ToDouble(k.CloseVal));

                        ticks.Add(tick);
                    }

                    int avgTick = Convert.ToInt32(ticks.Average());
                    if (avgTick < limitTicks)
                    {
                        avgTick = limitTicks;
                    }

                    var m = list[1];
                    if (candle != null)
                    {
                        if (candle.HighPrice > m.HighVal && candle.LowPrice < m.LowVal)
                        {
                            return;
                        }

                        int tick = PriceTick.GetTickDiff(ItemCode
                                                         , Convert.ToDouble(candle.OpenPrice)
                                                         , Convert.ToDouble(candle.ClosePrice));

                        if (tick < avgTick)
                        {
                            return;
                        }
                    }

                    candle = new S_CandleItemData(ItemCode, m.OpenVal, m.HighVal, m.LowVal, m.CloseVal, m.Volume, m.DT);

                    if (!ruleInfo.IsBuyDone)
                    {
                        InitRule();
                    }
                    else
                    {
                        ruleInfo.IsCanRevenue = true;
                    }
                }
                catch (Exception ex)
                {
                    string err = ex.Message;
                }
            }
            catch (Exception)
            {
            }
        }
Beispiel #4
0
        private void LoadCandle(string itemCode)
        {
            int             displayCnt = 10;
            PurushaPrakriti pp         = new PurushaPrakriti();

            pp.Item         = itemCode;
            pp.Interval     = (int)EnumUtil.GetTimeIntervalValue("1분");
            pp.DisplayCount = 30;
            try
            {
                Entities entities                  = (Entities)pp.Collect(new Query("USP_PP_SIMPLE_LST"));
                List <PurushaPrakriti>  list       = entities.Cast <PurushaPrakriti>().ToList();
                List <S_CandleItemData> resultList = new List <S_CandleItemData>();
                foreach (var m in list)
                {
                    var item = new S_CandleItemData(itemCode, m.OpenVal, m.HighVal, m.LowVal, m.CloseVal, m.Volume, m.DT);

                    resultList.Add(item);
                }
                PPStorage.Instance.Init01(itemCode, resultList);
            }
            catch (Exception) { }

            pp              = new PurushaPrakriti();
            pp.Item         = itemCode;
            pp.Interval     = (int)EnumUtil.GetTimeIntervalValue("5분");
            pp.DisplayCount = 30;
            try
            {
                Entities entities                  = (Entities)pp.Collect(new Query("USP_PP_SIMPLE_LST"));
                List <PurushaPrakriti>  list       = entities.Cast <PurushaPrakriti>().ToList();
                List <S_CandleItemData> resultList = new List <S_CandleItemData>();
                foreach (var m in list)
                {
                    var item = new S_CandleItemData(itemCode, m.OpenVal, m.HighVal, m.LowVal, m.CloseVal, m.Volume, m.DT);

                    resultList.Add(item);
                }
                PPStorage.Instance.Init05(itemCode, resultList);
            }
            catch (Exception) { }

            pp              = new PurushaPrakriti();
            pp.Item         = itemCode;
            pp.Interval     = (int)EnumUtil.GetTimeIntervalValue("10분");
            pp.DisplayCount = displayCnt;
            try
            {
                Entities entities                  = (Entities)pp.Collect(new Query("USP_PP_SIMPLE_LST"));
                List <PurushaPrakriti>  list       = entities.Cast <PurushaPrakriti>().ToList();
                List <S_CandleItemData> resultList = new List <S_CandleItemData>();
                foreach (var m in list)
                {
                    var item = new S_CandleItemData(itemCode, m.OpenVal, m.HighVal, m.LowVal, m.CloseVal, m.Volume, m.DT);

                    resultList.Add(item);
                }
                PPStorage.Instance.Init10(itemCode, resultList);
            }
            catch (Exception) { }

            pp              = new PurushaPrakriti();
            pp.Item         = itemCode;
            pp.Interval     = (int)EnumUtil.GetTimeIntervalValue("30분");
            pp.DisplayCount = displayCnt;
            try
            {
                Entities entities                  = (Entities)pp.Collect(new Query("USP_PP_SIMPLE_LST"));
                List <PurushaPrakriti>  list       = entities.Cast <PurushaPrakriti>().ToList();
                List <S_CandleItemData> resultList = new List <S_CandleItemData>();
                foreach (var m in list)
                {
                    var item = new S_CandleItemData(itemCode, m.OpenVal, m.HighVal, m.LowVal, m.CloseVal, m.Volume, m.DT);

                    resultList.Add(item);
                }
                PPStorage.Instance.Init30(itemCode, resultList);
            }
            catch (Exception) { }

            pp              = new PurushaPrakriti();
            pp.Item         = itemCode;
            pp.Interval     = (int)EnumUtil.GetTimeIntervalValue("60분");
            pp.DisplayCount = displayCnt;
            try
            {
                Entities entities                  = (Entities)pp.Collect(new Query("USP_PP_SIMPLE_LST"));
                List <PurushaPrakriti>  list       = entities.Cast <PurushaPrakriti>().ToList();
                List <S_CandleItemData> resultList = new List <S_CandleItemData>();
                foreach (var m in list)
                {
                    var item = new S_CandleItemData(itemCode, m.OpenVal, m.HighVal, m.LowVal, m.CloseVal, m.Volume, m.DT);

                    resultList.Add(item);
                }
                PPStorage.Instance.Init60(itemCode, resultList);
            }
            catch (Exception) { }

            pp              = new PurushaPrakriti();
            pp.Item         = itemCode;
            pp.Interval     = (int)EnumUtil.GetTimeIntervalValue("120분");
            pp.DisplayCount = displayCnt;
            try
            {
                Entities entities                  = (Entities)pp.Collect(new Query("USP_PP_SIMPLE_LST"));
                List <PurushaPrakriti>  list       = entities.Cast <PurushaPrakriti>().ToList();
                List <S_CandleItemData> resultList = new List <S_CandleItemData>();
                foreach (var m in list)
                {
                    var item = new S_CandleItemData(itemCode, m.OpenVal, m.HighVal, m.LowVal, m.CloseVal, m.Volume, m.DT);

                    resultList.Add(item);
                }
                PPStorage.Instance.Init120(itemCode, resultList);
            }
            catch (Exception) { }

            pp              = new PurushaPrakriti();
            pp.Item         = itemCode;
            pp.Interval     = (int)EnumUtil.GetTimeIntervalValue("일");
            pp.DisplayCount = displayCnt;
            try
            {
                Entities entities                  = (Entities)pp.Collect(new Query("USP_PP_SIMPLE_LST"));
                List <PurushaPrakriti>  list       = entities.Cast <PurushaPrakriti>().ToList();
                List <S_CandleItemData> resultList = new List <S_CandleItemData>();
                foreach (var m in list)
                {
                    var item = new S_CandleItemData(itemCode, m.OpenVal, m.HighVal, m.LowVal, m.CloseVal, m.Volume, m.DT);

                    resultList.Add(item);
                }
                PPStorage.Instance.InitDay(itemCode, resultList);
            }
            catch (Exception) { }
        }