• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

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

OmegaChartのソースコードの保守


コミットメタ情報

リビジョン4a19d2e38eceb83051bcd3431dce63ce3c28d7cd (tree)
日時2014-04-29 16:45:05
作者panacoran <panacoran@user...>
コミッターpanacoran

ログメッセージ

日付の制約を取り除く

https://sourceforge.jp/users/panacoran/pastebin/910
の指摘に基づいてDatePickerの最大最小の設定を外した。
週足のロジックを変更して日付の制約がないものにした。

変更サマリ

差分

--- a/AutoTradingDialog.cs
+++ b/AutoTradingDialog.cs
@@ -264,7 +264,6 @@ namespace Zanetti.Forms {
264264 //
265265 this._startDatePicker.Checked = false;
266266 this._startDatePicker.Location = new System.Drawing.Point(80, 16);
267- this._startDatePicker.MinDate = new System.DateTime(1996, 1, 1, 0, 0, 0, 0);
268267 this._startDatePicker.Name = "_startDatePicker";
269268 this._startDatePicker.Size = new System.Drawing.Size(200, 19);
270269 this._startDatePicker.TabIndex = 1;
@@ -282,8 +281,6 @@ namespace Zanetti.Forms {
282281 // _endDatePicker
283282 //
284283 this._endDatePicker.Location = new System.Drawing.Point(80, 40);
285- this._endDatePicker.MaxDate = new System.DateTime(2010, 12, 31, 0, 0, 0, 0);
286- this._endDatePicker.MinDate = new System.DateTime(1996, 1, 1, 0, 0, 0, 0);
287284 this._endDatePicker.Name = "_endDatePicker";
288285 this._endDatePicker.Size = new System.Drawing.Size(200, 19);
289286 this._endDatePicker.TabIndex = 3;
--- a/Data.cs
+++ b/Data.cs
@@ -3,6 +3,10 @@
33 *
44 * $Id$
55 */
6+// Copyright (c) 2014 panacoran <panacoran@users.sourceforge.jp>
7+// This program is part of OmegaChart.
8+// OmegaChart is licensed under the Apache License, Version 2.0.
9+
610 using System;
711 using System.IO;
812 using System.Collections;
@@ -353,26 +357,28 @@ namespace Zanetti.Data
353357 _isEmpty = false;
354358 _firstDate= GetInt(daily, 0);
355359 _lastDate = GetInt(daily, daily.Length-RECORD_LENGTH);
356- WeeklyIndex weekly_begin = Env.WeekFormat.FindByDate(GetInt(daily, 0));
357- WeeklyIndex weekly_end = Env.WeekFormat.FindByDate(GetInt(daily, daily.Length-RECORD_LENGTH));
358- _filledLength = weekly_end.Index+1 - weekly_begin.Index;
360+ var daily_begin = Util.IntToDate(GetInt(daily, 0));
361+ var weekly_begin = daily_begin.AddDays(-(int)daily_begin.DayOfWeek);
362+ var daily_end = Util.IntToDate(GetInt(daily, daily.Length - RECORD_LENGTH));
363+ var weekly_end = daily_end.AddDays(-(int)daily_end.DayOfWeek);
364+ _filledLength = (int)(weekly_end - weekly_begin).TotalDays / 7 + 1;
359365 _data = new TradeData[_filledLength + Env.CurrentIndicators.GetAddedFutureLength(ChartFormat.Weekly)];
360366
361367 //byte[]部分のデータ読み
362368 _farm = new byte[_data.Length * RECORD_LENGTH];
363369 _byteLength = _farm.Length;
364370 int offset = 0;
365- for(int i=weekly_begin.Index; i<=weekly_end.Index; i++) {
366- WeeklyIndex wi = Env.WeekFormat.GetAt(i);
367- offset = FillWeeklyData((i-weekly_begin.Index)*RECORD_LENGTH, daily, offset, wi);
371+ var weekly = weekly_begin;
372+ for(int i=0; i < _filledLength; i++, weekly = weekly.AddDays(7)) {
373+ offset = FillWeeklyData(i*RECORD_LENGTH, daily, offset, Util.DateToInt(weekly));
368374 if(offset>=daily.Length) break;
369375 }
370376 }
371377 }
372378 }
373- private int FillWeeklyData(int farmoffset, byte[] daily, int offset, WeeklyIndex wi) {
379+ private int FillWeeklyData(int farmoffset, byte[] daily, int offset, int firstdate) {
374380
375- int enddate = Env.WeekFormat.Length>wi.Index+1? Env.WeekFormat.GetAt(wi.Index+1).FirstDate : Util.DateToInt(Util.IntToDate(wi.FirstDate).AddDays(7));
381+ int enddate = Util.DateToInt(Util.IntToDate(firstdate).AddDays(7));
376382
377383 int vol = 0, high = Int32.MinValue, low = Int32.MaxValue;
378384 int open = 0, close = 0, cre_long = 0, cre_short = 0;
@@ -384,7 +390,7 @@ namespace Zanetti.Data
384390 // で、後に式を評価する際に用いられる基準日として日曜基準で 'wi.FirstDate' を使っているのだから、
385391 // ここでもこの値を使うべき。 2005/3/15 T. SARUKI
386392 //
387- double base_split = this.CalcSplitRatio(wi.FirstDate); //分割を考慮する場合は期間内の調整が要る
393+ double base_split = this.CalcSplitRatio(firstdate); //分割を考慮する場合は期間内の調整が要る
388394 while(offset<=daily.Length-RECORD_LENGTH && today<enddate) {
389395 //if(!is_index && today>20031201) Debugger.Break();
390396 double split = Env.Preference.AdjustSplit? this.CalcSplitRatio(today) / base_split : 1;
@@ -403,7 +409,7 @@ namespace Zanetti.Data
403409 if(offset<daily.Length) today = GetInt(daily, offset);
404410 }
405411
406- SetInt(_farm, farmoffset, wi.FirstDate);
412+ SetInt(_farm, farmoffset, firstdate);
407413 SetInt(_farm, farmoffset+OPEN_OFFSET, open);
408414 SetInt(_farm, farmoffset+HIGH_OFFSET, high);
409415 SetInt(_farm, farmoffset+LOW_OFFSET, low);
--- a/Env.cs
+++ b/Env.cs
@@ -43,7 +43,6 @@ namespace Zanetti
4343 private static CommandCollection _command;
4444 private static BrandHistory _history;
4545 private static StorageNode _rootStorageNode;
46- private static WeekFormat _weekFormat;
4746 private static ImageList _imageList16;
4847
4948 public static Preference Preference {
@@ -118,12 +117,6 @@ namespace Zanetti
118117 return _freeLines;
119118 }
120119 }
121- public static WeekFormat WeekFormat {
122- get {
123- return _weekFormat;
124- }
125- }
126-
127120 //パース済み設定ファイルのルート ネーミングはちとおかしいが
128121 public static StorageNode RootStorageNode {
129122 get {
@@ -167,7 +160,6 @@ namespace Zanetti
167160 _options = new Options();
168161 _bookmark = new Bookmark();
169162 _freeLines = new FreeLineCollection();
170- _weekFormat = new WeekFormat();
171163 _history = new BrandHistory();
172164 InitialAction act = new InitialAction();
173165
--- a/ScreeningDialog.cs
+++ b/ScreeningDialog.cs
@@ -276,7 +276,6 @@ namespace Zanetti.Forms
276276 //
277277 this._datePicker.Checked = false;
278278 this._datePicker.Location = new System.Drawing.Point(16, 16);
279- this._datePicker.MinDate = new System.DateTime(1996, 1, 1, 0, 0, 0, 0);
280279 this._datePicker.Name = "_datePicker";
281280 this._datePicker.Size = new System.Drawing.Size(200, 19);
282281 this._datePicker.TabIndex = 12;
--- a/Weekly.cs
+++ /dev/null
@@ -1,95 +0,0 @@
1-/*
2- * Copyright (c) Daisuke OKAJIMA All rights reserved.
3- *
4- * $Id$
5- */
6-using System;
7-using System.Diagnostics;
8-using System.Collections;
9-
10-namespace Zanetti.Data
11-{
12- //毎週月曜からの見出し項目
13- internal class WeeklyIndex
14- {
15- private int _index;
16- private int _firstDate;
17- private bool _startOfQuarter;
18-
19- public int FirstDate {
20- get {
21- return _firstDate;
22- }
23- }
24- public int Index {
25- get {
26- return _index;
27- }
28- }
29- public bool StartOfQuarter {
30- get {
31- return _startOfQuarter;
32- }
33- }
34-
35- public WeeklyIndex(int index, int firstdate, bool quarter) {
36- _index = index;
37- _firstDate = firstdate;
38- _startOfQuarter = quarter;
39- }
40- }
41-
42- //毎週月曜のコレクション
43- internal class WeekFormat {
44- private WeeklyIndex[] _data;
45-
46- private void Construct() {
47- DateTime dt = new DateTime(1987,12,27); //こいつは日曜日
48- ArrayList t = new ArrayList(500);
49- DateTime now = DateTime.Now;
50- int i = 0;
51- while(dt < now) {
52- int dti = Util.DateToInt(dt);
53- int m = (dti % 10000) / 100;
54- int d = dti % 100;
55- t.Add(new WeeklyIndex(i++, dti, d<=7 && (m==1 || m==4 || m==7 || m==10)));
56- dt = dt.AddDays(7);
57- }
58-
59- _data = (WeeklyIndex[])t.ToArray(typeof(WeeklyIndex));
60- }
61-
62- public WeeklyIndex FindByDate(int date) {
63- if(_data==null) Construct();
64- if(date<_data[1].FirstDate)
65- return _data[0]; //両端はよくあるケースなので
66- else if(date>=_data[_data.Length-1].FirstDate)
67- return _data[_data.Length-1];
68- else
69- return FindByDate(date, 0, _data.Length);
70- }
71- private WeeklyIndex FindByDate(int date, int start, int end) {
72- int m = (start+end)/2;
73- if(_data[m].FirstDate > date)
74- return FindByDate(date, start, m);
75- else if(_data[m+1].FirstDate <= date)
76- return FindByDate(date, m+1, end);
77- else
78- return _data[m];
79- }
80-
81- public WeeklyIndex GetAt(int index) {
82- if(_data==null) Construct();
83- Debug.Assert(index>=0 && index<_data.Length);
84- return _data[index];
85- }
86- public int Length {
87- get {
88- if(_data==null) Construct();
89- return _data.Length;
90- }
91- }
92- }
93-
94-
95-}
--- a/zanetti.csproj
+++ b/zanetti.csproj
@@ -364,7 +364,6 @@
364364 <SubType>Component</SubType>
365365 </Compile>
366366 <Compile Include="Visitor.cs" />
367- <Compile Include="Weekly.cs" />
368367 <Compile Include="Win32.cs" />
369368 <Compile Include="XmlStorageRW.cs" />
370369 <Compile Include="XmlUtil.cs" />