FinMind 2.0.8__tar.gz → 2.0.9__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. {finmind-2.0.8 → finmind-2.0.9}/FinMind/strategies/base.py +18 -11
  2. {finmind-2.0.8 → finmind-2.0.9}/FinMind/strategies/utils.py +11 -2
  3. {finmind-2.0.8/finmind.egg-info → finmind-2.0.9}/PKG-INFO +13 -7
  4. {finmind-2.0.8 → finmind-2.0.9}/README.md +12 -6
  5. {finmind-2.0.8 → finmind-2.0.9/finmind.egg-info}/PKG-INFO +13 -7
  6. {finmind-2.0.8 → finmind-2.0.9}/FinMind/__init__.py +0 -0
  7. {finmind-2.0.8 → finmind-2.0.9}/FinMind/_version.py +0 -0
  8. {finmind-2.0.8 → finmind-2.0.9}/FinMind/crawler/__init__.py +0 -0
  9. {finmind-2.0.8 → finmind-2.0.9}/FinMind/crawler/base.py +0 -0
  10. {finmind-2.0.8 → finmind-2.0.9}/FinMind/crawler/commodities.py +0 -0
  11. {finmind-2.0.8 → finmind-2.0.9}/FinMind/crawler/demo.py +0 -0
  12. {finmind-2.0.8 → finmind-2.0.9}/FinMind/crawler/government_bonds.py +0 -0
  13. {finmind-2.0.8 → finmind-2.0.9}/FinMind/data/__init__.py +0 -0
  14. {finmind-2.0.8 → finmind-2.0.9}/FinMind/data/data_loader.py +0 -0
  15. {finmind-2.0.8 → finmind-2.0.9}/FinMind/data/data_subscriber.py +0 -0
  16. {finmind-2.0.8 → finmind-2.0.9}/FinMind/data/finmind_api.py +0 -0
  17. {finmind-2.0.8 → finmind-2.0.9}/FinMind/indicators/__init__.py +0 -0
  18. {finmind-2.0.8 → finmind-2.0.9}/FinMind/indicators/bias.py +0 -0
  19. {finmind-2.0.8 → finmind-2.0.9}/FinMind/indicators/continue_holding.py +0 -0
  20. {finmind-2.0.8 → finmind-2.0.9}/FinMind/indicators/institutional_investors_follower.py +0 -0
  21. {finmind-2.0.8 → finmind-2.0.9}/FinMind/indicators/institutional_investors_over_buy.py +0 -0
  22. {finmind-2.0.8 → finmind-2.0.9}/FinMind/indicators/kd.py +0 -0
  23. {finmind-2.0.8 → finmind-2.0.9}/FinMind/indicators/kd_crossover.py +0 -0
  24. {finmind-2.0.8 → finmind-2.0.9}/FinMind/indicators/ma_cross_orver.py +0 -0
  25. {finmind-2.0.8 → finmind-2.0.9}/FinMind/indicators/short_sale_margin_purchase_ratio.py +0 -0
  26. {finmind-2.0.8 → finmind-2.0.9}/FinMind/plotting/__init__.py +0 -0
  27. {finmind-2.0.8 → finmind-2.0.9}/FinMind/plotting/bar.py +0 -0
  28. {finmind-2.0.8 → finmind-2.0.9}/FinMind/plotting/kline.py +0 -0
  29. {finmind-2.0.8 → finmind-2.0.9}/FinMind/plotting/line.py +0 -0
  30. {finmind-2.0.8 → finmind-2.0.9}/FinMind/plotting/pie.py +0 -0
  31. {finmind-2.0.8 → finmind-2.0.9}/FinMind/schema/__init__.py +0 -0
  32. {finmind-2.0.8 → finmind-2.0.9}/FinMind/schema/data.py +0 -0
  33. {finmind-2.0.8 → finmind-2.0.9}/FinMind/schema/indicators.py +0 -0
  34. {finmind-2.0.8 → finmind-2.0.9}/FinMind/schema/info.py +0 -0
  35. {finmind-2.0.8 → finmind-2.0.9}/FinMind/schema/plot.py +0 -0
  36. {finmind-2.0.8 → finmind-2.0.9}/FinMind/schema/rule.py +0 -0
  37. {finmind-2.0.8 → finmind-2.0.9}/FinMind/strategies/__init__.py +0 -0
  38. {finmind-2.0.8 → finmind-2.0.9}/FinMind/strategies/bias.py +0 -0
  39. {finmind-2.0.8 → finmind-2.0.9}/FinMind/strategies/continue_holding.py +0 -0
  40. {finmind-2.0.8 → finmind-2.0.9}/FinMind/strategies/institutional_investors_follower.py +0 -0
  41. {finmind-2.0.8 → finmind-2.0.9}/FinMind/strategies/kd.py +0 -0
  42. {finmind-2.0.8 → finmind-2.0.9}/FinMind/strategies/kd_crossover.py +0 -0
  43. {finmind-2.0.8 → finmind-2.0.9}/FinMind/strategies/ma_crossover.py +0 -0
  44. {finmind-2.0.8 → finmind-2.0.9}/FinMind/strategies/macd_crossover.py +0 -0
  45. {finmind-2.0.8 → finmind-2.0.9}/FinMind/strategies/max_min_period_bias.py +0 -0
  46. {finmind-2.0.8 → finmind-2.0.9}/FinMind/strategies/naive_kd.py +0 -0
  47. {finmind-2.0.8 → finmind-2.0.9}/FinMind/strategies/short_sale_margin_purchase_ratio.py +0 -0
  48. {finmind-2.0.8 → finmind-2.0.9}/FinMind/templates/post.html +0 -0
  49. {finmind-2.0.8 → finmind-2.0.9}/FinMind/utility/__init__.py +0 -0
  50. {finmind-2.0.8 → finmind-2.0.9}/FinMind/utility/request.py +0 -0
  51. {finmind-2.0.8 → finmind-2.0.9}/FinMind/utility/rule.py +0 -0
  52. {finmind-2.0.8 → finmind-2.0.9}/LICENSE +0 -0
  53. {finmind-2.0.8 → finmind-2.0.9}/finmind.egg-info/SOURCES.txt +0 -0
  54. {finmind-2.0.8 → finmind-2.0.9}/finmind.egg-info/dependency_links.txt +0 -0
  55. {finmind-2.0.8 → finmind-2.0.9}/finmind.egg-info/requires.txt +0 -0
  56. {finmind-2.0.8 → finmind-2.0.9}/finmind.egg-info/top_level.txt +0 -0
  57. {finmind-2.0.8 → finmind-2.0.9}/pyproject.toml +0 -0
  58. {finmind-2.0.8 → finmind-2.0.9}/setup.cfg +0 -0
  59. {finmind-2.0.8 → finmind-2.0.9}/setup.py +0 -0
