コピペ: OmegaChart DreamVisor終了対応 DownloadOrder.cs 追加修正ポイントには//☆DreamVisor終了対応

形式
Plain text
投稿日時
2018-09-09 13:34
公開期間
無期限
  1. /*
  2. * Copyright (c) Daisuke OKAJIMA All rights reserved.
  3. *
  4. * $Id$
  5. */
  6. // This file is modified by panacoran.
  7. // Copyright (c) 2014 panacoran <panacoran@users.sourceforge.jp>
  8. // This program is part of OmegaChart.
  9. // OmegaChart is licensed under the Apache License, Version 2.0.
  10. using System;
  11. using System.Collections;
  12. using Travis.Storage;
  13. using Zanetti.Data;
  14. namespace Zanetti.DataSource
  15. {
  16. //何をダウンロードするかの設定
  17. internal class DownloadOrder
  18. {
  19. public enum StockDownload {
  20. None, //ダウンロードしない
  21. All, //全部
  22. Bookmark, //ブックマーク内の銘柄のみ
  23. Recent, //最近の日付のみ
  24. SingleBrand //1銘柄
  25. }
  26. public enum StockDataSource
  27. {
  28. Mujinzou,
  29. KdbCom,
  30. Yahoo,
  31. Edatalab
  32. }
  33. static public string[] StockDataSourceNames
  34. {
  35. get { return new[] {"無尽蔵", "k-db.com", "Yahoo時系列", "edatalab.net"}; }
  36. }
  37. private string _name; //名前をつけていなければnull
  38. private StockDownload _stock;
  39. private bool _domesticIndices;
  40. private bool _foreignIndices;
  41. private bool _sectors;
  42. private bool _currencies;
  43. private bool _commodities;
  44. private int[] _dateArray; //_stock==Recentのみで有効
  45. private AbstractBrand _targetBrand; //_stock==SingleBrandでのみ有効 //!!このあたりはクラス階層を分離すべきかも
  46. public DownloadOrder() {
  47. }
  48. public string Name {
  49. get {
  50. return _name;
  51. }
  52. set {
  53. _name = value;
  54. }
  55. }
  56. public StockDownload Stock {
  57. get {
  58. return _stock;
  59. }
  60. set {
  61. _stock = value;
  62. }
  63. }
  64. public StockDataSource Source { get; set; }
  65. public bool DomesticIndices {
  66. get {
  67. return _domesticIndices;
  68. }
  69. set {
  70. _domesticIndices = value;
  71. }
  72. }
  73. public bool ForeignIndices {
  74. get {
  75. return _foreignIndices;
  76. }
  77. set {
  78. _foreignIndices = value;
  79. }
  80. }
  81. public bool Sectors {
  82. get {
  83. return _sectors;
  84. }
  85. set {
  86. _sectors = value;
  87. }
  88. }
  89. public bool Currencies {
  90. get {
  91. return _currencies;
  92. }
  93. set {
  94. _currencies = value;
  95. }
  96. }
  97. public bool Commodities {
  98. get {
  99. return _commodities;
  100. }
  101. set {
  102. _commodities = value;
  103. }
  104. }
  105. public int[] DateArray {
  106. get {
  107. return _dateArray;
  108. }
  109. set {
  110. _dateArray = value;
  111. }
  112. }
  113. public AbstractBrand TargetBrand {
  114. get {
  115. return _targetBrand;
  116. }
  117. set {
  118. _targetBrand = value;
  119. }
  120. }
  121. public CombinedDataSource ConvertToDataSource() {
  122. //これらでオプションからダウンロード元を適当に選定してもよい。
  123. ArrayList col = new ArrayList();
  124. #if BUILD_INITIAL_DATA
  125. //チェックボックスとは関係なくダウンロード
  126. AddDreamVisorDomesticIndicesDataSources(col);
  127. AddDreamVisorForeignIndicesDataSources(col);
  128. col.Add(new Specialized.DreamVisorDataSource(new CodeEnumerator.SectorsEnumerator()));
  129. AddDreamVisorCurrenciesDataSources(col);
  130. col.Add(new Specialized.KenMilleDataSource(new CodeEnumerator.AllStockEnumerator()));
  131. #else //通常版
  132. if(_domesticIndices) AddDomesticIndicesDataSources(col);
  133. if(_foreignIndices) AddForeignIndicesDataSources(col);
  134. if(_sectors) col.Add(new Specialized.DreamVisorDataSource(new CodeEnumerator.SectorsEnumerator()));
  135. if(_currencies) AddCurrenciesDataSources(col);
  136. #if DOJIMA
  137. if(_commodities) col.Add(new Specialized.YutakaDataSource(new CodeEnumerator.CommodityEnumerator()));
  138. #endif
  139. //ダウンロードの残り時間を自然に見せるため、国内株式は最後にする
  140. SingleDataSource stock_ds = null;
  141. switch(_stock) {
  142. case StockDownload.SingleBrand:
  143. #if DOJIMA
  144. if(_targetBrand.IsCommodity)
  145. stock_ds = new Specialized.YutakaDataSource(new CodeEnumerator.Single(_targetBrand));
  146. else
  147. #endif
  148. throw new NotSupportedException("単一銘柄のダウンロードはサポートされていません。");
  149. case StockDownload.All:
  150. throw new NotSupportedException("全銘柄一括ダウンロードはサポートされていません。");
  151. case StockDownload.Bookmark:
  152. throw new NotSupportedException("ブックマーク内のダウンロードはサポートされていません。");
  153. case StockDownload.Recent:
  154. switch (Source)
  155. {
  156. case StockDataSource.Mujinzou:
  157. stock_ds = new Specialized.MujinzouDataSource(_dateArray);
  158. break;
  159. case StockDataSource.KdbCom:
  160. stock_ds = new Specialized.KdbComDataSource(_dateArray);
  161. break;
  162. case StockDataSource.Yahoo:
  163. stock_ds = new Specialized.YahooDataSource(_dateArray);
  164. break;
  165. case StockDataSource.Edatalab:
  166. stock_ds = new Specialized.EdatalabDataSource(_dateArray);
  167. break;
  168. }
  169. break;
  170. }
  171. if(stock_ds!=null) col.Add(stock_ds);
  172. #endif //BUILD_INITIAL_DATA
  173. return new CombinedDataSource((SingleDataSource[])col.ToArray(typeof(SingleDataSource)));
  174. }
  175. //株価指数
  176. private void AddDomesticIndicesDataSources(ArrayList col) {
  177. //☆DreamVisor終了対応 追加ここから
  178. ArrayList ar = new ArrayList();
  179. ar.Add((int)BuiltInIndex.Nikkei225);
  180. ar.Add((int)BuiltInIndex.TOPIX);
  181. ar.Add((int)BuiltInIndex.JASDAQ);
  182. col.Add(new Specialized.YahooDataVariousSource(new CodeEnumerator.VariousEnumerator(ar)));
  183. ar = new ArrayList();
  184. ar.Add((int)BuiltInIndex.Nikkei225_F);
  185. ar.Add((int)BuiltInIndex.TOPIX_F);
  186. col.Add(new Specialized.KenMilleDataVariousSource(new CodeEnumerator.VariousEnumerator(ar)));
  187. //ここまで
  188. #if DREAMVISOR
  189. col.Add(new Specialized.DreamVisorDataSource(new CodeEnumerator.DomesticIndicesEnumerator()));
  190. #endif
  191. }
  192. //海外指数
  193. private void AddForeignIndicesDataSources(ArrayList col) {
  194. //col.Add(new Specialized.DreamVisorDataSource(new CodeEnumerator.ForeignIndicesEnumerator()));//☆DreamVisor終了対応 コメントアウト
  195. //☆DreamVisor終了対応 追加ここから
  196. ArrayList ar = new ArrayList();
  197. ar.Add((int)BuiltInIndex.Dow);
  198. ar.Add((int)BuiltInIndex.Nasdaq);
  199. ar.Add((int)BuiltInIndex.SP500);
  200. col.Add(new Specialized.YahooDataUsSource(new CodeEnumerator.VariousEnumerator(ar)));
  201. //ここまで
  202. }
  203. //為替
  204. private void AddCurrenciesDataSources(ArrayList col) {
  205. //col.Add(new Specialized.DreamVisorDataSource(new CodeEnumerator.CurrenciesEnumerator()));//☆DreamVisor終了対応 コメントアウト
  206. //☆DreamVisor終了対応 追加ここから
  207. ArrayList ar = new ArrayList();
  208. ar.Add((int)BuiltInIndex.JPYUSD);
  209. ar.Add((int)BuiltInIndex.JPYEUR);
  210. col.Add(new Specialized.YahooDataVariousSource(new CodeEnumerator.VariousEnumerator(ar)));
  211. //ここまで
  212. }
  213. //使ってない
  214. private void AddDreamVisorDomesticIndicesDataSources(ArrayList col) {
  215. col.Add(new Specialized.DreamVisorDataSource(new CodeEnumerator.DomesticIndicesEnumerator()));
  216. }
  217. //使ってない
  218. private void AddDreamVisorForeignIndicesDataSources(ArrayList col) {
  219. col.Add(new Specialized.DreamVisorDataSource(new CodeEnumerator.ForeignIndicesEnumerator()));
  220. }
  221. //使ってない
  222. private void AddDreamVisorCurrenciesDataSources(ArrayList col) {
  223. col.Add(new Specialized.DreamVisorDataSource(new CodeEnumerator.CurrenciesEnumerator()));
  224. }
  225. public void Load(StorageNode node) {
  226. _name = node["name"];
  227. _stock = (StockDownload)Enum.Parse(typeof(StockDownload), node.GetValue("stock", "All"));
  228. Source = (StockDataSource)Enum.Parse(typeof(StockDataSource), node.GetValue("source", "Mujinzou"));
  229. _domesticIndices = Util.ParseBool(node["domesticIndices"], true);
  230. _foreignIndices = Util.ParseBool(node["foreignIndices"], true);
  231. _sectors = Util.ParseBool(node["sectors"], false);
  232. _currencies = Util.ParseBool(node["currencies"], false);
  233. _commodities = Util.ParseBool(node["commodities"], false);
  234. }
  235. public StorageNode SaveAsNewNode() {
  236. StorageNode node = new StorageNode();
  237. if(_name!=null) node["name"] = _name;
  238. node["stock"] = _stock.ToString();
  239. node["source"] = Source.ToString();
  240. node["domesticIndices"] = _domesticIndices.ToString();
  241. node["foreignIndices"] = _foreignIndices.ToString();
  242. node["sectors"] = _sectors.ToString();
  243. node["currencies"] = _currencies.ToString();
  244. node["commodities"] = _commodities.ToString();
  245. return node;
  246. }
  247. public static DownloadOrder CreateDefault() {
  248. DownloadOrder r = new DownloadOrder();
  249. r.Sectors = false;
  250. r.DomesticIndices = true;
  251. r.ForeignIndices = true;
  252. r.Currencies = true;
  253. r.Commodities = false;
  254. r.Source = StockDataSource.Mujinzou;
  255. r.Stock = StockDownload.All;
  256. return r;
  257. }
  258. }
  259. //所定の個数は保存できるようにする
  260. internal class DownloadOrderCollection {
  261. private DownloadOrder[] _data;
  262. public DownloadOrderCollection() {
  263. _data = new DownloadOrder[3];
  264. }
  265. public DownloadOrder this[int i] {
  266. get {
  267. return _data[i];
  268. }
  269. set {
  270. _data[i] = value;
  271. }
  272. }
  273. public int Count {
  274. get {
  275. return _data.Length;
  276. }
  277. }
  278. public string GetDescription(int i) {
  279. DownloadOrder o = _data[i];
  280. return o==null? "未定義" : o.Name==null? "名前なし" : o.Name;
  281. }
  282. public void SaveTo(StorageNode parent) {
  283. for(int i=0; i<_data.Length; i++) {
  284. DownloadOrder o = _data[i];
  285. if(o!=null) {
  286. StorageNode ch = o.SaveAsNewNode();
  287. ch.Name = "download-order";
  288. parent.AddChild(ch);
  289. }
  290. }
  291. }
  292. public void Load(StorageNode node) {
  293. int i = 0;
  294. foreach(StorageNode ch in node.Children) {
  295. if(ch.Name=="download-order") {
  296. DownloadOrder o = new DownloadOrder();
  297. o.Load(ch);
  298. _data[i++] = o;
  299. }
  300. }
  301. }
  302. }
  303. }
ダウンロード 印刷用表示

このコピペの URL

JavaScript での埋め込み

iframe での埋め込み

元のテキスト