• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

OmegaChartのソースコードの保守


Commit MetaInfo

Revisionabec95183e38adccdd3ae834f0e303862ebeff62 (tree)
Zeit2022-12-15 22:48:19
Autorpanacoran <panacoran@user...>
Commiterpanacoran

Log Message

Yahooファイナンスからの株価取得が途中で止まるのを回避

Ändern Zusammenfassung

Diff

--- a/Yahoo.cs
+++ b/Yahoo.cs
@@ -6,6 +6,7 @@ using System;
66 using System.Collections.Generic;
77 using System.Globalization;
88 using System.IO;
9+using System.Linq;
910 using System.Net;
1011 using System.Text.RegularExpressions;
1112 using System.Threading;
@@ -19,6 +20,7 @@ namespace Zanetti.DataSource.Specialized
1920 private readonly List<int> _codes = new List<int>();
2021 private readonly List<int> _series = new List<int>();
2122 private const int DaysAtOnce = 20; // 一度に取得する時系列の営業日数
23+ private static Random _rng = new Random();
2224
2325 private class FetchResult
2426 {
@@ -76,7 +78,7 @@ namespace Zanetti.DataSource.Specialized
7678 UpdateDataFarm((int)BuiltInIndex.Nikkei225, nikkei225.Prices);
7779 SendMessage(AsyncConst.WM_ASYNCPROCESS, (int)BuiltInIndex.Nikkei225,
7880 AsyncConst.LPARAM_PROGRESS_SUCCESSFUL);
79- _codeQueue = new Queue<int>(_codes);
81+ _codeQueue = new Queue<int>(_codes.OrderBy(x => _rng.Next()));
8082 _codeQueue.Enqueue((int)BuiltInIndex.TOPIX);
8183 var retry = 0;
8284 while (true)
@@ -96,6 +98,7 @@ namespace Zanetti.DataSource.Specialized
9698 }
9799 UpdateDataFarm(result.Code, result.Prices);
98100 SendMessage(AsyncConst.WM_ASYNCPROCESS, result.Code, AsyncConst.LPARAM_PROGRESS_SUCCESSFUL);
101+ Thread.Sleep(_rng.Next(0, 500));
99102 }
100103 if (_codeQueue.Count == 0)
101104 break;