@@ -116,11 +116,12 @@ class Trader:
116
116
  self.UnrealizedProfit = capital_gains - sell_fee - sell_tax
117
117
  self.EverytimeProfit = self.UnrealizedProfit + self.RealizedProfit
118
118
 
119
- @staticmethod
120
119
  def __have_enough_money(
121
- trader_fund: int, trade_price: float, trade_volume: float
120
+ self, trader_fund: int, trade_price: float, trade_volume: float
122
121
  ) -> bool:
123
- return trader_fund >= (trade_price * trade_volume)
122
+ buy_price = trade_price * trade_volume
123
+ buy_fee = max(20.0, buy_price * self.fee)
124
+ return trader_fund >= (buy_price + buy_fee)
124
125
 
125
126
  @staticmethod
126
127
  def __have_enough_volume(hold_volume: float, trade_volume: float) -> bool:
@@ -266,7 +267,7 @@ class BackTest:
266
267
  indicators_info: typing.Union[IndicatorsInfo, typing.Dict[str, str]],
267
268
  ):
268
269
  indicators_info = (
269
- indicators_info.dict()
270
+ indicators_info.model_dump()
270
271
  if isinstance(indicators_info, IndicatorsInfo)
271
272
  else indicators_info
272
273
  )
@@ -323,7 +324,7 @@ class BackTest:
323
324
  ],
