コピペ: OmegaChart MY検索ワード Brand.cs 追加する部分には//☆MY検索ワード

形式
Plain text
投稿日時
2018-11-10 18:30
公開期間
無期限
  1. /*
  2. * Copyright (c) Daisuke OKAJIMA All rights reserved.
  3. *
  4. * $Id$
  5. */
  6. using System;
  7. using System.IO;
  8. using System.Collections;
  9. using System.Diagnostics;
  10. using System.Text;
  11. using System.Reflection;
  12. using Travis.Util;
  13. using Zanetti.Arithmetic;
  14. using Zanetti.Parser;
  15. namespace Zanetti.Data
  16. {
  17. [EnumDesc(typeof(MarketType))]
  18. internal enum MarketType
  19. {
  20. [EnumValue(Description = "指数")] B, //指数、為替など
  21. [EnumValue(Description = "東証1部")] T1,
  22. [EnumValue(Description = "東証2部")] T2,
  23. [EnumValue(Description = "大証1部")] O1,
  24. [EnumValue(Description = "大証2部")] O2,
  25. [EnumValue(Description = "JASDAQ")] J,
  26. [EnumValue(Description = "マザーズ")] M,
  27. [EnumValue(Description = "ヘラクレス")] H,
  28. [EnumValue(Description = "派生銘柄")] Custom,
  29. [EnumValue(Description = "商品")] C //当面堂島バージョンでのみ必要
  30. }
  31. [EnumDesc(typeof(BuiltInIndex))]
  32. internal enum BuiltInIndex
  33. {
  34. //国内指数
  35. [EnumValue(Description = "日経平均")] Nikkei225 = 101,
  36. [EnumValue(Description = "TOPIX")] TOPIX = 102,
  37. [EnumValue(Description = "長期金利")] LONGTERM_INTEREST = 0, //これはDreamVisorからしか取得できないのでヤメ。値をレンジ外にしている
  38. [EnumValue(Description = "JASDAQ")] JASDAQ = 106,
  39. //株価指数先物
  40. [EnumValue(Description = "日経平均先物")] Nikkei225_F = 151,
  41. [EnumValue(Description = "TOPIX先物")] TOPIX_F = 152,
  42. //為替
  43. [EnumValue(Description = "円/ドル")] JPYUSD = 201,
  44. [EnumValue(Description = "円/ユーロ")] JPYEUR = 202,
  45. //外国株式指数
  46. [EnumValue(Description = "NYダウ")] Dow = 301,
  47. [EnumValue(Description = "NASDAQ")] Nasdaq = 302,
  48. [EnumValue(Description = "SP500")] SP500 = 303,
  49. //[EnumValue(Description="FT100")] FT100 = 304, //ケンミレ事件のためこの2つはあきらめる
  50. //[EnumValue(Description="DAX30")] DAX30 = 305,
  51. //業種別
  52. [EnumValue(Description = "水産")] SI_FISHING = 501, //派生銘柄は400番台にしてしまったので
  53. [EnumValue(Description = "鉱業")] SI_MINING,
  54. [EnumValue(Description = "建設")] SI_CONSTRUCTION,
  55. [EnumValue(Description = "食品")] SI_FOOD,
  56. [EnumValue(Description = "繊維")] SI_FABRIC,
  57. [EnumValue(Description = "パルプ")] SI_PULP,
  58. [EnumValue(Description = "化学")] SI_CHEMICAL,
  59. [EnumValue(Description = "医薬")] SI_MEDICAL,
  60. [EnumValue(Description = "石油")] SI_OIL,
  61. [EnumValue(Description = "ゴム")] SI_RUBBER,
  62. [EnumValue(Description = "ガラス")] SI_CERAMIC,
  63. [EnumValue(Description = "鉄鋼")] SI_IRON,
  64. [EnumValue(Description = "非鉄")] SI_NONEMETAL,
  65. [EnumValue(Description = "金属")] SI_METAL,
  66. [EnumValue(Description = "機械")] SI_MACHINE,
  67. [EnumValue(Description = "電気")] SI_ELECTRIC,
  68. [EnumValue(Description = "輸送")] SI_FREIGHTER_MACHINE,
  69. [EnumValue(Description = "精密")] SI_PRECISIONS,
  70. [EnumValue(Description = "製造")] SI_MANIFUCTURING,
  71. [EnumValue(Description = "ガス")] SI_GAS,
  72. [EnumValue(Description = "陸運")] SI_LANDTRANSPORT,
  73. [EnumValue(Description = "海運")] SI_MARINETRANSPORT,
  74. [EnumValue(Description = "空運")] SI_AIRTRANSPORT,
  75. [EnumValue(Description = "倉庫")] SI_STORAGE,
  76. [EnumValue(Description = "情報")] SI_COMMUNICATION,
  77. [EnumValue(Description = "卸売")] SI_TRADEFARM,
  78. [EnumValue(Description = "小売")] SI_RETAIL,
  79. [EnumValue(Description = "銀行")] SI_BANK,
  80. [EnumValue(Description = "証券")] SI_SECURITY,
  81. [EnumValue(Description = "保険")] SI_INSUARANCE,
  82. [EnumValue(Description = "金融")] SI_FINANCE,
  83. [EnumValue(Description = "不動産")] SI_REALESTATES,
  84. [EnumValue(Description = "サービス")] SI_SERVICE,
  85. //600台は商品
  86. //COMMOITY_START = 600
  87. }
  88. internal enum BuiltInIndexGroup
  89. {
  90. DomesticIndexStart = BuiltInIndex.Nikkei225,
  91. DomesticIndexEnd = BuiltInIndex.TOPIX_F,
  92. ForeignIndexStart = BuiltInIndex.JPYUSD, //属性としてはほぼ一緒
  93. ForeignIndexEnd = BuiltInIndex.SP500,
  94. SectorIndexStart = BuiltInIndex.SI_FISHING,
  95. SectorIndexEnd = BuiltInIndex.SI_SERVICE
  96. }
  97. //分割情報
  98. internal class SplitInfo
  99. {
  100. private int _date;
  101. private double _ratio;
  102. public int Date
  103. {
  104. get
  105. {
  106. return _date;
  107. }
  108. }
  109. public double Ratio
  110. {
  111. get
  112. {
  113. return _ratio;
  114. }
  115. }
  116. public SplitInfo(int date, double ratio)
  117. {
  118. _date = date;
  119. _ratio = ratio;
  120. }
  121. public SplitInfo(string txt)
  122. {
  123. //S:ddd:valueからの構築
  124. string[] t = txt.Split(':');
  125. _date = Int32.Parse(t[1]);
  126. _ratio = Double.Parse(t[2]);
  127. }
  128. }
  129. //銘柄の基本情報
  130. internal abstract class AbstractBrand
  131. {
  132. protected string _name;
  133. protected int _code;
  134. protected MarketType _market;
  135. protected int _referenceValue;
  136. protected SplitInfo[] _splitInfo;
  137. public AbstractBrand(string name, int code, MarketType m)
  138. {
  139. _name = name;
  140. _code = code;
  141. _market = m;
  142. }
  143. public string Name
  144. {
  145. get
  146. {
  147. return _name;
  148. }
  149. }
  150. public int Code
  151. {
  152. get
  153. {
  154. return _code;
  155. }
  156. }
  157. public string CodeAsString
  158. {
  159. get
  160. {
  161. string t = _code.ToString();
  162. Debug.Assert(t.Length <= 4);
  163. if (t.Length < 4)
  164. {
  165. StringBuilder bld = new StringBuilder(4);
  166. for (int i = 0; i < 4 - t.Length; i++) bld.Append('0');
  167. bld.Append(t);
  168. return bld.ToString();
  169. }
  170. else
  171. return t;
  172. }
  173. }
  174. public SplitInfo[] SplitInfo
  175. {
  176. get
  177. {
  178. return _splitInfo;
  179. }
  180. set
  181. {
  182. _splitInfo = value;
  183. }
  184. }
  185. public MarketType Market
  186. {
  187. get
  188. {
  189. return _market;
  190. }
  191. }
  192. public bool IsBuiltIn
  193. {
  194. get
  195. {
  196. return _code < 1000;
  197. }
  198. }
  199. public bool IsSectorIndex
  200. {
  201. get
  202. {
  203. return (int)BuiltInIndexGroup.SectorIndexStart <= _code && _code <= (int)BuiltInIndexGroup.SectorIndexEnd;
  204. }
  205. }
  206. public bool IsDomesticIndex
  207. {
  208. get
  209. {
  210. return (int)BuiltInIndexGroup.DomesticIndexStart <= _code && _code <= (int)BuiltInIndexGroup.DomesticIndexEnd;
  211. }
  212. }
  213. public bool IsForeignIndex
  214. {
  215. get
  216. {
  217. return (int)BuiltInIndexGroup.ForeignIndexStart <= _code && _code <= (int)BuiltInIndexGroup.ForeignIndexEnd;
  218. }
  219. }
  220. public bool IsCommodity
  221. {
  222. get
  223. {
  224. //他との統一性では_codeで分類すべきだが、定数がDOJIMAディレクトリにあって面倒くさい
  225. return _market == MarketType.C;
  226. }
  227. }
  228. public bool IsIndexFuture
  229. {
  230. get
  231. {
  232. return (int)BuiltInIndex.Nikkei225_F == _code || (int)BuiltInIndex.TOPIX_F == _code;
  233. }
  234. }
  235. public virtual bool IsVolumeAvailable
  236. {
  237. get
  238. {
  239. if (!IsBuiltIn) //多くはこれだ
  240. return true;
  241. else if (IsDomesticIndex)
  242. return _code == (int)BuiltInIndex.Nikkei225 || _code == (int)BuiltInIndex.TOPIX || _code == (int)BuiltInIndex.JASDAQ ||
  243. _code == (int)BuiltInIndex.Nikkei225_F || _code == (int)BuiltInIndex.TOPIX_F;
  244. else if (this.IsForeignIndex)
  245. return _code != (int)BuiltInIndex.JPYUSD && _code != (int)BuiltInIndex.JPYEUR;
  246. else if (this.IsSectorIndex)
  247. return false;
  248. else
  249. return true;
  250. }
  251. }
  252. //保存されているデータから実数への変換に何をかければよいか
  253. public virtual double PriceScale
  254. {
  255. get
  256. {
  257. if (!IsBuiltIn) //多くはこれだ
  258. return 0.1;
  259. else if (IsDomesticIndex)
  260. {
  261. if (_code == (int)BuiltInIndex.Nikkei225_F)
  262. return 1;
  263. else if (_code == (int)BuiltInIndex.LONGTERM_INTEREST)
  264. return 0.001;
  265. else if (_code == (int)BuiltInIndex.TOPIX_F)
  266. return 0.1;
  267. else
  268. return 0.01;
  269. }
  270. else if (this.IsForeignIndex || this.IsSectorIndex)
  271. {
  272. return 0.01;
  273. }
  274. else if (IsCommodity)
  275. return 1;
  276. else
  277. return 1;
  278. }
  279. }
  280. public virtual string PriceFormatString
  281. {
  282. get
  283. {
  284. if (!IsBuiltIn) //多くはこれだ
  285. return "F1";
  286. else if (IsDomesticIndex)
  287. {
  288. if (_code == (int)BuiltInIndex.Nikkei225_F)
  289. return "F0";
  290. else if (_code == (int)BuiltInIndex.LONGTERM_INTEREST)
  291. return "F3";
  292. else
  293. return "F2";
  294. }
  295. else if (this.IsForeignIndex || this.IsSectorIndex)
  296. return "F2";
  297. else if (IsCommodity)
  298. return "F0";
  299. else
  300. return "F0";
  301. }
  302. }
  303. public int ReferenceValue
  304. {
  305. get
  306. {
  307. return _referenceValue;
  308. }
  309. set
  310. {
  311. _referenceValue = value;
  312. }
  313. }
  314. public bool HasFarm
  315. {
  316. get
  317. {
  318. return Env.BrandCollection.HasFarm(this);
  319. }
  320. }
  321. //dateの日付の1株はbasisの日に何倍になっているかを分割データから計算
  322. public double CalcSplitRatio(int date, int basis)
  323. {
  324. if (_splitInfo == null) return 1;
  325. double r = 1;
  326. for (int i = _splitInfo.Length - 1; i >= 0; i--)
  327. {
  328. SplitInfo si = _splitInfo[i];
  329. if (si.Date > basis) continue;
  330. if (date < si.Date) r *= si.Ratio;
  331. else break;
  332. }
  333. return r;
  334. }
  335. public abstract DataFarm ReserveFarm();
  336. //!!以下2つって両方必要?
  337. public abstract DataFarm CreateDailyFarm(int extra_dates);
  338. public abstract DataFarm CreateFarm(ChartFormat format);
  339. }
  340. //個別の1銘柄
  341. internal class BasicBrand : AbstractBrand
  342. {
  343. private int _unit; //単位株数 これが当てはまらない銘柄では0
  344. private bool _nikkei225;
  345. private bool _active500;
  346. private bool _obsolete; //上場廃止
  347. public BasicBrand(string name, int code, MarketType m) : base(name, code, m)
  348. {
  349. }
  350. public bool Nikkei225
  351. {
  352. get
  353. {
  354. return _nikkei225;
  355. }
  356. set
  357. {
  358. _nikkei225 = value;
  359. }
  360. }
  361. public bool Active500
  362. {
  363. get
  364. {
  365. return _active500;
  366. }
  367. set
  368. {
  369. _active500 = value;
  370. }
  371. }
  372. public bool Obsolete
  373. {
  374. get
  375. {
  376. return _obsolete;
  377. }
  378. set
  379. {
  380. _obsolete = value;
  381. }
  382. }
  383. public int Unit
  384. {
  385. get
  386. {
  387. return _unit;
  388. }
  389. set
  390. {
  391. _unit = value;
  392. }
  393. }
  394. public override DataFarm ReserveFarm()
  395. {
  396. return Env.BrandCollection.ReserveFarm(this);
  397. }
  398. public override DataFarm CreateDailyFarm(int extra_dates)
  399. {
  400. return Env.BrandCollection.CreateDailyFarm(this, extra_dates);
  401. }
  402. public override DataFarm CreateFarm(ChartFormat format)
  403. {
  404. return Env.BrandCollection.CreateFarm(this, format);
  405. }
  406. }
  407. internal class DerivedBrand : AbstractBrand
  408. {
  409. protected Expression _expression;
  410. protected string _rawExpression;
  411. protected AbstractBrand[] _dependencies;
  412. protected double _priceScale;
  413. protected string _formatString;
  414. public DerivedBrand(AbstractBrand[] dep, string expr, string name, int code, MarketType m, double pricescale, string formatstring) : base(name, code, m)
  415. {
  416. _rawExpression = expr;
  417. _dependencies = dep;
  418. _priceScale = pricescale;
  419. _formatString = formatstring;
  420. }
  421. public override double PriceScale
  422. {
  423. get
  424. {
  425. return _priceScale;
  426. }
  427. }
  428. public override string PriceFormatString
  429. {
  430. get
  431. {
  432. return _formatString;
  433. }
  434. }
  435. public Expression Expression
  436. {
  437. get
  438. {
  439. if (_expression == null)
  440. {
  441. ExpressionConstructor ee = new ExpressionConstructor();
  442. new ZPredicationParser(new StringReader(_rawExpression), ee).Parse();
  443. _expression = ee.Result;
  444. }
  445. return _expression;
  446. }
  447. }
  448. public AbstractBrand[] Dependencies
  449. {
  450. get
  451. {
  452. return _dependencies;
  453. }
  454. }
  455. public override DataFarm ReserveFarm()
  456. {
  457. return Env.BrandCollection.ReserveFarm(this);
  458. }
  459. public override DataFarm CreateDailyFarm(int extra_dates)
  460. {
  461. return Env.BrandCollection.CreateDailyFarm(this, extra_dates);
  462. }
  463. public override DataFarm CreateFarm(ChartFormat format)
  464. {
  465. return Env.BrandCollection.CreateFarm(this, format);
  466. }
  467. public override bool IsVolumeAvailable
  468. {
  469. get
  470. {
  471. return false;
  472. }
  473. }
  474. }
  475. internal class BrandCollection
  476. {
  477. private Hashtable _data; //codeの値からAbstractBrandへ
  478. private Hashtable _farms; //AbstractBrandからFarmへ Farmの個数を制限する機構はまだ
  479. private ArrayList _search;//☆MY検索ワード
  480. private int _lastUpdatedDate;
  481. private int _stockBrandCount;
  482. private ArrayList _derivedBrands;
  483. //生きているDataFarmの数がfarmCapacityを超えないようにする
  484. private int _farmCapacity;
  485. private int _nextRefCount;
  486. public BrandCollection()
  487. {
  488. _data = new Hashtable();
  489. _farms = new Hashtable();
  490. _search = new ArrayList();//☆MY検索ワード
  491. _derivedBrands = new ArrayList();
  492. _farmCapacity = 100;
  493. _nextRefCount = 1;
  494. }
  495. public int TotalCount
  496. {
  497. get
  498. {
  499. return _data.Count;
  500. }
  501. }
  502. //個別銘柄の数
  503. public int StockBrandCount
  504. {
  505. get
  506. {
  507. return _stockBrandCount;
  508. }
  509. }
  510. public int DerivedBrandCount
  511. {
  512. get
  513. {
  514. return _derivedBrands.Count;
  515. }
  516. }
  517. public int LastUpdatedDate
  518. {
  519. get
  520. {
  521. return _lastUpdatedDate;
  522. }
  523. }
  524. //☆MY検索ワード
  525. public ArrayList HSearchWord
  526. {
  527. get
  528. {
  529. return _search;
  530. }
  531. }
  532. public void Load(string filename)
  533. {
  534. //indexファイルから読んで構築
  535. //!!バージョンチェック必要
  536. StreamReader sr = new StreamReader(filename, Encoding.Default);
  537. string line = sr.ReadLine();
  538. ReadHeader(line);
  539. line = sr.ReadLine();
  540. int n = 1;
  541. ArrayList splits = new ArrayList();
  542. _stockBrandCount = 0;
  543. _data.Clear();
  544. _farms.Clear();
  545. LoadBuiltIns();
  546. while (line != null)
  547. {
  548. string[] d = line.Split(',');
  549. if (d.Length < 4) throw new IOException("index file format error: line" + n);
  550. try
  551. {
  552. int code = Int32.Parse(d[0]);
  553. BasicBrand br = new BasicBrand(d[1], code, (MarketType)Enum.Parse(typeof(MarketType), d[2], true));
  554. br.Unit = Int32.Parse(d[3]);
  555. _data[code] = br;
  556. _stockBrandCount++;
  557. for (int i = 4; i < d.Length; i++)
  558. {
  559. string col = d[i];
  560. if (col == "N225") br.Nikkei225 = true;
  561. if (col == "A500") br.Active500 = true;
  562. if (col == "OBS") br.Obsolete = true;
  563. Debug.Assert(col.Length > 0);
  564. if (col.Length > 0 && col[0] == 'S') splits.Add(new SplitInfo(d[i]));
  565. }
  566. if (splits.Count > 0)
  567. {
  568. br.SplitInfo = (SplitInfo[])splits.ToArray(typeof(SplitInfo));
  569. splits.Clear();
  570. }
  571. }
  572. catch (Exception ex)
  573. {
  574. Debug.WriteLine(String.Format("{0} 行{1} {2}", ex.Message, n, line));
  575. }
  576. line = sr.ReadLine();
  577. n++;
  578. //Debug.WriteLine(n);
  579. }
  580. sr.Close();
  581. ///☆MY検索ワード ここから
  582. var search_word_file_path = string.Format(@"{0}\search_word.txt", System.IO.Path.GetDirectoryName(filename));
  583. var line_search = string.Empty;
  584. if (System.IO.File.Exists(search_word_file_path))
  585. {
  586. using (var st = new StreamReader(search_word_file_path, Encoding.Default))
  587. {
  588. line_search = st.ReadToEnd();
  589. var sp = line_search.Split('\n');
  590. foreach (var e in sp)
  591. {
  592. var code = 0;
  593. var name = string.Empty;
  594. SearchWord sw = new SearchWord();
  595. if (!chk_search_word(e.Trim(), ref sw)) continue;
  596. _search.Add(sw);
  597. }
  598. }
  599. }
  600. else
  601. {
  602. using (var st = new StreamWriter(search_word_file_path, false, Encoding.Default))
  603. {
  604. st.Write(string.Empty);
  605. }
  606. }
  607. //ここまで
  608. }
  609. //☆MY検索ワード ここから
  610. private bool chk_search_word(string s, ref SearchWord sw)
  611. {
  612. if (s.Length == 0) return false;
  613. var sp = s.Split(',');
  614. if (sp.Length != 2) return false;
  615. if (!int.TryParse(sp[0], out sw.code)) return false;
  616. if (sw.code <= 0 && sw.code > 9999) return false;
  617. if (sp[1].Trim() == string.Empty) return false;
  618. sw.name = sp[1].Trim();
  619. return true;
  620. }
  621. //ここまで
  622. public AbstractBrand FindBrand(int code)
  623. {
  624. return (AbstractBrand)_data[code];
  625. }
  626. public AbstractBrand FindNextBrand(int code)
  627. {
  628. // TODO:10000は定数に出す
  629. for (int i = code + 1; i < 10000; i++)
  630. {
  631. if (_data.ContainsKey(i))
  632. {
  633. return (AbstractBrand)_data[i];
  634. }
  635. }
  636. return FindNextBrand(0);
  637. }
  638. public AbstractBrand FindPrevBrand(int code)
  639. {
  640. for (int i = code - 1; i > 0; i--)
  641. {
  642. if (_data.ContainsKey(i))
  643. {
  644. return (AbstractBrand)_data[i];
  645. }
  646. }
  647. return FindPrevBrand(10000);
  648. }
  649. public void Append(AbstractBrand br)
  650. {
  651. _data[br.Code] = br;
  652. if (br is DerivedBrand) _derivedBrands.Add(br);
  653. }
  654. public ArrayList DerivedBrands
  655. {
  656. get
  657. {
  658. return _derivedBrands;
  659. }
  660. }
  661. public IDictionaryEnumerator GetEnumerator()
  662. {
  663. return _data.GetEnumerator();
  664. }
  665. public DataFarm ReserveFarm(AbstractBrand br)
  666. {
  667. return ReserveFarm(br, Env.CurrentIndicators.Format);
  668. }
  669. public DataFarm ReserveFarm(AbstractBrand br, ChartFormat fmt)
  670. {
  671. DataFarm f = (DataFarm)_farms[br];
  672. if (f != null)
  673. { //キャッシュにヒット
  674. if (f.IsEmpty) f.LoadFor(br);
  675. if (br.ReferenceValue < _nextRefCount - 1)
  676. br.ReferenceValue = _nextRefCount++;
  677. return f;
  678. }
  679. if (_farms.Count >= _farmCapacity) CleanFarms();
  680. if (br is BasicBrand)
  681. f = CreateFarm((BasicBrand)br, fmt);
  682. else
  683. f = CreateFarm((DerivedBrand)br, fmt);
  684. _farms[br] = f;
  685. br.ReferenceValue = _nextRefCount++;
  686. return f;
  687. }
  688. public bool HasFarm(AbstractBrand br)
  689. {
  690. return _farms.Contains(br);
  691. }
  692. private void CleanFarms()
  693. {
  694. ArrayList t = new ArrayList(_farms.Keys);
  695. t.Sort(new BrandComparer());
  696. Hashtable newfarms = new Hashtable();
  697. for (int n = t.Count / 2; n < t.Count; n++)
  698. {
  699. AbstractBrand br = (AbstractBrand)t[n];
  700. br.ReferenceValue = n;
  701. newfarms[br] = _farms[br];
  702. }
  703. _nextRefCount = t.Count;
  704. _farms = newfarms;
  705. }
  706. //キャッシュとは無関係にDataFarmを作成
  707. public DataFarm CreateDailyFarm(AbstractBrand br, int extra_dates)
  708. {
  709. DailyDataFarm f = new DailyDataFarm();
  710. f.LoadFor(br, extra_dates);
  711. return f;
  712. }
  713. public DataFarm CreateFarm(BasicBrand br, ChartFormat format)
  714. {
  715. DataFarm f;
  716. if (Util.IsDailyBased(format))
  717. f = new DailyDataFarm();
  718. else if (format == ChartFormat.Weekly)
  719. f = new WeeklyDataFarm();
  720. else if (format == ChartFormat.Yearly)
  721. f = new YearlyDataFarm();
  722. else // Monthly
  723. f = new MonthlyDataFarm();
  724. f.LoadFor(br);
  725. return f;
  726. }
  727. public DataFarm CreateFarm(DerivedBrand br, ChartFormat format)
  728. {
  729. DerivedDataFarm f = new DerivedDataFarm(br, format);
  730. f.LoadFor(br);
  731. return f;
  732. }
  733. private class BrandComparer : IComparer
  734. {
  735. public int Compare(object x, object y)
  736. {
  737. return ((AbstractBrand)x).ReferenceValue - ((AbstractBrand)y).ReferenceValue;
  738. }
  739. }
  740. public void ClearAllFarms()
  741. {
  742. _farms.Clear();
  743. _nextRefCount = 1;
  744. #if DOJIMA
  745. Dojima.DojimaUtil.HalfDailyDataFarmCache.ClearAll();
  746. #endif
  747. }
  748. public ICollection Values
  749. {
  750. get
  751. {
  752. return _data.Values;
  753. }
  754. }
  755. private void LoadBuiltIns()
  756. {
  757. AddBrandFromEnumType(typeof(BuiltInIndex).GetMembers(), MarketType.B);
  758. #if DOJIMA
  759. AddBrandFromEnumType( typeof(CommodityIndex).GetMembers(), MarketType.C );
  760. #endif
  761. }
  762. private void AddBrandFromEnumType(MemberInfo[] ms, MarketType mt)
  763. {
  764. foreach (MemberInfo mi in ms)
  765. {
  766. FieldInfo fi = mi as FieldInfo;
  767. //!!EnumDescAttributeは0から順に並んだ場合しか対応していなかったので急遽。後でまとめること
  768. if (fi != null && fi.IsStatic && fi.IsPublic)
  769. {
  770. EnumValueAttribute a = (EnumValueAttribute)(fi.GetCustomAttributes(typeof(EnumValueAttribute), false)[0]);
  771. int code = (int)fi.GetValue(null);
  772. BasicBrand br = new BasicBrand(a.Description, code, mt);
  773. br.Unit = 0;
  774. _data[code] = br;
  775. }
  776. }
  777. }
  778. private void ReadHeader(string line)
  779. {
  780. _lastUpdatedDate = ReadDateFromHeader(line);
  781. }
  782. private static int ReadDateFromHeader(string line)
  783. {
  784. foreach (string e in line.Split(','))
  785. {
  786. int eq = e.IndexOf('=');
  787. if (eq == -1) throw new IOException("index.txtのヘッダフォーマットエラー");
  788. string name = e.Substring(0, eq);
  789. string value = e.Substring(eq + 1);
  790. if (name == "date")
  791. return Int32.Parse(value); //いまのところこれしかデータなし
  792. }
  793. return -1;
  794. }
  795. public static int GuessDate(MemoryStream strm)
  796. {
  797. strm.Position = 0;
  798. TextReader s = new StreamReader(strm, Encoding.Default);
  799. string line = s.ReadLine();
  800. int dt = ReadDateFromHeader(line);
  801. return dt;
  802. }
  803. }
  804. //☆MY検索ワード
  805. internal class SearchWord
  806. {
  807. public int code;
  808. public string name;
  809. }
  810. }
ダウンロード 印刷用表示

このコピペの URL

JavaScript での埋め込み

iframe での埋め込み

元のテキスト