Giter VIP home page Giter VIP logo

Comments (4)

linsamtw avatar linsamtw commented on May 24, 2024

@sakkyoi
我在 colab 執行,是正常的耶,能提供更多資訊嗎?
image

from finmind.

sakkyoi avatar sakkyoi commented on May 24, 2024

@linsamtw
抱歉回晚了,我用 colab 也執行了相同的程式碼,問題是可以再現的,以下是我的執行結果:
image

from finmind.

sakkyoi avatar sakkyoi commented on May 24, 2024

改成直接用 backtest._trade_detail 呼叫交易資料的話,會發現在 hold_volume 欄位中,出現了小數的結果:
image
造成這個結果的來由,是在 strategies/base.py 的第692行,TradeDetail(**row_dict) 的地方 (上圖是 base.py 中的程式碼)。

在 schema/info.py 中 TradeDetail 的 hold_volume 型態定義是 int,
另外,StockEarningsDistribution 是 float,根據 strategies/base.py 第 577 行 (與一開始的 issue 描述有些出入,現在是改用 1.6.4 版做測試):

gain_stock_div = stock_div * trader.hold_volume / 10

stock_div 根據地 554 行,是來自於 StockEarningsDistribution 欄位,這個欄位在原 issue 的測試條件中,是包含小數 0.37877029 的數值,在實務上這也是常發生的事情。這導致了最終 gain_stock_div 有可能是一個包含小數部分的 float,並且在地 580 行被加回 trader.hold_volume 中,該欄位是 int 型態,根據前面的描述,這個值在貼入 TradeDetail 的時候,會被 pydantic 檢查到,並發生錯誤。

from finmind.

linsamtw avatar linsamtw commented on May 24, 2024

已 release to 1.6.6 version

from finmind.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.