Exemple #1
0
        /// <summary>
        /// 捕捞季节
        /// VAR1:=(2*CLOSE+HIGH+LOW)/3;
        /// VAR2:= EMA(EMA(EMA(VAR1, 3), 3), 3);
        /// J: (VAR2 - REF(VAR2, 1)) / REF(VAR2, 1) * 100;
        /// D: MA(J, 2);
        /// K: MA(J, 1);
        /// </summary>
        public static string BLJJ(string code = null, string period = null, string type = null, string date = null)
        {
            string EndDate = date == null?DateTime.Now.ToString("yyyy-MM-dd") : Convert.ToDateTime(date).ToString("yyyy-MM-dd");

            string BeginDate = Convert.ToDateTime(EndDate).AddDays(-1450).ToString("yyyy-MM-dd");

            code   = code == null ? "300083" : code;
            type   = type == null ? "1d" : type;
            period = period == null ? "30" : period;

            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("code", code + ".XSHG");
            dic.Add("unit", type);
            dic.Add("date", BeginDate);
            dic.Add("end_date", EndDate);
            dic.Add("fq_ref_date", EndDate);
            dic.Add("JQUserName", "13052089963");
            dic.Add("JQPassWord", "yangyanan");
            SortedList <string, SingleStockStru> stocklist = GetJQData.get_price_period(dic);
            List <decimal> testValues = new List <decimal>();

            //(2*CLOSE+HIGH+LOW)/3
            foreach (var item in stocklist)
            {
                testValues.Add((2 * item.Value.close + item.Value.high + item.Value.low) / 3);
            }
            //J: (VAR2 - REF(VAR2, 1)) / REF(VAR2, 1) * 100
            List <decimal> pre_ema_list = StockFunction.EMA(StockFunction.EMA(StockFunction.EMA(testValues, 3), 3), 3);
            List <decimal> DList        = new List <decimal>();
            List <decimal> KList        = new List <decimal>();

            if (pre_ema_list.Count > Convert.ToInt32(period))
            {
                for (int i = 0; i < Convert.ToInt32(period); i++)
                {
                    decimal J1 = (StockFunction.REF(pre_ema_list, i) - StockFunction.REF(pre_ema_list, i + 1)) / StockFunction.REF(pre_ema_list, i + 1) * 100;
                    decimal J2 = (StockFunction.REF(pre_ema_list, i + 1) - StockFunction.REF(pre_ema_list, i + 2)) / StockFunction.REF(pre_ema_list, i + 2) * 100;
                    DList.Add((J1 + J2) / 2);
                    KList.Add(J1);
                }
            }
            else
            {
                for (int i = 0; i < pre_ema_list.Count; i++)
                {
                    decimal J1 = (StockFunction.REF(pre_ema_list, i) - StockFunction.REF(pre_ema_list, i + 1)) / StockFunction.REF(pre_ema_list, i + 1) * 100;
                    decimal J2 = (StockFunction.REF(pre_ema_list, i + 1) - StockFunction.REF(pre_ema_list, i + 2)) / StockFunction.REF(pre_ema_list, i + 2) * 100;
                    DList.Add(J1 + J2);
                    KList.Add(J1);
                }
            }
            List <List <decimal> > ll = new List <List <decimal> >();

            DList.Reverse();
            KList.Reverse();
            ll.Add(DList);
            ll.Add(KList);
            return(JsonConvert.SerializeObject(ll));
        }
        public override Stream BuildReport()
        {
            StockHistoryWorksheet = Excel.Workbook.Worksheets.Add("Список Пользователей");

            StockList = StockFunction.GetAllStockHistory();

            // шапка
            StockHistoryWorksheet.Cells[1, 1].Value = "Название товара";
            StockHistoryWorksheet.Cells[1, 2].Value = "Было";
            StockHistoryWorksheet.Cells[1, 3].Value = "Изменение";
            StockHistoryWorksheet.Cells[1, 4].Value = "Стало";
            StockHistoryWorksheet.Cells[1, 5].Value = "Дата";
            StockHistoryWorksheet.Cells[1, 6].Value = "Комментарий";

            int row = 2;

            var ProductGroup = StockList.GroupBy(s => s.ProductId).ToList();

            foreach (var group in ProductGroup)
            {
                group.OrderByDescending(x => x.Id);

                foreach (var stock in group)
                {
                    StockHistoryWorksheet.Cells[row, 1].Value = stock.Product.Name;

                    StockHistoryWorksheet.Cells[row, 2].Value = stock.Balance - stock.Quantity;

                    StockHistoryWorksheet.Cells[row, 3].Value = stock.Quantity;

                    StockHistoryWorksheet.Cells[row, 4].Value = stock.Balance;

                    StockHistoryWorksheet.Cells[row, 5].Value = stock.DateAdd.ToString();

                    StockHistoryWorksheet.Cells[row, 6].Value = stock.Text;

                    row++;
                }
            }

            //foreach(var stock in StockList)
            //{
            //    StockHistoryWorksheet.Cells[row, 1].Value = stock.Product.Name;

            //    StockHistoryWorksheet.Cells[row, 2].Value = stock.Balance + stock.Quantity;

            //    StockHistoryWorksheet.Cells[row, 3].Value = stock.Quantity;

            //    StockHistoryWorksheet.Cells[row, 4].Value = stock.Balance;

            //    StockHistoryWorksheet.Cells[row, 5].Value = stock.DateAdd.ToString();

            //    StockHistoryWorksheet.Cells[row, 6].Value = stock.Text;

            //    row++;

            //}

            return(new MemoryStream(Excel.GetAsByteArray()));
        }
        public Task <TransactionReceipt> StockRequestAndWaitForReceiptAsync(ushort x, ushort y, string species, BigInteger amount, CancellationTokenSource cancellationToken = null)
        {
            var stockFunction = new StockFunction();

            stockFunction.X       = x;
            stockFunction.Y       = y;
            stockFunction.Species = species;
            stockFunction.Amount  = amount;

            return(ContractHandler.SendRequestAndWaitForReceiptAsync(stockFunction, cancellationToken));
        }
        public Task <string> StockRequestAsync(ushort x, ushort y, string species, BigInteger amount)
        {
            var stockFunction = new StockFunction();

            stockFunction.X       = x;
            stockFunction.Y       = y;
            stockFunction.Species = species;
            stockFunction.Amount  = amount;

            return(ContractHandler.SendRequestAsync(stockFunction));
        }
