Beispiel #1
0
        public static async Task <string> Send(string message)
        {
            if (_lineNotify == null)
            {
                _lineNotify = new LineNotify(AppSettings.LineNotifyUrl, AppSettings.LineNotifyToken);
            }

            return(await _lineNotify.SendToLine(message));
        }
Beispiel #2
0
        /// <summary>
        /// 閾値以上の変動があったら通知する
        /// </summary>
        /// <param name="diff"></param>
        /// <param name="now"></param>
        /// <param name="currentPrice"></param>
        /// <param name="askQuantity"></param>
        /// <param name="bidQuantity"></param>
        /// <param name="prefix"></param>
        /// <returns></returns>
        private async Task <string> NotifyIfLimitOver(decimal diff, DateTime now, decimal currentPrice, decimal askQuantity, decimal bidQuantity, string prefix)
        {
            string result = string.Empty;

            if (Math.Abs(diff) >= _limit)
            {
                if (_lastNotifyTime == null || (now - _lastNotifyTime).TotalSeconds > _notifySpan)
                {
                    // 1度通知したら暫く通知を停止する
                    _lastNotifyTime = DateTime.Now;

                    var lineMsg = string.Format("[{5}]ビットコインに値動きがありました。${1}({0}%)\n{2:#,0} 円\n[注文量]\n買↑:{3}\n売↓:{4}",
                                                diff, currentPrice.ToString("#.##"), (int)(currentPrice * FxRate.Rate),
                                                askQuantity, bidQuantity, prefix);
                    Console.WriteLine(lineMsg);
                    result = await LineNotify.Send(lineMsg);
                }
            }

            return(result);
        }