324
325
  ):
325
326
  return [
326
- rule.dict() if isinstance(rule, AddBuySellRule) else rule
327
+ rule.model_dump() if isinstance(rule, AddBuySellRule) else rule
327
328
  for rule in rule_list
328
329
  ]
329
330
 
@@ -584,11 +585,15 @@ class BackTest:
584
585
  gain_cash = (
585
586
  cash_div * trader.hold_volume + gain_stock_frac * 10
586
587
  ) # 將小數部分加進 gain_cash
588
+ # 配股「除權」不是一筆交易,總持有成本不會改變,
589
+ # 只是同一筆成本攤到更多股數上(每股成本被稀釋)。
590
+ # 因此 origin_cost 必須在 hold_volume 增加「之前」計算,
591
+ # 否則總成本會憑空跟著配股一起變大。
592
+ origin_cost = trader.hold_cost * trader.hold_volume
587
593
  trader.hold_volume += gain_stock_div
588
594
  # 在 UnrealizedProfit & RealizedProfit
589
595
  # 避免重複計算 gain_cash
590
- origin_cost = trader.hold_cost * trader.hold_volume
591
- # 持有成本不變,將配息歸類在,已實現損益
596
+ # 現金股利不調整持有成本,改歸類在已實現損益
592
597
  # new_cost = origin_cost - gain_cash
