Skip to content

Commit

Permalink
Add docstrings for visualize method using $(TYPEDSIGNATURES)
Browse files Browse the repository at this point in the history
  • Loading branch information
g-gundam committed Sep 17, 2024
1 parent f0ee4c3 commit cfe2862
Showing 1 changed file with 30 additions and 6 deletions.
36 changes: 30 additions & 6 deletions src/visualize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ denominated_price(bb::BB) = true
denominated_price(srsi::StochRSI) = false


""" visualize(any::Any)
"""$(TYPEDSIGNATURES)
This is a visualize method that's a catch-all for indicators
that haven't had a visualize method made for them yet. For now,
it returns an empty panel.
it returns `missing`.
"""
function visualize(unimplemented::Any, opts, df::DataFrame)
@warn "Unimplemented Visualization" typeof(unimplemented)
missing
end

""" visualize(sma::SMA)
"""$(TYPEDSIGNATURES)
Return an lwc_line for visualizing an SMA indicator.
"""
Expand All @@ -40,6 +40,10 @@ function visualize(sma::SMA, opts, df::DataFrame)
)
end

"""$(TYPEDSIGNATURES)
Visualize EMA using 1 lwc_line.
"""
function visualize(ema::EMA, opts, df::DataFrame)
start = ema.period
name = indicator_fields(ema)[1]
Expand All @@ -56,6 +60,10 @@ function visualize(ema::EMA, opts, df::DataFrame)
)
end

"""$(TYPEDSIGNATURES)
Visualize HMA using 1 lwc_line.
"""
function visualize(hma::HMA, opts, df::DataFrame)
start = hma.period
name = indicator_fields(hma)[1]
Expand All @@ -72,6 +80,10 @@ function visualize(hma::HMA, opts, df::DataFrame)
)
end

"""$(TYPEDSIGNATURES)
Visualize RSI using 1 lwc_line.
"""
function visualize(rsi::RSI, opts, df::DataFrame)
start = rsi.period + 1
name = indicator_fields(rsi)[1]
Expand All @@ -95,6 +107,10 @@ function replace_missing_with(val, collection)
map(n -> if ismissing(n) val else n end, collection)
end

"""$(TYPEDSIGNATURES)
Visualize StochRSI using 2 lwc_lines.
"""
function visualize(srsi::StochRSI, opts, df::DataFrame)
k_defaults = Dict(
:label_name => "StochRSI K",
Expand Down Expand Up @@ -131,6 +147,10 @@ function visualize(srsi::StochRSI, opts, df::DataFrame)
]
end

"""$(TYPEDSIGNATURES)
Visualize Bollinger Bands using 3 lwc_lines.
"""
function visualize(bb::BB, opts, df::DataFrame)
start = bb.period
upper_defaults = Dict(
Expand Down Expand Up @@ -171,6 +191,10 @@ function visualize(bb::BB, opts, df::DataFrame)
]
end

"""$(TYPEDSIGNATURES)
Visualize a DataFrame using lwc_candlestick.
"""
function visualize(df::DataFrame, opts)
candles = map(r -> LWCCandleChartItem(r.ts, r.o, r.h, r.l, r.c), eachrow(df))
lwc_candlestick(
Expand All @@ -179,23 +203,23 @@ function visualize(df::DataFrame, opts)
)
end

""" make_panel(plots::Vector)
"""$(TYPEDSIGNATURES)
Wrap a Vector of LWCCharts in a panel.
"""
function make_panel(plots::Vector)
lwc_panel(plots...)
end

""" make_panel(chart::LWCChart)
"""$(TYPEDSIGNATURES)
Wrap a single LWCChart in a panel.
"""
function make_panel(chart::LWCChart)
lwc_panel(chart)
end

""" visualize(chart::Chart)
"""$(TYPEDSIGNATURES)
Return an LWCLayout that visualizes all the components in chart appropriately.
"""
Expand Down

0 comments on commit cfe2862

Please sign in to comment.