Skip to content

Commit

Permalink
fix url
Browse files Browse the repository at this point in the history
  • Loading branch information
Thiago-NovaesB committed Oct 30, 2024
1 parent 6648cba commit ecb9f30
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
3 changes: 2 additions & 1 deletion src/caiso/urls.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ function _get_caiso_price_url(
stopdate::AbstractString,
market_run_id::AbstractString,
)::AbstractString
return _get_caiso_url("PRC_INTVL_LMP", startdate, stopdate, market_run_id)
queryname = market_run_id == "RTM" ? "PRC_INTVL_LMP" : "PRC_LMP"
return _get_caiso_url(queryname, startdate, stopdate, market_run_id)
end
16 changes: 7 additions & 9 deletions src/caiso/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,16 @@ function _get_data(
tasks = _async_get_raw_data(market, serie, start_date, end_date, folder)
dfs = Vector{DataFrame}()
for task in tasks
temp = nothing
for file_name in _unzip(fetch(task), x -> serie * "_" * x)
df = CSV.read(file_name, DataFrame)
push!(
dfs,
unstack(
df,
[:INTERVALSTARTTIME_GMT, :MARKET_RUN_ID, :NODE],
:LMP_TYPE,
:MW,
),
)
pivot =
unstack(df, [:INTERVALSTARTTIME_GMT, :MARKET_RUN_ID, :NODE], :LMP_TYPE, :MW)
temp =
isnothing(temp) ? pivot :
outerjoin(temp, pivot, on = [:INTERVALSTARTTIME_GMT, :MARKET_RUN_ID, :NODE])
end
push!(dfs, temp)
end
df = vcat(dfs...)
rename!(
Expand Down
8 changes: 8 additions & 0 deletions test/caiso/urls.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,12 @@
@test url ==
"http://oasis.caiso.com/oasisapi/SingleZip?resultformat=6&queryname=PRC_INTVL_LMP&version=1&startdatetime=20230104T07:00-0000&enddatetime=20230105T07:00-0000&market_run_id=RTM"
end
@testset "_get_caiso_price_url" begin
startdate = "20230104T07:00-0000"
stopdate = "20230105T07:00-0000"
market_run_id = "DAM"
url = ElectricityMarketData._get_caiso_price_url(startdate, stopdate, market_run_id)
@test url ==
"http://oasis.caiso.com/oasisapi/SingleZip?resultformat=6&queryname=PRC_LMP&version=1&startdatetime=20230104T07:00-0000&enddatetime=20230105T07:00-0000&market_run_id=DAM"
end
end

0 comments on commit ecb9f30

Please sign in to comment.