Exemple #5
0
        /// <summary>
        /// Добавить одну позицию товара в корзину
        /// </summary>
        /// <returns></returns>
        private async Task <IActionResult> AddToBasket()
        {
            var CurrentStock = StockFunction.CurrentBalance(ProductId);

            int CountInBasket = BasketFunction.ProductBasketCount(FollowerId, ProductId, BotInfo.Id);

            if (CurrentStock >= CountInBasket + 1)
            {
                BasketFunction.AddPositionToBasker(FollowerId, ProductId, BotInfo.Id);
                return(await SendEditorPositionMsg());
            }

            if (CurrentStock < CountInBasket + 1)
            {
                await AnswerCallback("В наличии только " + CurrentStock.ToString(), true);

                return(OkResult);
            }

            return(OkResult);
        }
Exemple #6
0
        /// <summary>
        /// 捕捞季节
        /// VAR1:=(2*CLOSE+HIGH+LOW)/3;
        /// VAR2:= EMA(EMA(EMA(VAR1, 3), 3), 3);
        /// J: (VAR2 - REF(VAR2, 1)) / REF(VAR2, 1) * 100;
        /// D: MA(J, 2);
        /// K: MA(J, 1);
        /// </summary>
        public List <List <decimal> > BLJJ(string code = null, string period = null, string type = null, string date = null)
        {
            string EndDate = date == null?DateTime.Now.ToString("yyyy-MM-dd") : Convert.ToDateTime(date).ToString("yyyy-MM-dd");

            if (date == null && DateTime.Now.Hour < 9)
            {
                EndDate = date == null?DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd") : Convert.ToDateTime(date).ToString("yyyy-MM-dd");
            }
            string BeginDate = Convert.ToDateTime(EndDate).AddDays(-1450).ToString("yyyy-MM-dd");

            code   = code == null ? DefaultCode : code;
            type   = type == null ? "1d" : type;
            period = period == null ? "30" : period;

            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("code", code + ".XSHG");
            dic.Add("unit", type);
            dic.Add("date", BeginDate);
            dic.Add("end_date", EndDate);
            dic.Add("fq_ref_date", EndDate);
            dic.Add("JQUserName", JQUserName);
            dic.Add("JQPassWord", JQPassWord);
            SortedList <string, SingleStockStru> stocklist = GetJQData.get_price_period(dic);
            List <decimal> testValues = new List <decimal>();
            List <decimal> TList      = new List <decimal>();

            //(2*CLOSE+HIGH+LOW)/3
            foreach (var item in stocklist)
            {
                testValues.Add((2 * item.Value.close + item.Value.high + item.Value.low) / 3);
            }

            //J: (VAR2 - REF(VAR2, 1)) / REF(VAR2, 1) * 100
            List <decimal>         pre_ema_list = StockFunction.EMA(StockFunction.EMA(StockFunction.EMA(testValues, 3), 3), 3);
            List <decimal>         DList        = new List <decimal>();
            List <decimal>         KList        = new List <decimal>();
            List <List <decimal> > ll           = new List <List <decimal> >();

            //根据给定显示周期,截取数据:D、J、Time
            if (pre_ema_list.Count > Convert.ToInt32(period))
            {
                for (int i = 0; i < Convert.ToInt32(period); i++)
                {
                    decimal J1 = (StockFunction.REF(pre_ema_list, i) - StockFunction.REF(pre_ema_list, i + 1)) / StockFunction.REF(pre_ema_list, i + 1) * 100;
                    decimal J2 = (StockFunction.REF(pre_ema_list, i + 1) - StockFunction.REF(pre_ema_list, i + 2)) / StockFunction.REF(pre_ema_list, i + 2) * 100;
                    DList.Add((J1 + J2) / 2);
                    KList.Add(J1);
                    TList.Add(Convert.ToDecimal(stocklist.Keys.ToList <string>()[stocklist.Count - i - 1]));
                }
            }
            else
            {
                for (int i = 0; i < pre_ema_list.Count; i++)
                {
                    decimal J1 = (StockFunction.REF(pre_ema_list, i) - StockFunction.REF(pre_ema_list, i + 1)) / StockFunction.REF(pre_ema_list, i + 1) * 100;
                    decimal J2 = (StockFunction.REF(pre_ema_list, i + 1) - StockFunction.REF(pre_ema_list, i + 2)) / StockFunction.REF(pre_ema_list, i + 2) * 100;
                    DList.Add(J1 + J2);
                    KList.Add(J1);
                    TList.Add(Convert.ToDecimal(stocklist.Keys.ToList <string>()[stocklist.Count - i - 1]));
                }
            }
            DList.Reverse();
            KList.Reverse();
            TList.Reverse();
            ll.Add(DList);
            ll.Add(KList);
            ll.Add(TList);
            return(ll);
        }
 public Task <TransactionReceipt> StockRequestAndWaitForReceiptAsync(StockFunction stockFunction, CancellationTokenSource cancellationToken = null)
 {
     return(ContractHandler.SendRequestAndWaitForReceiptAsync(stockFunction, cancellationToken));
 }
 public Task <string> StockRequestAsync(StockFunction stockFunction)
 {
     return(ContractHandler.SendRequestAsync(stockFunction));
 }