OmegaChartのソースコードの保守
Révision | abec95183e38adccdd3ae834f0e303862ebeff62 (tree) |
---|---|
l'heure | 2022-12-15 22:48:19 |
Auteur | panacoran <panacoran@user...> |
Commiter | panacoran |
Yahooファイナンスからの株価取得が途中で止まるのを回避
@@ -6,6 +6,7 @@ using System; | ||
6 | 6 | using System.Collections.Generic; |
7 | 7 | using System.Globalization; |
8 | 8 | using System.IO; |
9 | +using System.Linq; | |
9 | 10 | using System.Net; |
10 | 11 | using System.Text.RegularExpressions; |
11 | 12 | using System.Threading; |
@@ -19,6 +20,7 @@ namespace Zanetti.DataSource.Specialized | ||
19 | 20 | private readonly List<int> _codes = new List<int>(); |
20 | 21 | private readonly List<int> _series = new List<int>(); |
21 | 22 | private const int DaysAtOnce = 20; // 一度に取得する時系列の営業日数 |
23 | + private static Random _rng = new Random(); | |
22 | 24 | |
23 | 25 | private class FetchResult |
24 | 26 | { |
@@ -76,7 +78,7 @@ namespace Zanetti.DataSource.Specialized | ||
76 | 78 | UpdateDataFarm((int)BuiltInIndex.Nikkei225, nikkei225.Prices); |
77 | 79 | SendMessage(AsyncConst.WM_ASYNCPROCESS, (int)BuiltInIndex.Nikkei225, |
78 | 80 | AsyncConst.LPARAM_PROGRESS_SUCCESSFUL); |
79 | - _codeQueue = new Queue<int>(_codes); | |
81 | + _codeQueue = new Queue<int>(_codes.OrderBy(x => _rng.Next())); | |
80 | 82 | _codeQueue.Enqueue((int)BuiltInIndex.TOPIX); |
81 | 83 | var retry = 0; |
82 | 84 | while (true) |
@@ -96,6 +98,7 @@ namespace Zanetti.DataSource.Specialized | ||
96 | 98 | } |
97 | 99 | UpdateDataFarm(result.Code, result.Prices); |
98 | 100 | SendMessage(AsyncConst.WM_ASYNCPROCESS, result.Code, AsyncConst.LPARAM_PROGRESS_SUCCESSFUL); |
101 | + Thread.Sleep(_rng.Next(0, 500)); | |
99 | 102 | } |
100 | 103 | if (_codeQueue.Count == 0) |
101 | 104 | break; |