Pastebin: 最後のスクリーニング結果 Command.cs

Format
Plain text
Post date
2015-04-04 22:23
Publication Period
Unlimited
  1. /*
  2. * Copyright (c) Daisuke OKAJIMA All rights reserved.
  3. *
  4. * $Id$
  5. */
  6. using System;
  7. using System.Xml;
  8. using System.IO;
  9. using System.Drawing;
  10. using System.Diagnostics;
  11. using System.Text;
  12. using System.Windows.Forms;
  13. using System.Collections;
  14. using System.Security.Cryptography;
  15. using Zanetti.Arithmetic;
  16. using Zanetti.Data;
  17. using Zanetti.DataSource;
  18. using Zanetti.Forms;
  19. using Zanetti.Config;
  20. using Zanetti.SystemTrading.Screening;
  21. using Zanetti.SystemTrading.AutoTrading;
  22. using Zanetti.Prediction;
  23. using Zanetti.Indicators;
  24. using Zanetti.UI;
  25. using Zanetti.Parser;
  26. using Travis.Storage;
  27. using Travis.Util;
  28. using Travis.PKI;
  29. using Crownwood.Magic.Common;
  30. using Crownwood.Magic.Controls;
  31. using Crownwood.Magic.Docking;
  32. using TabControl = Crownwood.Magic.Controls.TabControl;
  33. //using Crownwood.DotNetMagic.Menus;
  34. namespace Zanetti.Commands {
  35. /* 新しいコマンドを追加するときは次のことをすること
  36. *
  37. * 1) Command.CIDのEnum値に追加
  38. * 2) Command#Init, Execを修正
  39. * 3) コマンドがメニューやツールバーを持つ場合は、MenuItemとCommandの関連付けなどを追加
  40. */
  41. internal enum CommandResult {
  42. Succeeded,
  43. Ignored,
  44. Failed
  45. }
  46. //キーカスタマイズダイアログではこの順番で表示される
  47. internal enum CID {
  48. None = 0 ,
  49. //ダイアログ表示
  50. ShowDownloadDialog,
  51. ShowInitializeDialog,
  52. ShowPrintDialog,
  53. ShowCustomizeDialog,
  54. ShowScreeningDialog,
  55. ShowPredictionDialog,
  56. ShowAutoTradingDialog,
  57. ShowAddBookmarkDialog,
  58. ShowAboutBox,
  59. ShowExtensionKitDialog,
  60. ShowTestKitDialog,
  61. ShowSearchBrandDialog,
  62. ShowKeyConfigDialog,
  63. ShowEnvironmentDialog,
  64. RegisterUserCode,
  65. //スタイル変更
  66. SetStyleDaily,
  67. SetStyleWeekly,
  68. SetStyleMonthly,
  69. SetStyleYearly,
  70. SetStyleHalfDaily, //堂島用
  71. ShrinkCandleWidth,
  72. ExpandCandleWidth,
  73. ToggleLogarithmStyle,
  74. ToggleInverseStyle,
  75. ClearFreeLines,
  76. ToggleBookmarkPane,
  77. ToggleSplitAdjuster,
  78. ToggleScaleLock,
  79. TogglePriceEnabled,
  80. ToggleAccumulativeVolumeEnabled,
  81. //移動
  82. MoveToFirstDate,
  83. MoveToLastDate,
  84. MoveToPrevPage,
  85. MoveToNextPage,
  86. MoveToPrevDate, //ロウソク1本分の移動
  87. MoveToNextDate,
  88. ShowPrevBrand, //現在見えているペインでの銘柄移動
  89. ShowNextBrand,
  90. ShowPrevCode, //コード順での移動
  91. ShowNextCode,
  92. Back,
  93. Front,
  94. //データ関係
  95. UpdateCurrentData,
  96. DownloadIndexFile,
  97. ExportBrand,
  98. ExportHalfDaily,
  99. //Web
  100. OpenWeb,
  101. OpenCompanyInfoSite_Yahoo,
  102. OpenCompanyInfoSite_Infoseek,
  103. OpenCompanyInfoSite_Nikkei,
  104. OpenCompanyInfoSite_Livedoor,
  105. //その他
  106. Quit,
  107. ReloadKit,
  108. //これより前にあるコマンドはキーカスタマイズ等の一覧で出てくる。後のコマンドは出てこない。
  109. VisibleCount,
  110. ShowInputCode,
  111. ShowSpecifiedBrand,
  112. //サポート用コマンド
  113. #if ENABLE_SUPPORT_COMMAND
  114. SupRebuildIndex,
  115. SupCreateKey,
  116. SupReload,
  117. SupCreateCert,
  118. SupStatistics,
  119. SupShrinkData,
  120. #endif
  121. //終端
  122. Count
  123. }
  124. internal class Command : ICloneable {
  125. private CID _id;
  126. private string _description;
  127. private Keys _shortcut;
  128. public CID ID {
  129. get {
  130. return _id;
  131. }
  132. }
  133. public string Description {
  134. get {
  135. return _description;
  136. }
  137. }
  138. public Keys Shortcut {
  139. get {
  140. return _shortcut;
  141. }
  142. }
  143. public object Clone() {
  144. return new Command(_id, _description, _shortcut);
  145. }
  146. /// これはCommandCollectionからしか呼ばない。
  147. public void SetChortcut(Keys key) {
  148. _shortcut = key;
  149. }
  150. public bool Visible {
  151. get {
  152. return _id < CID.VisibleCount;
  153. }
  154. }
  155. public Command(CID id, string description, Keys shortcut) {
  156. _id = id;
  157. _description = description;
  158. _shortcut = shortcut;
  159. }
  160. public CommandResult Exec() {
  161. switch(_id) {
  162. //ダイアログ表示
  163. case CID.ShowDownloadDialog:
  164. return CommandExec.ShowDownloadDialog();
  165. case CID.ShowInitializeDialog:
  166. return CommandExec.ShowInitializeDialog();
  167. case CID.ShowPrintDialog:
  168. return CommandExec.ShowPrintDialog();
  169. case CID.ShowCustomizeDialog:
  170. return CommandExec.ShowCustomizeDialog();
  171. case CID.ShowScreeningDialog:
  172. return CommandExec.ShowScreeningDialog();
  173. case CID.ShowPredictionDialog:
  174. return CommandExec.ShowPredictionDialog();
  175. case CID.ShowAutoTradingDialog:
  176. return CommandExec.ShowAutoTradingDialog();
  177. case CID.ShowAddBookmarkDialog:
  178. return CommandExec.ShowAddBookmarkDialog();
  179. case CID.ShowAboutBox:
  180. return CommandExec.AboutBox();
  181. case CID.ShowExtensionKitDialog:
  182. return CommandExec.ShowExtensionKitDialog();
  183. case CID.ShowTestKitDialog:
  184. return CommandExec.ShowKitTestDialog();
  185. case CID.ShowSearchBrandDialog:
  186. return CommandExec.ShowSearchBrandDialog();
  187. case CID.ShowKeyConfigDialog:
  188. return CommandExec.ShowKeyConfigDialog();
  189. case CID.ShowEnvironmentDialog:
  190. return CommandExec.ShowEnvironmentDialog();
  191. case CID.RegisterUserCode:
  192. return CommandExec.RegisterUserCode();
  193. //スタイル変更
  194. case CID.SetStyleDaily:
  195. return CommandExec.SetChartFormat(ChartFormat.Daily);
  196. case CID.SetStyleWeekly:
  197. return CommandExec.SetChartFormat(ChartFormat.Weekly);
  198. case CID.SetStyleMonthly:
  199. return CommandExec.SetChartFormat(ChartFormat.Monthly);
  200. case CID.SetStyleYearly:
  201. return CommandExec.SetChartFormat(ChartFormat.Yearly);
  202. #if DOJIMA
  203. case CID.SetStyleHalfDaily:
  204. return CommandExec.SetChartFormat(ChartFormat.HalfDaily);
  205. case CID.ExportHalfDaily:
  206. return CommandExec.ExportHalfDailyData();
  207. #endif
  208. case CID.ShrinkCandleWidth:
  209. return CommandExec.ShrinkCandleWidth();
  210. case CID.ExpandCandleWidth:
  211. return CommandExec.ExpandCandleWidth();
  212. case CID.ToggleLogarithmStyle:
  213. return CommandExec.SetLogarithmStyle(!Env.Preference.LogScale);
  214. case CID.ToggleInverseStyle:
  215. return CommandExec.SetInverseStyle(!Env.Preference.InverseChart);
  216. case CID.ClearFreeLines:
  217. return CommandExec.ClearFreeLines();
  218. case CID.ToggleBookmarkPane:
  219. return CommandExec.ShowBookmarkPane(!Env.Frame.IsBookmarkPaneVisible);
  220. case CID.ToggleSplitAdjuster:
  221. return CommandExec.SetSplitAdjuster(!Env.Preference.AdjustSplit);
  222. case CID.ToggleScaleLock:
  223. return CommandExec.SetScaleLock(!Env.Preference.ScaleLock);
  224. case CID.TogglePriceEnabled:
  225. return CommandExec.SetPriceEnabled(!Env.Preference.ShowPrice);
  226. case CID.ToggleAccumulativeVolumeEnabled:
  227. return CommandExec.SetAccumulativeVolumeEnabled(!Env.Preference.ShowAccumulativeVolume);
  228. //移動
  229. case CID.MoveToFirstDate:
  230. return CommandExec.JumpDate(Keys.Home);
  231. case CID.MoveToLastDate:
  232. return CommandExec.JumpDate(Keys.End);
  233. case CID.MoveToNextPage:
  234. return CommandExec.JumpDate(Keys.PageDown);
  235. case CID.MoveToPrevPage:
  236. return CommandExec.JumpDate(Keys.PageUp);
  237. case CID.MoveToNextDate:
  238. return CommandExec.JumpDate(Keys.Right);
  239. case CID.MoveToPrevDate:
  240. return CommandExec.JumpDate(Keys.Left);
  241. case CID.ShowNextBrand:
  242. return CommandExec.ShowNextBrand();
  243. case CID.ShowPrevBrand:
  244. return CommandExec.ShowPrevBrand();
  245. case CID.ShowNextCode:
  246. return CommandExec.ShowNextCode();
  247. case CID.ShowPrevCode:
  248. return CommandExec.ShowPrevCode();
  249. case CID.Back:
  250. return CommandExec.Back(1);
  251. case CID.Front:
  252. return CommandExec.Front(1);
  253. //データ関係
  254. case CID.DownloadIndexFile:
  255. return CommandExec.DownloadIndexFile();
  256. case CID.UpdateCurrentData:
  257. return CommandExec.UpdateCurrentData();
  258. case CID.ExportBrand:
  259. return CommandExec.ExportBrand();
  260. //Web
  261. case CID.OpenWeb:
  262. return CommandExec.OpenWeb();
  263. case CID.OpenCompanyInfoSite_Yahoo:
  264. return CommandExec.OpenCompanyInfoPage(CompanyInfoSite.Yahoo);
  265. case CID.OpenCompanyInfoSite_Infoseek:
  266. return CommandExec.OpenCompanyInfoPage(CompanyInfoSite.Infoseek);
  267. case CID.OpenCompanyInfoSite_Nikkei:
  268. return CommandExec.OpenCompanyInfoPage(CompanyInfoSite.Nikkei);
  269. case CID.OpenCompanyInfoSite_Livedoor:
  270. return CommandExec.OpenCompanyInfoPage(CompanyInfoSite.Livedoor);
  271. //その他
  272. case CID.Quit:
  273. return CommandExec.Quit();
  274. case CID.ReloadKit:
  275. return CommandExec.Reload(null);
  276. #if ENABLE_SUPPORT_COMMAND
  277. case CID.SupRebuildIndex: {
  278. Data.StaticGrouping.Run();
  279. return CommandResult.Succeeded;
  280. }
  281. case CID.SupReload:
  282. return CommandExec.Reload(null);
  283. case CID.SupCreateKey:
  284. return CommandExec.CreateKey();
  285. case CID.SupCreateCert:
  286. return CommandExec.GenerateUserCode();
  287. case CID.SupStatistics:
  288. return CommandExec.StatisticsTest();
  289. case CID.SupShrinkData:
  290. return CommandExec.ShrinkData();
  291. #endif
  292. default:
  293. Debug.WriteLine("Unknown command " + _id);
  294. return CommandResult.Ignored;
  295. }
  296. }
  297. }
  298. internal class CommandCollection : ICloneable {
  299. //Collection
  300. private Hashtable _keyToCommand;
  301. private Command[] _idArray;
  302. public CommandCollection(StorageNode keys) {
  303. Init(keys);
  304. }
  305. public void Reset() {
  306. Init(null);
  307. }
  308. private CommandCollection() {
  309. _keyToCommand = new Hashtable();
  310. _idArray = new Command[(int)CID.Count];
  311. }
  312. public object Clone() {
  313. CommandCollection r = new CommandCollection();
  314. foreach(Command cmd in _idArray) {
  315. Command nc = (Command)cmd.Clone();
  316. r._idArray[(int)nc.ID] = nc;
  317. if(nc.Shortcut!=Keys.None) r._keyToCommand[nc.Shortcut] = nc;
  318. }
  319. return r;
  320. }
  321. private void Init(StorageNode keys) {
  322. _keyToCommand = new Hashtable();
  323. _idArray = new Command[(int)CID.Count];
  324. //ダイアログ表示
  325. AddCommand(CID.ShowDownloadDialog, "データのダウンロード", keys, Keys.Control|Keys.O);
  326. AddCommand(CID.ShowInitializeDialog, "データの初期化", keys, Keys.None);
  327. AddCommand(CID.ShowPrintDialog, "印刷", keys, Keys.Control|Keys.P);
  328. AddCommand(CID.ShowCustomizeDialog, "カスタマイズ", keys, Keys.Control|Keys.T);
  329. AddCommand(CID.ShowScreeningDialog, "スクリーニング", keys, Keys.Control|Keys.S);
  330. AddCommand(CID.ShowAutoTradingDialog, "自動売買検証", keys, Keys.Control|Keys.V);
  331. AddCommand(CID.ShowPredictionDialog, "セオリー検証", keys, Keys.None);
  332. AddCommand(CID.ShowAddBookmarkDialog, "ブックマークへの追加", keys, Keys.None);
  333. AddCommand(CID.ShowAboutBox, "バージョン情報の表示", keys, Keys.None);
  334. AddCommand(CID.ShowKeyConfigDialog, "キー割り当てのカスタマイズ", keys, Keys.None);
  335. AddCommand(CID.ShowEnvironmentDialog, "環境設定", keys, Keys.None);
  336. AddCommand(CID.ShowExtensionKitDialog, "拡張キット一覧", keys, Keys.None);
  337. AddCommand(CID.ShowTestKitDialog, "拡張キットテスト", keys, Keys.None);
  338. AddCommand(CID.ShowSearchBrandDialog, "銘柄の検索", keys, Keys.Control|Keys.F);
  339. AddCommand(CID.RegisterUserCode, "Contribution Certificateの登録", keys, Keys.None);
  340. //スタイル変更
  341. AddCommand(CID.SetStyleDaily, "日足表示", keys, Keys.Control|Keys.D);
  342. AddCommand(CID.SetStyleWeekly, "週足表示", keys, Keys.Control|Keys.W);
  343. AddCommand(CID.SetStyleMonthly, "月足表示", keys, Keys.Control|Keys.M);
  344. AddCommand(CID.SetStyleYearly, "年足表示", keys, Keys.Control|Keys.Y);
  345. AddCommand(CID.SetStyleHalfDaily, "半日足表示", keys, Keys.Control|Keys.H);
  346. AddCommand(CID.ShrinkCandleWidth, "ロウソク幅の縮小", keys, Keys.Control|Keys.OemMinus);
  347. AddCommand(CID.ExpandCandleWidth, "ロウソク幅の拡大", keys, Keys.Control|Keys.Oemplus);
  348. AddCommand(CID.ToggleLogarithmStyle, "対数表示切替", keys, Keys.Control|Keys.L);
  349. AddCommand(CID.ToggleInverseStyle, "上下反転表示切替", keys, Keys.Control|Keys.R);
  350. AddCommand(CID.ClearFreeLines, "自由直線のクリア", keys, Keys.None);
  351. AddCommand(CID.ToggleBookmarkPane, "ブックマーク表示の切替", keys, Keys.Control|Keys.B);
  352. AddCommand(CID.ToggleSplitAdjuster, "分割の考慮切替", keys, Keys.None);
  353. AddCommand(CID.ToggleScaleLock, "縮尺の固定", keys, Keys.None);
  354. AddCommand(CID.TogglePriceEnabled, "価格と凡例の表示", keys, Keys.None);
  355. AddCommand(CID.ToggleAccumulativeVolumeEnabled, "価格帯出来高の表示",keys,Keys.None);
  356. //移動
  357. AddCommand(CID.MoveToFirstDate, "最初の日付へ移動", keys, Keys.Home);
  358. AddCommand(CID.MoveToLastDate, "最後の日付へ移動", keys, Keys.End);
  359. //このブロックはKeyConfigDialogでカスタマイズできる。1コマンドずつの独立ではないことに注意
  360. AddCommand(CID.MoveToNextPage, "1画面先の日付へ移動", keys, Keys.None);
  361. AddCommand(CID.MoveToPrevPage, "1画面前の日付へ移動", keys, Keys.None);
  362. AddCommand(CID.MoveToNextDate, "1日次へ", keys, Keys.None);
  363. AddCommand(CID.MoveToPrevDate, "1日前へ", keys, Keys.None);
  364. AddCommand(CID.ShowNextBrand, "次の表示順銘柄", keys, Keys.None);
  365. AddCommand(CID.ShowPrevBrand, "前の表示順銘柄", keys, Keys.None);
  366. AddCommand(CID.ShowNextCode, "次のコード順銘柄", keys, Keys.None);
  367. AddCommand(CID.ShowPrevCode, "前のコード順銘柄", keys, Keys.None);
  368. AddCommand(CID.Back, "戻る", keys, Keys.Back);
  369. AddCommand(CID.Front, "進む", keys, Keys.Shift|Keys.Back);
  370. AddCommand(CID.ShowInputCode, "コード入力", keys, Keys.None);
  371. //データ関係
  372. AddCommand(CID.DownloadIndexFile, "インデックスファイルのダウンロード", keys, Keys.None);
  373. AddCommand(CID.UpdateCurrentData, "現在の銘柄を更新", keys, Keys.F5);
  374. AddCommand(CID.ExportBrand, "データのエクスポート", keys, Keys.None);
  375. AddCommand(CID.ExportHalfDaily, "半日足データのエクスポート", keys, Keys.None);
  376. //Web
  377. AddCommand(CID.OpenWeb, "OmegaChartのWebを開く", keys, Keys.None);
  378. AddCommand(CID.OpenCompanyInfoSite_Yahoo, "Yahooの企業情報ページを開く", keys, Keys.None);
  379. AddCommand(CID.OpenCompanyInfoSite_Infoseek, "Infoseekの企業情報ページを開く", keys, Keys.None);
  380. AddCommand(CID.OpenCompanyInfoSite_Nikkei, "日経の企業情報ページを開く", keys, Keys.None);
  381. AddCommand(CID.OpenCompanyInfoSite_Livedoor, "livedoorの企業情報ページを開く", keys, Keys.None);
  382. //その他
  383. AddCommand(CID.Quit, "OmegaChartの終了", keys, Keys.Control|Keys.Shift|Keys.X);
  384. AddCommand(CID.ReloadKit, "拡張キットのリロード", keys, Keys.None);
  385. //サポート用コマンド
  386. #if ENABLE_SUPPORT_COMMAND
  387. AddCommand(CID.SupRebuildIndex, "Active500などのindex再作成", keys, Keys.None);
  388. AddCommand(CID.SupReload, "リロード", keys, Keys.None);
  389. AddCommand(CID.SupCreateKey, "キーの再作成", keys, Keys.None);
  390. AddCommand(CID.SupCreateCert, "Contribution Cert作成", keys, Keys.None);
  391. AddCommand(CID.SupStatistics, "Statistics", keys, Keys.None);
  392. AddCommand(CID.SupShrinkData, "データ縮小", keys, Keys.None);
  393. #endif
  394. }
  395. private void AddCommand(CID cid, string desc, StorageNode keys, Keys def) {
  396. Keys k = keys==null? def : Util.ParseKey(keys[cid.ToString()]);
  397. Command cmd = new Command(cid, desc, k);
  398. _idArray[(int)cid] = cmd;
  399. if(k!=Keys.None) _keyToCommand[k] = cmd;
  400. }
  401. public Command Get(CID cid) {
  402. Command r = _idArray[(int)cid];
  403. Debug.Assert(r!=null);
  404. return r;
  405. }
  406. public CommandResult Exec(CID cid) {
  407. Command cmd = Get(cid);
  408. Debug.Assert(cmd!=null);
  409. return cmd.Exec();
  410. }
  411. public CommandResult Exec(Keys key) {
  412. Command cmd = _keyToCommand[key] as Command;
  413. CID cid;
  414. if(cmd!=null)
  415. return cmd.Exec();
  416. else if((cid = Env.Options.KeyConfig.Translate(key))!=CID.None) {
  417. return Exec(cid);
  418. }
  419. else if(Keys.D0 <= key && key <= Keys.D9) {
  420. CommandExec.PromptInputCode(false, (char)('0' + (key-Keys.D0)));
  421. return CommandResult.Succeeded;
  422. }
  423. else if(Keys.NumPad0 <= key && key <= Keys.NumPad9) {
  424. CommandExec.PromptInputCode(false, (char)('0' + (key-Keys.NumPad0)));
  425. return CommandResult.Succeeded;
  426. }
  427. else
  428. return CommandResult.Ignored;
  429. }
  430. public CommandResult Exec(ref Message m) {
  431. if(m.Msg==Win32.WM_KEYDOWN) {
  432. int k = m.WParam.ToInt32();
  433. return Exec((Keys)k | Control.ModifierKeys); //VKシリーズ定数と同じと仮定
  434. }
  435. else if(m.Msg==Win32.WM_MOUSEWHEEL) {
  436. return ExecMouseWheel(m.WParam.ToInt32() >> 16);
  437. }
  438. else
  439. return CommandResult.Ignored;
  440. }
  441. public CommandResult ExecMouseWheel(int delta) {
  442. CID cid;
  443. if((cid = Env.Options.KeyConfig.TranslateWheel(delta))!=CID.None) {
  444. return Exec(cid);
  445. }
  446. else
  447. return CommandResult.Ignored;
  448. }
  449. public IEnumerator Enum() {
  450. return _idArray.GetEnumerator();
  451. }
  452. public void SetKeyAssign(Command cmd, Keys newkey) {
  453. Debug.Assert(_keyToCommand[newkey]==null);
  454. _keyToCommand[cmd.Shortcut] = null;
  455. _keyToCommand[newkey] = cmd;
  456. cmd.SetChortcut(newkey);
  457. }
  458. public void SaveTo(StorageNode node) {
  459. foreach(Command cmd in _idArray) {
  460. if(cmd.Shortcut!=Keys.None)
  461. node[cmd.ID.ToString()] = Util.FormatShortcut(cmd.Shortcut);
  462. }
  463. }
  464. }
  465. internal class CommandExec {
  466. public static CommandResult ShowBrand(AbstractBrand b) {
  467. AbstractBrand old = Env.Frame.ChartCanvas.GetBrand();
  468. if(old!=null) Env.BrandHistory.Update(old);
  469. CommandResult r = ShowBrandInternal(b);
  470. return r;
  471. }
  472. private static CommandResult ShowBrandInternal(AbstractBrand b) {
  473. Env.Preference.ScaleLock = false;
  474. RefreshChart();
  475. Env.Frame.ChartCanvas.LoadBrand(b, true);
  476. KitTestDialog kittest = Env.Frame.CurrentModelessDialog as KitTestDialog;
  477. if(kittest!=null) kittest.UpdateBrandName();
  478. return CommandResult.Succeeded;
  479. }
  480. public static CommandResult Back(int step) {
  481. if(!Env.BrandHistory.HasBack) return CommandResult.Ignored;
  482. AbstractBrand b = Env.BrandHistory.Back(Env.Frame.ChartCanvas.GetBrand(), step);
  483. return ShowBrandInternal(b);
  484. }
  485. public static CommandResult Front(int step) {
  486. if(!Env.BrandHistory.HasFront) return CommandResult.Ignored;
  487. AbstractBrand b = Env.BrandHistory.Redo(Env.Frame.ChartCanvas.GetBrand(), step);
  488. return ShowBrandInternal(b);
  489. }
  490. public static CommandResult ClearFreeLines() {
  491. Env.FreeLines.Clear(Env.Frame.ChartCanvas.GetBrand(), Env.CurrentIndicators.Format, Env.Preference.LogScale);
  492. Env.Frame.ChartCanvas.DrawingEngine.ClearScale();
  493. Env.Frame.ChartCanvas.Invalidate();
  494. return CommandResult.Succeeded;
  495. }
  496. public static CommandResult ShowDownloadDialog() {
  497. return ShowDownloadDialog(null);
  498. }
  499. public static CommandResult ShowDownloadDialog(DownloadOrder order) {
  500. MainFrame f = Env.Frame;
  501. //!!ModelessDialog機構はまだ未完成
  502. DownloadDialog dlg = new DownloadDialog(order);
  503. #if PRIVATE_FEATURE //自分専用:ダウンロードしたら即hottestでスクリーニング
  504. if(Control.ModifierKeys==Keys.Control) {
  505. dlg.RunScreeningNow = true;
  506. dlg.Text = "自分専用ダウンロード 即スクリーニング";
  507. }
  508. #endif
  509. dlg.Owner = f;
  510. Rectangle rc = f.DesktopBounds;
  511. dlg.Left = (rc.Left + rc.Right)/2 - dlg.Width/2;
  512. dlg.Top = (rc.Top + rc.Bottom)/2 - dlg.Height/2;
  513. //f.CurrentModelessDialog = dlg;
  514. dlg.Show();
  515. return CommandResult.Succeeded;
  516. }
  517. public static CommandResult ShowInitializeDialog() {
  518. InitializeData dlg = new InitializeData();
  519. if(dlg.ShowDialog(Env.Frame)==DialogResult.OK) {
  520. return RefreshChart();
  521. }
  522. else
  523. return CommandResult.Failed;
  524. }
  525. private static CodeInput _codeInput;
  526. public static void PromptInputCode(bool fromMenu, char ch) {
  527. if(_codeInput==null) _codeInput = new CodeInput(); //2回目から再利用
  528. if(!fromMenu) _codeInput.StockCode = (int)(ch - '0');
  529. if(_codeInput.ShowDialog(Env.Frame)==DialogResult.OK) {
  530. AbstractBrand br = Env.BrandCollection.FindBrand(_codeInput.StockCode);
  531. if(br!=null)
  532. ShowBrand(br);
  533. if(fromMenu)
  534. Util.Information(Env.Frame, "このメニューを使うかわりに、通常の画面で4桁の数値を打ち込めば銘柄を指定することができます。");
  535. }
  536. }
  537. public static CommandResult ShowPrintDialog() {
  538. new PrintSupport().ShowPrintDialog();
  539. return CommandResult.Succeeded;
  540. }
  541. public static CommandResult ShowCustomizeDialog() {
  542. CustomizeDialog dlg = new CustomizeDialog();
  543. if(dlg.ShowDialog(Env.Frame)==DialogResult.OK) {
  544. RefreshChart(null);
  545. }
  546. return CommandResult.Succeeded;
  547. }
  548. public static CommandResult ExportBrand() {
  549. ExportDialog dlg = new ExportDialog();
  550. dlg.ShowDialog(Env.Frame);
  551. return CommandResult.Succeeded;
  552. }
  553. public static CommandResult ShowScreeningDialog() {
  554. if(Env.Frame.CurrentModelessDialog!=null) {
  555. Util.Warning(Env.Frame, "現在ダウンロードを実行中のため、スクリーニングはできません。");
  556. return CommandResult.Succeeded;
  557. }
  558. ScreeningDialog dlg = new ScreeningDialog();
  559. if(dlg.ShowDialog(Env.Frame)==DialogResult.OK) {
  560. if(dlg.ScreeningOrder.Result!=null) {
  561. if(dlg.ScreeningOrder.Result.ResultCount > 0) {
  562. ScreeningResultPane pane = new ScreeningResultPane(dlg.ScreeningOrder);
  563. AddDockingPane(pane, dlg.ScreeningOrder.Name, pane.RequiredWidth, IconConst.SEARCH);
  564. Env.LastScreeningResult = dlg.ScreeningOrder.Result;
  565. }
  566. }
  567. }
  568. return CommandResult.Succeeded;
  569. }
  570. public static CommandResult ShowPredictionDialog() {
  571. PredictionDialog dlg = new PredictionDialog();
  572. if(dlg.ShowDialog(Env.Frame)==DialogResult.OK) {
  573. if(dlg.Result!=null) {
  574. if(dlg.Result.HitCount==0) {
  575. Util.Warning(Env.Frame, "条件に該当するデータはありませんでした。");
  576. }
  577. else {
  578. PredictionResultPane pane = new PredictionResultPane(dlg.Result);
  579. AddDockingPane(pane, dlg.Result.Item.Title, pane.RequiredWidth, IconConst.COPY);
  580. }
  581. }
  582. }
  583. return CommandResult.Succeeded;
  584. }
  585. public static CommandResult ShowAutoTradingDialog() {
  586. AutoTradingDialog dlg = new AutoTradingDialog();
  587. if(dlg.ShowDialog(Env.Frame)==DialogResult.OK) {
  588. if(dlg.Result!=null) {
  589. AutoTradingResultPane pane = new AutoTradingResultPane(dlg.Result);
  590. AddDockingPane(pane, dlg.Result.Item.Title, pane.RequiredWidth, IconConst.COPY);
  591. }
  592. }
  593. return CommandResult.Succeeded;
  594. }
  595. private static Content AddDockingPane(Control content, string title, int width, int imgindex) {
  596. DockingManager m = Env.Frame.DockingManager;
  597. WindowContentTabbed wc = FindTabControl(m, State.DockLeft);
  598. Content c;
  599. if(wc==null) {
  600. c = m.Contents.Add(content, title);
  601. c.DisplaySize = new Size(width+16,500);
  602. c.FloatingSize = new Size(width+16,500);
  603. m.AddContentWithState(c, State.DockLeft);
  604. }
  605. else {
  606. c = m.Contents.Add(content, title);
  607. //通常のタブがあればそこに追加
  608. if(wc.TabControl.HideTabsMode==TabControl.HideTabsModes.HideUsingLogic)
  609. m.AddContentToWindowContent(c, wc);
  610. c.BringToFront();
  611. }
  612. c.ImageList = Env.ImageList16;
  613. c.ImageIndex = imgindex;
  614. return c;
  615. }
  616. private static WindowContentTabbed FindTabControl(DockingManager m, State s) {
  617. foreach(Content c in m.Contents) {
  618. WindowContentTabbed t = c.ParentWindowContent as WindowContentTabbed;
  619. if(t!=null && t.State==s) return t;
  620. }
  621. return null;
  622. }
  623. public static CommandResult ShowAddBookmarkDialog() {
  624. SelectBookmarkFolder dlg = new SelectBookmarkFolder();
  625. if(dlg.ShowDialog(Env.Frame)==DialogResult.OK) {
  626. AbstractBrand br = Env.Frame.ChartCanvas.GetBrand();
  627. if(dlg.ResultFolder.ContainsCode(br.Code,false))
  628. Util.Warning(Env.Frame, "既に同じ銘柄が登録されています。");
  629. else{
  630. Content cnt = Env.Frame.BookmarkPaneContent;
  631. if(cnt!=null && !cnt.Visible)
  632. ShowBookmarkPane(true);
  633. dlg.ResultFolder.AddChild(new BrandBookmark(dlg.ResultFolder,br.Code),null);
  634. }
  635. }
  636. return CommandResult.Succeeded;
  637. }
  638. public static CommandResult ShowBookmarkPane(bool show) {
  639. if(show) {
  640. foreach(Content content in Env.Frame.DockingManager.Contents) {
  641. if(content.Control is BookmarkPane) {
  642. content.BringToFront();
  643. return CommandResult.Failed;
  644. }
  645. }
  646. BookmarkPane pane = new BookmarkPane();
  647. Env.Frame.BookmarkPaneContent = AddDockingPane(pane, "お気に入り", 150, IconConst.STAR);
  648. }
  649. else {
  650. foreach(Content content in Env.Frame.DockingManager.Contents) {
  651. if(content.Control is BookmarkPane) {
  652. Env.Frame.DockingManager.Contents.Remove(content);
  653. return CommandResult.Failed;
  654. }
  655. }
  656. //Env.Frame.DockingManager.Contents.Remove(Env.Frame.BookmarkPaneContent);
  657. //Env.Frame.BookmarkPaneContent = null;
  658. //Env.Frame.DockingManager.HideContent(Env.Frame.BookmarkPaneContent);
  659. }
  660. return CommandResult.Succeeded;
  661. }
  662. public static CommandResult SetSplitAdjuster(bool adjust) {
  663. Env.BrandCollection.ClearAllFarms();
  664. Env.Preference.AdjustSplit = adjust;
  665. return ResetLayout();
  666. }
  667. public static CommandResult SetScaleLock(bool lock_) {
  668. Env.BrandCollection.ClearAllFarms();
  669. Env.Preference.ScaleLock = lock_;
  670. return ResetLayout();
  671. }
  672. public static CommandResult SetPriceEnabled(bool value) {
  673. Env.Preference.ShowPrice = value;
  674. return ResetLayout();
  675. }
  676. public static CommandResult SetAccumulativeVolumeEnabled(bool value) {
  677. Env.Preference.ShowAccumulativeVolume = value;
  678. return ResetLayout();
  679. }
  680. //!!Keysを使うのはやめたいところ
  681. public static CommandResult JumpDate(Keys key) {
  682. DataFarm farm = Env.Frame.ChartCanvas.GetBrand().ReserveFarm();
  683. if(farm.IsEmpty) return CommandResult.Failed;
  684. int limit = farm.TotalLength;
  685. int w = Env.Layout.DisplayColumnCount;
  686. int n = Env.Frame.ChartCanvas.FirstDateIndex;
  687. int cursor = n;
  688. switch(key) {
  689. case Keys.Home:
  690. n = 0;
  691. cursor = n;
  692. break;
  693. case Keys.End:
  694. n = limit - w;
  695. if(n<0) n = 0;
  696. cursor = limit-1;
  697. break;
  698. case Keys.PageUp:
  699. n -= w;
  700. if(n<0) n = 0;
  701. cursor = n;
  702. break;
  703. case Keys.PageDown:
  704. n += w;
  705. if(n > limit-w) n = limit-w;
  706. if(n < 0) n = 0;
  707. cursor = n + w - 1;
  708. break;
  709. case Keys.Left:
  710. n -= 5;
  711. if(n < 0) n=0;
  712. cursor = n;
  713. break;
  714. case Keys.Right:
  715. n += 5;
  716. if(n > limit-w) n = limit-w;
  717. if(n < 0) n = 0;
  718. cursor = n + w - 1;
  719. break;
  720. }
  721. Env.Frame.ChartCanvas.SetDateIndex(n, cursor);
  722. return CommandResult.Succeeded;
  723. }
  724. public static CommandResult OpenWeb() {
  725. try {
  726. Process.Start("http://www.omegachart.org/");
  727. }
  728. catch(Exception) {
  729. }
  730. return CommandResult.Succeeded;
  731. }
  732. public static CommandResult AboutBox() {
  733. AboutBox dlg = new AboutBox();
  734. dlg.ShowDialog(Env.Frame);
  735. return CommandResult.Succeeded;
  736. }
  737. public static CommandResult ShowExtensionKitDialog() {
  738. ExtensionKitListDialog dlg = new ExtensionKitListDialog();
  739. if(dlg.ShowDialog(Env.Frame)==DialogResult.OK) {
  740. Env.SaveEnv();
  741. Reload(null);
  742. }
  743. return CommandResult.Succeeded;
  744. }
  745. public static CommandResult ShowKeyConfigDialog() {
  746. KeyConfigDialog dlg = new KeyConfigDialog();
  747. dlg.ShowDialog(Env.Frame);
  748. return CommandResult.Succeeded;
  749. }
  750. public static CommandResult ShowEnvironmentDialog() {
  751. EnvironmentDialog dlg = new EnvironmentDialog();
  752. dlg.ShowDialog(Env.Frame);
  753. return CommandResult.Succeeded;
  754. }
  755. public static CommandResult ShowKitTestDialog() {
  756. KitTestDialog dlg = Env.KitTestDialog;
  757. if(dlg==null) {
  758. dlg = new KitTestDialog();
  759. Rectangle rc = Env.Frame.DesktopBounds;
  760. dlg.Left = (rc.Left + rc.Right)/2 - dlg.Width/2;
  761. dlg.Top = (rc.Top + rc.Bottom)/2 - dlg.Height/2;
  762. }
  763. if(dlg.Visible) return CommandResult.Ignored;
  764. Env.Frame.CurrentModelessDialog = dlg;
  765. dlg.Owner = Env.Frame;
  766. dlg.Show();
  767. return CommandResult.Succeeded;
  768. }
  769. public static CommandResult ShowSearchBrandDialog() {
  770. SearchBrandDialog dlg = new SearchBrandDialog();
  771. dlg.ShowDialog(Env.Frame);
  772. return CommandResult.Succeeded;
  773. }
  774. //IndicatorSetの再構築と再表示
  775. public static CommandResult RefreshChart() {
  776. RefreshChart(null);
  777. return CommandResult.Succeeded;
  778. }
  779. public static CommandResult RefreshChart(IIndicatorCustomizer ic) {
  780. Env.Frame.Cursor = Cursors.WaitCursor;
  781. ChartCanvas cnv = Env.Frame.ChartCanvas;
  782. AbstractBrand br = cnv.GetBrand();
  783. ChartFormat format= Env.Options.ChartFormat;
  784. #if DOJIMA
  785. //派生銘柄時の半日足は許可しない 原理的にはできるはずだが
  786. if(br is DerivedBrand && format==ChartFormat.HalfDaily)
  787. format = ChartFormat.Daily;
  788. #endif
  789. Env.BrandCollection.ClearAllFarms();
  790. Env.Preference.Refresh();
  791. IndicatorSetBuilder bld = new IndicatorSetBuilder();
  792. bld.Customizer = ic;
  793. bld.Construct(Env.Options.ChartFormat);
  794. Env.CurrentIndicators = bld.Result;
  795. cnv.ReloadFromPreference();
  796. cnv.LoadBrand(br, false);
  797. ResetLayout();
  798. Env.Frame.Cursor = Cursors.Default;
  799. return CommandResult.Succeeded;
  800. }
  801. public static CommandResult ResetLayout() {
  802. Env.Layout.Init();
  803. Env.Frame.ChartCanvas.ResetLayout();
  804. Env.Frame.Invalidate(true);
  805. return CommandResult.Succeeded;
  806. }
  807. public static CommandResult Reload(IIndicatorCustomizer ic) {
  808. Env.ReloadSchema();
  809. RefreshChart(ic);
  810. //Util.Information(Env.Frame, "リロードしました");
  811. return CommandResult.Succeeded;
  812. }
  813. public static CommandResult Quit() {
  814. Env.Frame.Close();
  815. return CommandResult.Succeeded;
  816. }
  817. //署名関係
  818. public static CommandResult CreateKey() {
  819. RSAKeyPair kp = RSAKeyPair.GenerateNew(256, new Random());
  820. //PrivateKey保存
  821. StreamWriter wr = new StreamWriter(Env.GetAppDir()+"privatekey.txt");
  822. wr.WriteLine(kp.D.ToHexString());
  823. wr.WriteLine(kp.P.ToHexString());
  824. wr.WriteLine(kp.Q.ToHexString());
  825. wr.WriteLine(kp.U.ToHexString());
  826. wr.Close();
  827. //PublicKeyダンプ
  828. RSAPublicKey pub = (RSAPublicKey)kp.PublicKey;
  829. Debug.WriteLine("Pubkey-Mod="+pub.Modulus.ToHexString());
  830. Debug.WriteLine("Pubkey-Exp="+pub.Exponent.ToHexString());
  831. return CommandResult.Succeeded;
  832. }
  833. public static CommandResult SignKit() {
  834. OpenFileDialog dlg = new OpenFileDialog();
  835. dlg.Title = "XMLフォーマットの拡張キット選択";
  836. if(dlg.ShowDialog(Env.Frame)==DialogResult.OK) {
  837. string fn = dlg.FileName;
  838. StorageNode node = new DOMNodeReader(XmlUtil.LoadDOM(fn)).Read();
  839. Stream strm = new FileStream(fn+".bin", FileMode.Create, FileAccess.Write);
  840. new BinaryNodeWriter(strm).Write(node);
  841. strm.Close();
  842. SignFile(fn+".bin", fn+".signed");
  843. }
  844. return CommandResult.Succeeded;
  845. }
  846. public static CommandResult SignFile(string fn, string destfile) {
  847. StreamReader re = new StreamReader(Env.GetAppDir()+"privatekey.txt");
  848. BigInteger d = new BigInteger(re.ReadLine(), 16);
  849. BigInteger p = new BigInteger(re.ReadLine(), 16);
  850. BigInteger q = new BigInteger(re.ReadLine(), 16);
  851. BigInteger u = new BigInteger(re.ReadLine(), 16);
  852. RSAPublicKey pub = ZPublicKey.PubKeyForExtensionKit;
  853. RSAKeyPair kp = new RSAKeyPair(pub.Exponent, d, pub.Modulus, u, p, q);
  854. byte[] data = new byte[(int)new FileInfo(fn).Length];
  855. FileStream s = new FileStream(fn, FileMode.Open, FileAccess.Read);
  856. s.Read(data, 0, data.Length);
  857. s.Close();
  858. Debug.WriteLine("Signed length="+data.Length);
  859. byte[] hash = new SHA1CryptoServiceProvider().ComputeHash(data, 0, data.Length);
  860. byte[] signature = kp.Sign(hash);
  861. kp.Verify(signature, hash);
  862. Stream strm = new FileStream(destfile, FileMode.Create, FileAccess.Write);
  863. strm.Write(data, 0, data.Length);
  864. strm.Write(signature, 0, signature.Length);
  865. strm.Close();
  866. return CommandResult.Succeeded;
  867. }
  868. public static CommandResult GenerateUserCode() {
  869. RegistrationDialog dlg = new RegistrationDialog();
  870. dlg.GeneratingCode = true;
  871. dlg.ShowDialog(Env.Frame);
  872. return CommandResult.Succeeded;
  873. }
  874. public static CommandResult RegisterUserCode() {
  875. RegistrationDialog dlg = new RegistrationDialog();
  876. dlg.GeneratingCode = false;
  877. dlg.ShowDialog(Env.Frame);
  878. return CommandResult.Succeeded;
  879. }
  880. public static CommandResult OpenCompanyInfoPage(CompanyInfoSite type) {
  881. try {
  882. string url = null;
  883. int code = Env.Frame.ChartCanvas.GetBrand().Code;
  884. switch(type) {
  885. case CompanyInfoSite.Yahoo:
  886. url = String.Format("http://profile.yahoo.co.jp/biz/fundamental/{0}.html", code);
  887. break;
  888. case CompanyInfoSite.Infoseek:
  889. url = String.Format("http://money.www.infoseek.co.jp/MnStock?qt={0}&sv=MN&pg=mn_creport.html", code);
  890. break;
  891. case CompanyInfoSite.Nikkei:
  892. url = String.Format("http://company.nikkei.co.jp/index.cfm?scode={0}", code);
  893. break;
  894. case CompanyInfoSite.Livedoor:
  895. url = String.Format("http://finance.livedoor.com/quote/profile?c={0}", code);
  896. break;
  897. }
  898. Process.Start(url);
  899. return CommandResult.Succeeded;
  900. }
  901. catch(Exception ex) {
  902. Util.ReportCriticalError(ex);
  903. return CommandResult.Failed;
  904. }
  905. }
  906. //!!このあたりのペアはdelegateを使うなどしてまとめたい
  907. public static CommandResult ShowNextCode(){
  908. AbstractBrand br = Env.BrandCollection.FindNextBrand(
  909. Env.Frame.ChartCanvas.GetBrand().Code);
  910. ShowBrand(br);
  911. return CommandResult.Succeeded;
  912. }
  913. public static CommandResult ShowPrevCode() {
  914. AbstractBrand br = Env.BrandCollection.FindPrevBrand(
  915. Env.Frame.ChartCanvas.GetBrand().Code);
  916. ShowBrand(br);
  917. return CommandResult.Succeeded;
  918. }
  919. public static CommandResult ShowNextBrand(){
  920. BrandListPane pane = Env.Frame.CurrentBrandListPane;
  921. if(pane!=null) {
  922. AbstractBrand br = pane.NextBrand;
  923. if(br!=null)
  924. return ShowBrand(br);
  925. else
  926. return CommandResult.Failed;
  927. }
  928. return CommandResult.Ignored;
  929. }
  930. public static CommandResult ShowPrevBrand() {
  931. BrandListPane pane = Env.Frame.CurrentBrandListPane;
  932. if(pane!=null) {
  933. AbstractBrand br = pane.PrevBrand;
  934. if(br!=null)
  935. return ShowBrand(br);
  936. else
  937. return CommandResult.Failed;
  938. }
  939. return CommandResult.Ignored;
  940. }
  941. public static CommandResult ShrinkCandleWidth() {
  942. int hcw = Env.Preference.HalfCandleWidth;
  943. if(--hcw < 1) {
  944. hcw = 1;
  945. }
  946. Env.Preference.CandleWidth = hcw * 2;
  947. ResetLayout();
  948. return CommandResult.Succeeded;
  949. }
  950. public static CommandResult ExpandCandleWidth(){
  951. int hcw = Env.Preference.HalfCandleWidth;
  952. if(++hcw > 20) { // 特に意味なし
  953. hcw = 20;
  954. }
  955. Env.Preference.CandleWidth = hcw * 2;
  956. ResetLayout();
  957. return CommandResult.Succeeded;
  958. }
  959. public static CommandResult SetCandleWidth(int width) {
  960. Env.Preference.CandleWidth = width;
  961. ResetLayout();
  962. return CommandResult.Succeeded;
  963. }
  964. public static CommandResult SetLogarithmStyle(bool value){
  965. Env.Preference.LogScale = value;
  966. ResetLayout();
  967. return CommandResult.Succeeded;
  968. }
  969. public static CommandResult SetInverseStyle(bool value){
  970. Env.Preference.InverseChart = value;
  971. ResetLayout();
  972. return CommandResult.Succeeded;
  973. }
  974. public static CommandResult SetChartFormat(ChartFormat fmt) {
  975. if(Env.Options.ChartFormat==fmt) return CommandResult.Ignored;
  976. Env.Options.ChartFormat = fmt;
  977. RefreshChart();
  978. return CommandResult.Succeeded;
  979. }
  980. public static CommandResult UpdateCurrentData() {
  981. #if KENMILLE
  982. Env.Frame.ChartCanvas.ChartTitle.UpdateCurrentBrand();
  983. return CommandResult.Succeeded;
  984. #else
  985. return CommandResult.Failed;
  986. #endif
  987. }
  988. public static CommandResult DownloadIndexFile() {
  989. MemoryStream ns = null;
  990. try {
  991. ns = Util.HttpDownload("http://protra.sourceforge.jp/data/index.txt");
  992. int dt = BrandCollection.GuessDate(ns);
  993. ns.Position = 0;
  994. if(dt > Env.BrandCollection.LastUpdatedDate) {
  995. Util.Information(Env.Frame, "新しいインデックスファイルが見つかりました。反映させるにはOmegaChartの再起動が必要です。");
  996. Util.StreamToFile(ns, Env.GetAppDir() + "index.txt");
  997. return CommandResult.Succeeded;
  998. }
  999. else {
  1000. Util.Information(Env.Frame, "新しいインデックスファイルはありません。");
  1001. return CommandResult.Ignored;
  1002. }
  1003. }
  1004. catch(Exception ex) {
  1005. Util.ReportCriticalError(ex);
  1006. return CommandResult.Failed;
  1007. }
  1008. finally {
  1009. if(ns!=null) ns.Close();
  1010. }
  1011. }
  1012. #if DOJIMA
  1013. public static CommandResult ExportHalfDailyData() {
  1014. if(Env.CurrentIndicators.Format!=ChartFormat.HalfDaily) {
  1015. Util.Warning("半日足を表示した状態でのみエクスポートできます");
  1016. return CommandResult.Failed;
  1017. }
  1018. SaveFileDialog dlg = new SaveFileDialog();
  1019. dlg.Title = "半日足データのエクスポート";
  1020. dlg.Filter = "CSV Files(*.csv)|*.csv";
  1021. dlg.DefaultExt = "csv";
  1022. if(dlg.ShowDialog(Env.Frame)==DialogResult.OK) {
  1023. string filename = dlg.FileName;
  1024. DailyDataFarm f = (DailyDataFarm)Env.Frame.ChartCanvas.GetBrand().ReserveFarm();
  1025. Dojima.DojimaUtil.HalfDailyDataFarmCache.Get(f).ExportInCSV(filename);
  1026. return CommandResult.Succeeded;
  1027. }
  1028. else
  1029. return CommandResult.Ignored;
  1030. }
  1031. #endif
  1032. //初期データの縮小
  1033. public static CommandResult ShrinkData() {
  1034. Env.Frame.Text = "データ縮小中";
  1035. int date = 20050701; //ここ以降の日付のみ切り出す
  1036. string dir = "shrinked";
  1037. if(!Directory.Exists(dir))
  1038. Directory.CreateDirectory("shrinked");
  1039. IDictionaryEnumerator ie = Env.BrandCollection.GetEnumerator();
  1040. while(ie.MoveNext()) {
  1041. BasicBrand br = ie.Value as BasicBrand;
  1042. if(br!=null) {
  1043. DailyDataFarm f = new DailyDataFarm();
  1044. f.LoadFor(br);
  1045. if(!f.IsEmpty) {
  1046. int index = f.DateToIndex(date);
  1047. FileStream fs = new FileStream(dir + "\\" + br.CodeAsString, FileMode.Create, FileAccess.Write);
  1048. fs.Write(f.RawDataImage, index*DataFarm.RECORD_LENGTH, (f.TotalLength-index)*DataFarm.RECORD_LENGTH);
  1049. fs.Close();
  1050. }
  1051. }
  1052. }
  1053. Util.Information(Env.Frame, "終了");
  1054. return CommandResult.Succeeded;
  1055. }
  1056. //試作:統計情報
  1057. public static CommandResult StatisticsTest() {
  1058. //RunPrivateScreening();
  1059. //MyStatistics.Do();
  1060. return CommandResult.Succeeded;
  1061. }
  1062. #if PRIVATE_FEATURE
  1063. public static void RunPrivateScreening() {
  1064. ScreeningItem item = FindScreeningItem("hottest");
  1065. ScreeningOrder so = new ScreeningOrder(item.Header, item);
  1066. so.Execute();
  1067. ScreeningResult sr = so.Result as ScreeningResult; //!!asがいやらしい
  1068. Util.Information(Env.Frame, "完了");
  1069. if(sr.ResultCount > 0) {
  1070. ScreeningResultPane pane = new ScreeningResultPane(so);
  1071. AddDockingPane(pane, item.Header, pane.RequiredWidth, IconConst.SEARCH);
  1072. }
  1073. }
  1074. private static ScreeningItem FindScreeningItem(string name) {
  1075. foreach(ScreeningItem item in Env.CurrentIndicators.GetScreeningItems()) {
  1076. if(item.Header=="要注意銘柄") return item;
  1077. }
  1078. return null;
  1079. }
  1080. #endif
  1081. }
  1082. }
Download Printable view

URL of this paste

Embed with JavaScript

Embed with iframe

Raw text