question

Upvotes
1 0 1 1

how to get Hongkong stock dayline data by API?

#contentpython api
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

· Write an Answer
Upvotes
7.2k 23 3 6

Hi @YanHan Does this work for you?

from datetime import datetime
import lseg.data as ld
ld.open_session()

instrument = '0700.HK'  # Example: Tencent Holdings Ltd
start_date = '2023-01-01'
end_date = '2023-12-31'

data = ld.get_history(
    universe=[instrument],
    fields=['BID', 'ASK', 'OPEN', 'HIGH', 'LOW', 'CLOSE', 'VOLUME'],
    start=start_date,
    end=end_date,
    interval='daily'
)

# Close the session
ld.close_session()

# Display the data
print(data)

1728916430768.png


1728916430768.png (14.3 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.