Skip to content

Commit

Permalink
add suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
andre_ramos committed Oct 25, 2024
1 parent de38213 commit fa2bf56
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 43 deletions.
12 changes: 2 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

| Data | PJM | MISO | CAISO |
| ------------- | :---: | :---: | :---: |
| Real Time LMP | | ✔️ ||
| Real Time LMP | ✔️ | ✔️ ||
| Day-ahead LMP | ✔️ | ✔️ ||
| Load ||||

Expand All @@ -19,19 +19,11 @@ using Dates
using TimeZones
import TimeZones: ZonedDateTime
market = ElectricityMarketData.PjmMarket()
ElectricityMarketData.get_pjm_lmp_raw_data(market,
"DA-LMP",
ZonedDateTime(DateTime(2023, 12, 1, 0, 0), tz"UTC-4"),
ZonedDateTime(DateTime(2024, 1, 3, 1, 0), tz"UTC-4");
folder = pwd(),
download = true)

df = ElectricityMarketData.get_pjm_lmp_raw_data(market,
"RT-LMP",
ZonedDateTime(DateTime(2023, 12, 1, 0, 0), tz"UTC-4"),
ZonedDateTime(DateTime(2024, 1, 3, 1, 0), tz"UTC-4");
folder = pwd(),
download = false)
download = true)

parsed_data = ElectricityMarketData.parse_df_format(
df,
Expand Down
19 changes: 19 additions & 0 deletions src/helpers/http_helper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,22 @@ function _async_download(
end
return tasks
end

"""
read_url(url::AbstractString, access_key_dict::Dict)::DataFrame
Read the data from the url.
# Arguments
- url::AbstractString: The url to read the data from.
- access_key_dict::Dict: The access key dictionary.
# Returns
- DataFrame: The data read from the url.
"""
function read_url(url::AbstractString, access_key_dict::Dict)::DataFrame
# get the data from the url
response = HTTP.get(url, headers = access_key_dict)
# read the data into a DataFrame
CSV.read(IOBuffer(response.body), DataFrame)
end
21 changes: 1 addition & 20 deletions src/pjm/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -107,23 +107,4 @@ function get_dates(
current_start = current_end + Hour(1)
end
return dates
end

"""
read_url(url::AbstractString, access_key_dict::Dict)::DataFrame
Read the data from the url.
# Arguments
- url::AbstractString: The url to read the data from.
- access_key_dict::Dict: The access key dictionary.
# Returns
- DataFrame: The data read from the url.
"""
function read_url(url::AbstractString, access_key_dict::Dict)::DataFrame
# get the data from the url
response = HTTP.get(url, headers = access_key_dict)
# read the data into a DataFrame
CSV.read(IOBuffer(response.body), DataFrame)
end
end
14 changes: 14 additions & 0 deletions test/helpers/http_helper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,18 @@
@test isfile(temp_filename_zip)
end
end

@testset "read_url" begin
url = ElectricityMarketData.get_url_day_ahead_lmp(
"1/1/2024",
"00:00",
"1/1/2024",
"01:00",
)
df = ElectricityMarketData.read_url(
url,
ElectricityMarketData.get_acess_key_headers(),
)
@test typeof(df) == DataFrame
end
end
13 changes: 0 additions & 13 deletions test/pjm/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,4 @@
)
end

@testset "read_url" begin
url = ElectricityMarketData.get_url_day_ahead_lmp(
"1/1/2024",
"00:00",
"1/1/2024",
"01:00",
)
df = ElectricityMarketData.read_url(
url,
ElectricityMarketData.get_acess_key_headers(),
)
@test typeof(df) == DataFrame
end
end

0 comments on commit fa2bf56

Please sign in to comment.