Fetching commodity prices

Hide code cell content

import warnings
warnings.simplefilter(action='ignore', category=FutureWarning)

import lseg.data as ld

ld.open_session()
<lseg.data.session.Definition object at 0x7fc0488a23c0 {name='rdp'}>

You can use the LSEG Data Library for Python to retrieve the latest price of a commodity by passing its Refinitiv Instrument Code to the get_data function.

Adding an equals sign as a suffix will return the value in US dollars. Here’s the spot price of gold:

ld.get_data("XAU=")

The get_data query requires that you account have access to real-time trading data, which is not available to all users. If you don’t, you can request the latest "1min" intervals from the get_history method.

ld.get_history(
    "XAU=",
    interval="1min",
).tail(1)
XAU= BID_HIGH_1 BID_LOW_1 OPEN_BID BID BID_NUMMOV ASK_HIGH_1 ASK_LOW_1 OPEN_ASK ASK ASK_NUMMOV MID_HIGH MID_LOW MID_OPEN MID_PRICE
Timestamp
2025-10-16 13:45:00 4258.08 4252.19 4256.93 4252.815 298 4258.59 4253.2 4257.28 4253.635 298 4258.335 4252.795 4257.105 4253.225

Historical data

You can retrieve historical stock prices by passing a Refinitiv Instrument Code to the get_history function. By default it returns the closing price for the last 30 days.

ld.get_history('XAU=')
XAU= HIGH_1 LOW_1 MID_PRICE BID OPEN_BID ASK OPEN_ASK BID_LOW_1 BID_HIGH_1 ASK_LOW_1 ASK_HIGH_1
Date
2025-09-18 3672.76 3627.54 3644.3624 3644.0095 3658.8 3644.7153 3660.0 3627.54 3672.76 3628.24 3673.6
2025-09-19 3685.16 3632.02 3684.9751 3683.7251 3644.44 3686.2251 3645.64 3632.02 3685.16 3632.53 3687.5
2025-09-22 3748.7 3682.79 3746.47495 3746.2075 3685.59 3746.7424 3688.0 3682.79 3748.7 3684.4541 3749.79
2025-09-23 3790.82 3736.42 3764.1925 3763.821 3746.1418 3764.564 3746.8081 3736.42 3790.82 3737.03 3791.4011
2025-09-24 3779.17 3717.1 3736.29245 3735.9199 3764.98 3736.665 3766.58 3717.1 3779.17 3717.5 3779.9
2025-09-25 3761.38 3721.65 3749.37 3748.8196 3736.17 3749.9204 3737.17 3721.65 3761.38 3722.42 3761.94
2025-09-26 3783.55 3734.25 3760.2351 3759.6377 3747.18 3760.8325 3749.18 3734.25 3783.55 3734.9 3784.2
2025-09-29 3833.89 3756.79 3833.9325 3833.553 3757.5183 3834.312 3759.6716 3756.79 3833.89 3758.4575 3835.26
2025-09-30 3871.45 3792.79 3858.51255 3858.1787 3832.84 3858.8464 3834.84 3792.79 3871.45 3793.56 3872.28
2025-10-01 3895.09 3853.04 3865.8025 3865.4495 3857.84 3866.1555 3859.84 3853.04 3895.09 3853.83 3895.8
2025-10-02 3896.49 3819.09 3856.53005 3856.0125 3865.66 3857.0476 3867.66 3819.09 3896.49 3819.92 3897.9
2025-10-03 3891.49 3837.63 3886.83495 3885.9905 3856.92 3887.6794 3858.92 3837.63 3891.49 3838.46 3892.2
2025-10-06 3969.91 3882.86 3961.09 3960.4097 3887.25 3961.7703 3889.65 3882.86 3969.91 3885.0 3970.57
2025-10-07 3990.85 3940.19 3983.8203 3983.5459 3961.48 3984.0947 3963.48 3940.19 3990.85 3941.3 3991.5
2025-10-08 4059.05 3982.14 4038.9 4037.9 3983.52 4039.9 3984.1201 3982.14 4059.05 3983.5779 4059.6218
2025-10-09 4057.79 3944.29 3976.2949 3975.0449 4041.69 3977.5449 4043.69 3944.29 4057.79 3945.3 4058.38
2025-10-10 4022.52 3946.29 4018.29625 4017.343 3976.58 4019.2495 3978.58 3946.29 4022.52 3947.31 4023.4
2025-10-13 4116.77 4007.39 4110.7024 4110.1182 4017.5449 4111.2866 4020.0449 4007.39 4116.77 4010.2 4117.5
2025-10-14 4179.48 4089.93 4142.31495 4141.4697 4107.78 4143.1602 4110.18 4089.93 4179.48 4091.05 4181.3
2025-10-15 4217.95 4139.19 4208.58495 4207.5146 4143.97 4209.6553 4144.82 4139.19 4217.95 4141.7 4218.9

Multiple instruments

You can retrieve data for multiple instruments by passing a list of Refinitiv Instrument Codes to the get_data and get_history functions.

