Exemplo n.º 1
0
        public BarInfo GetHistory(HistoryRequest value)
        {
            BarInfo ret = new BarInfo {
                Token = value
            };
            object IntResultArray = null;
            object FltResultArray = null;

            try
            {
                if (uaApi2 == null)
                {
                    uaApi2 = new API2Class();
                }

                uaApi2.MarketSymbol = value.Symbol;
                uaApi2.IsStock      = 1;
                int MarketNumber = uaApi2.FindMarketNumber();
                int Count        = 0;
                if (MarketNumber == -1)
                {
                    uaApi2.IsStock = 0;
                    MarketNumber   = uaApi2.FindMarketNumber();
                }
                if (MarketNumber != -1)
                {
                    // JSM added 20130715
                    uaApi2.ApplyStockSplitAdjustments    = 1;
                    uaApi2.ApplyStockDividendAdjustments = 1;
                    uaApi2.PropStockAdjustments          = 1;
                    uaApi2.PropStockVolumeAdjustments    = 1;
                    uaApi2.RoundToTick = 1;

                    uaApi2.RetrieveStock(MarketNumber, int.Parse(GetBeginDate(value.period, value.MaxAmount).ToString("yyyyMMdd")), int.Parse(DateTime.Now.ToString("yyyyMMdd")));
                    Count = uaApi2.CopyRetrievedDataToArray2(0, out IntResultArray, out FltResultArray);
                    double[,] singleArray = FltResultArray as double[, ];
                    Int32[,] intArray     = IntResultArray as Int32[, ];
                    for (int j = 0; j < Count; j++)
                    {
                        ret.Add(new Bar()
                        {
                            TimeStamp = ParseDate(intArray[0, j].ToString()), Open = singleArray[1, j], High = singleArray[2, j], Low = singleArray[3, j], Close = singleArray[4, j], Volume = intArray[3, j]
                        });
                    }
                }
            }
            catch (Exception e)
            {
                uaApi2        = null;
                value.Message = e.Message;
                throw e;
            }
            return(ret);
        }