Beispiel #1
0
        /// <summary>
        /// Updates the daily share ticker.
        /// </summary>
        /// <param name="s">The s.</param>
        /// <param name="eodList">The eod list.</param>
        //public void UpdateDailyShareTicker(Share s, List<AsxEod> eodList)
        //{
        //    Ticker lastTicker = GetLastTicker(s.Id, null);

        //    if (lastTicker != null)
        //    {
        //        int nextTradingDay = DateHelper.NextTradingDay(lastTicker.TradingDate);

        //        if (eodList != null && eodList.Count > 0 &&
        //            nextTradingDay == eodList[0].TradingDate)
        //        {
        //            try
        //            {
        //                // update daily from EOD file Azure
        //                // jjjj this to be removed
        //                //updateDailyTickerFromEODTicker(s, eodList);

        //                _auditBLL.Create(new AuditLog
        //                {
        //                    ActionMessage = string.Format("Success upload {0} via EOD azure", s.Symbol),
        //                    ExtraData = "",
        //                    ActionType = ActionType.UploadDailyTicker.ToString(),
        //                    ActionResult = ""
        //                });
        //            }
        //            catch (Exception ex)
        //            {
        //                LogHelper.Error(_log, string.Format("Error load ticker from EOD {0} {1}. Load from yahoo instead", s.Symbol, nextTradingDay));
        //                LogHelper.Error(_log, ex.ToString());

        //                // upload history data from yahoo
        //                this.UploadHistoryPriceTicker(s.Symbol, DateHelper.IntToDate(nextTradingDay), DateTime.Now);

        //                _auditBLL.Create(new AuditLog
        //                {
        //                    ActionMessage = string.Format("Error load EOD. Then successfully upload {0} via EOD azure", s.Symbol),
        //                    ExtraData = "",
        //                    ActionType = ActionType.UploadDailyTicker.ToString(),
        //                    ActionResult = ""
        //                });
        //            }
        //        }
        //        else if (nextTradingDay <= DateHelper.DateToInt(DateTime.Now))
        //        {
        //            // upload history data from yahoo
        //            this.UploadHistoryPriceTicker(s.Symbol, DateHelper.IntToDate(nextTradingDay), DateTime.Now);

        //            _auditBLL.Create(new AuditLog
        //            {
        //                ActionMessage = string.Format("Success load from yahoo more than 1 day {0}.", s.Symbol),
        //                ExtraData = "",
        //                ActionType = ActionType.UploadDailyTicker.ToString(),
        //                ActionResult = string.Format("{0}  {1}  {2}", s.Symbol, DateHelper.IntToDate(nextTradingDay), DateTime.Now)
        //            });

        //        }
        //        else
        //        {
        //            _auditBLL.Create(new AuditLog
        //            {
        //                ActionMessage = string.Format("Ticker {0} already loaded, skipped.", s.Symbol),
        //                ExtraData = "",
        //                ActionType = ActionType.UploadDailyTicker.ToString(),
        //                ActionResult = ""
        //            });

        //        }
        //    }
        //    else
        //    {
        //        SettingBLL settingBLL = new SettingBLL(_unit);
        //        int historyYears = int.Parse(settingBLL.GetSetting(SettingKey.HistoryDataYears));
        //        DateTime defaultStart = DateTime.Now.AddYears(-1 * historyYears);

        //        // upload history data from yahoo from day 1
        //        this.UploadHistoryPriceTicker(s.Symbol, defaultStart, DateTime.Now);

        //        _auditBLL.Create(new AuditLog
        //        {
        //            ActionMessage = string.Format("Success load from yahoo from day 1 {0}.", s.Symbol),
        //            ExtraData = "",
        //            ActionType = ActionType.UploadDailyTicker.ToString(),
        //            ActionResult = string.Format("{0}  {1}  {2}", s.Symbol, defaultStart, DateTime.Now)
        //        });
        //    }

        //}

        /// <summary>
        /// Updates the daily ticker from eod ticker.
        /// </summary>
        /// <param name="s">The s.</param>
        /// <param name="eodTickerList">The eod ticker list.</param>
        public void updateDailyTickerFromEODTicker(Share s, AsxEod eod)
        {
            Ticker t = new Ticker();

            t.TradingDate   = eod.TradingDate;
            t.Open          = eod.Open;
            t.High          = eod.High;
            t.Low           = eod.Low;
            t.Close         = eod.Close;
            t.Volumn        = eod.Volumn;
            t.ShareId       = s.Id;
            t.AdjustedClose = eod.AdjustedClose;
            t.JSTicks       = DateHelper.IntToJSTicks(eod.TradingDate);

            this.Create(t);
        }
Beispiel #2
0
        /// <summary>
        /// Gets the asx ticker from string.
        /// </summary>
        /// <param name="tickerString">The ticker string.</param>
        /// <returns></returns>
        private AsxEod GetASXTickerFromString(string tickerString)
        {
            AsxEod t      = null;
            string suffix = ".AX";

            string[] tickerParts = tickerString.Split(',');

            if (tickerParts != null && tickerParts.Length > 0)
            {
                t = new AsxEod();

                t.Symbol        = tickerParts[0] + suffix;
                t.TradingDate   = int.Parse(tickerParts[1]);
                t.Open          = double.Parse(tickerParts[2]);
                t.High          = double.Parse(tickerParts[3]);
                t.Low           = double.Parse(tickerParts[4]);
                t.Close         = double.Parse(tickerParts[5]);
                t.Volumn        = long.Parse(tickerParts[6]);
                t.AdjustedClose = double.Parse(tickerParts[7]);
            }
            return(t);
        }