ld.get_history(['XAU=', 'XAG='])
XAU= ... XAG=
HIGH_1 LOW_1 MID_PRICE BID OPEN_BID ASK OPEN_ASK BID_LOW_1 BID_HIGH_1 ASK_LOW_1 ... LOW_1 MID_PRICE BID OPEN_BID ASK OPEN_ASK BID_LOW_1 BID_HIGH_1 ASK_LOW_1 ASK_HIGH_1
Date
2025-09-18 3672.76 3627.54 3644.3624 3644.0095 3658.8 3644.7153 3660.0 3627.54 3672.76 3628.24 ... 41.17 41.825 41.8 41.6445 41.85 41.6835 41.17 41.9612 41.2117 42.01
2025-09-19 3685.16 3632.02 3684.9751 3683.7251 3644.44 3686.2251 3645.64 3632.02 3685.16 3632.53 ... 41.62 43.105 43.08 41.785 43.13 41.824 41.62 43.0857 41.663 43.16
2025-09-22 3748.7 3682.79 3746.47495 3746.2075 3685.59 3746.7424 3688.0 3682.79 3748.7 3684.4541 ... 42.99 44.105 44.08 43.06 44.13 43.18 42.99 44.11 43.0455 44.16
2025-09-23 3790.82 3736.42 3764.1925 3763.821 3746.1418 3764.564 3746.8081 3736.42 3790.82 3737.03 ... 43.62 44.04 44.015 44.0042 44.065 44.0542 43.62 44.46 43.6562 44.51
2025-09-24 3779.17 3717.1 3736.29245 3735.9199 3764.98 3736.665 3766.58 3717.1 3779.17 3717.5 ... 43.64 43.935 43.91 43.969 43.96 44.009 43.64 44.31 43.6853 44.36
2025-09-25 3761.38 3721.65 3749.37 3748.8196 3736.17 3749.9204 3737.17 3721.65 3761.38 3722.42 ... 43.7558 45.245 45.22 43.8926 45.27 43.9251 43.7558 45.23 43.786 45.28
2025-09-26 3783.55 3734.25 3760.2351 3759.6377 3747.18 3760.8325 3749.18 3734.25 3783.55 3734.9 ... 44.5076 46.0262 45.9937 45.1715 46.0587 45.2365 44.5076 46.63 44.6171 46.68
2025-09-29 3833.89 3756.79 3833.9325 3833.553 3757.5183 3834.312 3759.6716 3756.79 3833.89 3758.4575 ... 45.92 46.955 46.93 46.07 46.98 46.18 45.92 47.17 45.9648 47.22
2025-09-30 3871.45 3792.79 3858.51255 3858.1787 3832.84 3858.8464 3834.84 3792.79 3871.45 3793.56 ... 45.78 46.695 46.67 46.9035 46.72 46.9685 45.78 47.16 45.8203 47.21
2025-10-01 3895.09 3853.04 3865.8025 3865.4495 3857.84 3866.1555 3859.84 3853.04 3895.09 3853.83 ... 46.57 47.345 47.32 46.6375 47.37 46.7025 46.57 47.83 46.6559 47.88
2025-10-02 3896.49 3819.09 3856.53005 3856.0125 3865.66 3857.0476 3867.66 3819.09 3896.49 3819.92 ... 45.88 46.99 46.965 47.2905 47.015 47.3555 45.88 48.05 45.9276 48.16
2025-10-03 3891.49 3837.63 3886.83495 3885.9905 3856.92 3887.6794 3858.92 3837.63 3891.49 3838.46 ... 46.62 47.9975 47.9725 46.9505 48.0225 47.0155 46.62 48.3644 46.6676 48.4
2025-10-06 3969.91 3882.86 3961.09 3960.4097 3887.25 3961.7703 3889.65 3882.86 3969.91 3885.0 ... 47.92 48.555 48.53 48.04 48.58 48.12 47.92 48.7616 47.98 48.81
2025-10-07 3990.85 3940.19 3983.8203 3983.5459 3961.48 3984.0947 3963.48 3940.19 3990.85 3941.3 ... 47.29 47.845 47.82 48.5269 47.87 48.5919 47.29 48.64 47.3414 48.69
2025-10-08 4059.05 3982.14 4038.9 4037.9 3983.52 4039.9 3984.1201 3982.14 4059.05 3983.5779 ... 47.7 48.905 48.88 47.7907 48.93 47.8687 47.7 49.57 47.7594 49.62
2025-10-09 4057.79 3944.29 3976.2949 3975.0449 4041.69 3977.5449 4043.69 3944.29 4057.79 3945.3 ... 48.41 49.14 49.115 48.8826 49.165 48.9476 48.41 51.2205 48.49 51.26
2025-10-10 4022.52 3946.29 4018.29625 4017.343 3976.58 4019.2495 3978.58 3946.29 4022.52 3947.31 ... 48.7602 50.295 50.27 49.11 50.32 49.16 48.7602 51.13 48.8252 51.1964
2025-10-13 4116.77 4007.39 4110.7024 4110.1182 4017.5449 4111.2866 4020.0449 4007.39 4116.77 4010.2 ... 49.6674 52.34985 52.3398 50.2191 52.3599 50.4791 49.6674 52.4454 49.9274 52.48
2025-10-14 4179.48 4089.93 4142.31495 4141.4697 4107.78 4143.1602 4110.18 4089.93 4179.48 4091.05 ... 50.4498 51.47 51.445 52.32 51.495 52.37 50.4498 53.6 50.5148 53.65
2025-10-15 4217.95 4139.19 4208.58495 4207.5146 4143.97 4209.6553 4144.82 4139.19 4217.95 4141.7 ... 51.34 53.095 53.07 51.4547 53.12 51.4947 51.34 53.18 51.4145 53.2524

20 rows × 22 columns

Hide code cell content

ld.close_session()