thinh-vu / vnstock

A powerful Python library for getting rich data from the Vietnam Stock Market using just a few lines of code
https://vnstocks.com
Other
499 stars 130 forks source link

Lỗi khi lấy giá lịch sử theo tháng #127

Closed AnhCaooo closed 1 month ago

AnhCaooo commented 3 months ago

Mô tả lỗi Gọi hàm tock.quote.history và truyền parameter 'interval="1M"' không hoạt động

Cách tái hiện lại lỗi để xử lý Các bước để tái hiện sự cố:

  1. Code
# List all stocks from VN30
vn_stock_list = stock.listing.symbols_by_group('VN30')

for index in range(len(vn_stock_list)): 
    # Stock price history from 15/04/2019 to 15/04/2024
    stock_history_df = stock.quote.history(symbol=vn_stock_list[index], start='2019-04-15', end='2024-04-15', interval='1M')
  1. Gặp lỗi khi chạy trên Google Colab

KeyError Traceback (most recent call last) /usr/local/lib/python3.10/dist-packages/pandas/_libs/tslibs/offsets.pyx in pandas._libs.tslibs.offsets._get_offset()

KeyError: 'ME'

The above exception was the direct cause of the following exception:

ValueError Traceback (most recent call last) 11 frames ValueError: Invalid frequency: ME

The above exception was the direct cause of the following exception:

ValueError Traceback (most recent call last) /usr/local/lib/python3.10/dist-packages/pandas/_libs/tslibs/offsets.pyx in pandas._libs.tslibs.offsets.to_offset()

ValueError: Invalid frequency: ME



**Mong muốn đạt được**
Nhận về giá cổ phiếu theo tháng tương tự như theo ngày và tuần 

**Bổ sung thông tin**
https://vnstocks.com/docs/huong-dan/thong-ke-gia-lich-su#gi%C3%A1-l%E1%BB%8Bch-s%E1%BB%AD 
thinh-vu commented 2 months ago

Cám ơn @AnhCaooo đã báo lỗi. Mình đã kiểm tra và lỗi này chỉ xuất hiện với phiên bản Python trên Google Colab trong khi vẫn hoạt động bình thường với môi trường cục bộ, bản python 3.10rc2. Mình sẽ cập nhật lỗi này trong thời gian sớm nhất.

thinh-vu commented 1 month ago

Lỗi này đã được mình bổ sung cơ chế xử lý trong phiên bản 0.3.0.6. Mình đóng ticket tại đây.

trucphan66 commented 1 month ago

Hi, bạn kiểm tra dùm, mình không trích xuất được lịch sử giá trong phiên bản python 3.12 khi dùng lệnh stock.quote.history(symbol=stock_symbol, start=start_date, end=end_date, interval='1d'). Cám ơn bạn

Bug stock quote history