593
598
  trader.hold_cost = (
594
599
  origin_cost / trader.hold_volume if trader.hold_volume != 0 else 0
@@ -698,7 +703,7 @@ class BackTest:
698
703
  @property
699
704
  def final_stats(self) -> pd.Series:
700
705
  self._final_stats = pd.Series(
701
- FinalStats(**self._final_stats.to_dict()).dict()
706
+ FinalStats(**self._final_stats.to_dict()).model_dump()
702
707
  )
703
708
  return self._final_stats
704
709
 
@@ -706,7 +711,7 @@ class BackTest:
706
711
  def trade_detail(self) -> pd.DataFrame:
707
712
  self._trade_detail = pd.DataFrame(
708
713
  [
709
- TradeDetail(**row_dict).dict()
714
+ TradeDetail(**row_dict).model_dump()
710
715
  for row_dict in self._trade_detail.to_dict("records")
711
716
  ]
712
717
  )
@@ -716,7 +721,7 @@ class BackTest:
716
721
  def compare_market_detail(self) -> pd.DataFrame:
717
722
  self._compare_market_detail = pd.DataFrame(
718
723
  [
719
- CompareMarketDetail(**row_dict).dict()
724
+ CompareMarketDetail(**row_dict).model_dump()
720
725
  for row_dict in self._compare_market_detail.to_dict("records")
721
726
  ]
722
727
  )
@@ -725,7 +730,9 @@ class BackTest:
725
730
  @property
726
731
  def compare_market_stats(self) -> pd.Series:
727
732
  self._compare_market_stats = pd.Series(
728
- CompareMarketStats(**self._compare_market_stats.to_dict()).dict()
733
+ CompareMarketStats(
734
+ **self._compare_market_stats.to_dict()
735
+ ).model_dump()
729
736
  )
730
737
  return self._compare_market_stats
731
738
 
@@ -35,9 +35,18 @@ def get_asset_underlying_type(stock_id: str, data_loader: DataLoader) -> str:
35
35
  return sorted(industry_category.values)[0]
36
36
 
37
37
 
38
+ # ETF 的證交稅是 0.1%,一般股票是 0.3%。TaiwanStockInfo 對上櫃 ETF 的
39
+ # industry_category 有「上櫃指數股票型基金(ETF)」與「上櫃ETF」兩種寫法,
40
+ # 同一檔可能只出現其中一種,兩種都要對應到 ETF 稅率。
41
+ UNDERLYING_TRADING_TAX = {
42
+ "ETF": 0.001,
43
+ "上櫃指數股票型基金(ETF)": 0.001,
44
+ "上櫃ETF": 0.001,
45
+ }
46
+
47
+
38
48
  def get_underlying_trading_tax(underlying_type: str) -> float:
39
- mapping = {"ETF": 0.001, "上櫃指數股票型基金(ETF)": 0.001}
40
- return mapping.get(underlying_type, 0.003)
49
+ return UNDERLYING_TRADING_TAX.get(underlying_type, 0.003)
41
50
 
42
51
 
43
52
  def calculate_datenbr(day1: str, day2: str) -> int:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: finmind
3
- Version: 2.0.8
3
+ Version: 2.0.9
4
4
  Summary: financial mining
5
5
  Author-email: linsam <finmind.tw@gmail.com>
6
6
  License: Apache License
@@ -245,8 +245,8 @@ Dynamic: license-file
245
245
  </p>
246
246
 
247
247
  <p align="center">
248
- <a href="https://travis-ci.org/FinMind/FinMind"><img src="https://travis-ci.org/FinMind/FinMind.svg?branch=master" alt="Build Status"></a>
249
- <a href="https://github.com/linsamtw/FinMind/blob/master/LICENSE"><img src="https://img.shields.io/github/license/FinMind/FinMind" alt="license"></a>
248
+ <a href="https://github.com/FinMind/FinMind/actions/workflows/python-package.yml"><img src="https://github.com/FinMind/FinMind/actions/workflows/python-package.yml/badge.svg?branch=master" alt="Build Status"></a>
249
+ <a href="https://github.com/FinMind/FinMind/blob/master/LICENSE"><img src="https://img.shields.io/github/license/FinMind/FinMind" alt="license"></a>
250
250
  <a href="https://finmind.github.io/"><img src="https://readthedocs.org/projects/finminddoc/badge/?version=latest" alt="Documentation Status"></a>
251
251
  <a href="https://gitter.im/FinMindTW/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge"><img src="https://badges.gitter.im/FinMindTW/community.svg" alt="Gitter"></a>
252
252
  <a href="https://badge.fury.io/py/FinMind"><img src="https://badge.fury.io/py/FinMind.svg" alt="PyPI version"></a>
@@ -285,7 +285,7 @@ pip install FinMind
285
285
 
286
286
  ## 這是什麼?
287
287
 
288
- **FinMind** 是超過 50 種金融開源數據 [50 datasets](https://finmind.github.io/)。
288
+ **FinMind** 提供台灣與國際市場的金融開源數據,完整資料集清單請見[官方文件](https://finmind.github.io/)。
289
289
  包含
290
290
 
291
291
  * 技術面 : 台股股價 daily、即時報價、歷史 tick、PER、PBR、每5秒委託成交統計、加權指數、當日沖銷交易標的及成交量值。
@@ -299,8 +299,9 @@ pip install FinMind
299
299
 
300
300
  ## What is this?
301
301
 
302
- **FinMind** is open source of more
303
- than [50 datasets](https://finmind.github.io/), including
302
+ **FinMind** provides open financial datasets for Taiwan and international
303
+ markets. See the [official documentation](https://finmind.github.io/) for the
304
+ current dataset list, including
304
305
 
305
306
  Taiwan stock trade data daily, Taiwan stock trade data (5 seconds) (2019-05-29 ~
306
307
  now, more than 30 million data in total), Financial Statements, Balance Sheet,
@@ -321,7 +322,7 @@ without having to collect the data by yourself.
321
322
 
322
323
  ## License
323
324
 
324
- - [License Detail](https://github.com/linsamtw/FinMind/blob/master/LICENSE)
325
+ - [License Detail](https://github.com/FinMind/FinMind/blob/master/LICENSE)
325
326
 
326
327
  - 本專案提供的所有內容均用於教育、非商業用途。資料僅供參考,使用者依本資料交易發生交易損失需自行負責,本專案不對資料內容錯誤、更新延誤或傳輸中斷負任何責任。
327
328
 
@@ -390,6 +391,11 @@ Email: FinMind.TW@gmail.com
390
391
 
391
392
  每週日早上零點至早上七點為維護時間,不提供服務。
392
393
 
394
+ ## Contributing
395
+
396
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for the development setup, test commands,
397
+ and pull request checklist.
398
+
393
399
  ## Note
394
400
 
395
401
  + 未來預計新增更多功能,包含個人化回測分析、chatbot 監控策略,
@@ -3,8 +3,8 @@
3
3
  </p>
4
4
 
5
5
  <p align="center">
6
- <a href="https://travis-ci.org/FinMind/FinMind"><img src="https://travis-ci.org/FinMind/FinMind.svg?branch=master" alt="Build Status"></a>
7
- <a href="https://github.com/linsamtw/FinMind/blob/master/LICENSE"><img src="https://img.shields.io/github/license/FinMind/FinMind" alt="license"></a>
6
+ <a href="https://github.com/FinMind/FinMind/actions/workflows/python-package.yml"><img src="https://github.com/FinMind/FinMind/actions/workflows/python-package.yml/badge.svg?branch=master" alt="Build Status"></a>
7
+ <a href="https://github.com/FinMind/FinMind/blob/master/LICENSE"><img src="https://img.shields.io/github/license/FinMind/FinMind" alt="license"></a>
8
8
  <a href="https://finmind.github.io/"><img src="https://readthedocs.org/projects/finminddoc/badge/?version=latest" alt="Documentation Status"></a>
9
9
  <a href="https://gitter.im/FinMindTW/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge"><img src="https://badges.gitter.im/FinMindTW/community.svg" alt="Gitter"></a>
10
10
  <a href="https://badge.fury.io/py/FinMind"><img src="https://badge.fury.io/py/FinMind.svg" alt="PyPI version"></a>
@@ -43,7 +43,7 @@ pip install FinMind
43
43
 
44
44
  ## 這是什麼?
45
45
 
46
- **FinMind** 是超過 50 種金融開源數據 [50 datasets](https://finmind.github.io/)。
46
+ **FinMind** 提供台灣與國際市場的金融開源數據,完整資料集清單請見[官方文件](https://finmind.github.io/)。
47
47
  包含
48
48
 
49
49
  * 技術面 : 台股股價 daily、即時報價、歷史 tick、PER、PBR、每5秒委託成交統計、加權指數、當日沖銷交易標的及成交量值。
@@ -57,8 +57,9 @@ pip install FinMind
57
57
 
58
58
  ## What is this?
59
59
 
60
- **FinMind** is open source of more
61
- than [50 datasets](https://finmind.github.io/), including
60
+ **FinMind** provides open financial datasets for Taiwan and international
61
+ markets. See the [official documentation](https://finmind.github.io/) for the
62
+ current dataset list, including
62
63
 
63
64
  Taiwan stock trade data daily, Taiwan stock trade data (5 seconds) (2019-05-29 ~
64
65
  now, more than 30 million data in total), Financial Statements, Balance Sheet,
@@ -79,7 +80,7 @@ without having to collect the data by yourself.
79
80
 
80
81
  ## License
81
82
 
82
- - [License Detail](https://github.com/linsamtw/FinMind/blob/master/LICENSE)
83
+ - [License Detail](https://github.com/FinMind/FinMind/blob/master/LICENSE)
83
84
 
84
85
  - 本專案提供的所有內容均用於教育、非商業用途。資料僅供參考,使用者依本資料交易發生交易損失需自行負責,本專案不對資料內容錯誤、更新延誤或傳輸中斷負任何責任。
85
86
 
@@ -148,6 +149,11 @@ Email: FinMind.TW@gmail.com
148
149
 
149
150
  每週日早上零點至早上七點為維護時間,不提供服務。
150
151
 
152
+ ## Contributing
153
+
154
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for the development setup, test commands,
155
+ and pull request checklist.
156
+
151
157
  ## Note
152
158
 
153
159
  + 未來預計新增更多功能,包含個人化回測分析、chatbot 監控策略,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: finmind
3
- Version: 2.0.8
3
+ Version: 2.0.9
4
4
  Summary: financial mining
5
5
  Author-email: linsam <finmind.tw@gmail.com>
6
6
  License: Apache License
@@ -245,8 +245,8 @@ Dynamic: license-file
245
245
  </p>
246
246
 
247
247
  <p align="center">
248
- <a href="https://travis-ci.org/FinMind/FinMind"><img src="https://travis-ci.org/FinMind/FinMind.svg?branch=master" alt="Build Status"></a>
249
- <a href="https://github.com/linsamtw/FinMind/blob/master/LICENSE"><img src="https://img.shields.io/github/license/FinMind/FinMind" alt="license"></a>
248
+ <a href="https://github.com/FinMind/FinMind/actions/workflows/python-package.yml"><img src="https://github.com/FinMind/FinMind/actions/workflows/python-package.yml/badge.svg?branch=master" alt="Build Status"></a>
249
+ <a href="https://github.com/FinMind/FinMind/blob/master/LICENSE"><img src="https://img.shields.io/github/license/FinMind/FinMind" alt="license"></a>
250
250
  <a href="https://finmind.github.io/"><img src="https://readthedocs.org/projects/finminddoc/badge/?version=latest" alt="Documentation Status"></a>
251
251
  <a href="https://gitter.im/FinMindTW/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge"><img src="https://badges.gitter.im/FinMindTW/community.svg" alt="Gitter"></a>
252
252
  <a href="https://badge.fury.io/py/FinMind"><img src="https://badge.fury.io/py/FinMind.svg" alt="PyPI version"></a>
@@ -285,7 +285,7 @@ pip install FinMind
285
285
 
286
286
  ## 這是什麼?
287
287
 
288
- **FinMind** 是超過 50 種金融開源數據 [50 datasets](https://finmind.github.io/)。
288
+ **FinMind** 提供台灣與國際市場的金融開源數據,完整資料集清單請見[官方文件](https://finmind.github.io/)。
289
289
  包含
290
290
 
291
291
  * 技術面 : 台股股價 daily、即時報價、歷史 tick、PER、PBR、每5秒委託成交統計、加權指數、當日沖銷交易標的及成交量值。
@@ -299,8 +299,9 @@ pip install FinMind
299
299
 
300
300
  ## What is this?
301
301
 
302
- **FinMind** is open source of more
303
- than [50 datasets](https://finmind.github.io/), including
302
+ **FinMind** provides open financial datasets for Taiwan and international
303
+ markets. See the [official documentation](https://finmind.github.io/) for the
304
+ current dataset list, including
304
305
 
305
306
  Taiwan stock trade data daily, Taiwan stock trade data (5 seconds) (2019-05-29 ~
306
307
  now, more than 30 million data in total), Financial Statements, Balance Sheet,
@@ -321,7 +322,7 @@ without having to collect the data by yourself.
321
322
 
322
323
  ## License
323
324
 
324
- - [License Detail](https://github.com/linsamtw/FinMind/blob/master/LICENSE)
325
+ - [License Detail](https://github.com/FinMind/FinMind/blob/master/LICENSE)
325
326
 
326
327
  - 本專案提供的所有內容均用於教育、非商業用途。資料僅供參考,使用者依本資料交易發生交易損失需自行負責,本專案不對資料內容錯誤、更新延誤或傳輸中斷負任何責任。
327
328
 
@@ -390,6 +391,11 @@ Email: FinMind.TW@gmail.com
390
391
 
391
392
  每週日早上零點至早上七點為維護時間,不提供服務。
392
393
 
394
+ ## Contributing
395
+
396
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for the development setup, test commands,
397
+ and pull request checklist.
398
+
393
399
  ## Note
394
400
 
395
401
  + 未來預計新增更多功能,包含個人化回測分析、chatbot 監控策略,
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes