-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Split tests into separate files * Add tests for AV plots * Add tests for CG plots * Update tests * Bump minor version
- Loading branch information
Showing
8 changed files
with
274 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
################# Test cases for CoinGecko API ################# | ||
|
||
@testset "Check if CG developer and community data are accessible" begin | ||
|
||
for currency in ["btc", "eth", "ltc"] | ||
|
||
df_dev, df_comm = CryptoDashApp.get_dev_comm_data(currency) | ||
|
||
@test ~isempty(df_dev) | ||
@test ~isempty(df_comm) | ||
|
||
end | ||
|
||
end | ||
|
||
@testset "Check for exception handling while determining coin id" begin | ||
|
||
currency = "dummy" | ||
|
||
@test_logs (:info, "Could not find an id for the given currency") match_mode = :any CryptoDashApp.get_coin_id( | ||
currency, | ||
) | ||
|
||
end | ||
|
||
@testset "Check if CG exchange volume data per currency are accessible" begin | ||
|
||
for currency in ["btc", "eth", "ltc"] | ||
|
||
num_exchanges = 10 | ||
|
||
df_ex_vol = CryptoDashApp.get_exchange_vol_data(currency, num_exchanges) | ||
|
||
@test size(df_ex_vol)[1] == num_exchanges | ||
|
||
end | ||
|
||
end | ||
|
||
@testset "Check if CG overall exchange volume data are accessible" begin | ||
|
||
num_exchanges = 10 | ||
|
||
for duration in [5, 10, 50, 75] | ||
df_ex_vol = CryptoDashApp.get_overall_vol_data(duration, num_exchanges) | ||
|
||
# Check for rows | ||
@test size(df_ex_vol)[1] == duration | ||
|
||
# Check for columns, total is num_exchanges + 1 due to "Time" column | ||
@test size(df_ex_vol)[2] == num_exchanges + 1 | ||
end | ||
|
||
end | ||
|
||
#=@testset "Check if ratings data is accessible" begin | ||
utility_score, fcas_score, dev_score, mark_score, fcas_rating = CryptoDashApp.get_ratings_data("ETH") | ||
@test ~isempty(utility_score) | ||
@test ~isempty(fcas_score) | ||
@test ~isempty(dev_score) | ||
@test ~isempty(mark_score) | ||
@test ~isempty(fcas_rating) | ||
end=# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
################# Test cases for accessing market data ################# | ||
|
||
@testset "Check if AV market data are accessible" begin | ||
|
||
for currency in ["ETH", "LTC", "LINK"] | ||
|
||
df_out_price, df_out_candle, df_out_vol = | ||
CryptoDashApp.get_price_data_single(currency) | ||
|
||
@test ~isempty(df_out_price) | ||
@test ~isempty(df_out_candle) | ||
@test ~isempty(df_out_vol) | ||
|
||
end | ||
|
||
end | ||
|
||
@testset "Check for exception handling while accessing AV market data" begin | ||
|
||
currency = "dummy" | ||
|
||
@test_logs (:info, "Could not fetch data, try again later!") match_mode = :any CryptoDashApp.get_price_data_single( | ||
currency, | ||
) | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
################# Test cases for moving averages ################# | ||
|
||
@testset "Check if MA, MACD + signal, σ (for Bollinger bands) are calculated" begin | ||
|
||
for currency in ["BTC", "DOT"] | ||
|
||
df_out_price, _, _ = CryptoDashApp.get_price_data_single(currency) | ||
|
||
duration = 90 | ||
window = 30 | ||
|
||
price_SMA, price_WMA, price_EMA = | ||
CryptoDashApp.moving_averages(df_out_price, duration, window) | ||
|
||
@test ~isempty(price_SMA) | ||
@test ~isempty(price_WMA) | ||
@test ~isempty(price_WMA) | ||
|
||
df_out_price = df_out_price[end-duration+1-26-9+1:end, :] | ||
df_ema_all = CryptoDashApp.calculate_macd(df_out_price) | ||
@test ~isempty(df_ema_all) | ||
|
||
Price_σ = CryptoDashApp.moving_std(df_out_price, duration, window) | ||
@test ~isempty(Price_σ) | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
################# Test cases for plots using AlphaVantage data ################# | ||
|
||
@testset "plot_price_ma_trade_data" begin | ||
|
||
all_traces = CryptoDashApp.plot_price_ma_trade_data(7, 90, 30) | ||
@test ~isempty(all_traces) | ||
|
||
for trace in all_traces | ||
@test trace.fields[:y] |> length == 90 | ||
end | ||
|
||
end | ||
|
||
@testset "plot_price_bollinger_bands" begin | ||
|
||
all_traces = CryptoDashApp.plot_price_bollinger_bands(13, 180, 30) | ||
@test ~isempty(all_traces) | ||
|
||
for trace in all_traces | ||
@test trace.fields[:y] |> length == 180 | ||
end | ||
|
||
end | ||
|
||
@testset "plot_candle_vol_data" begin | ||
|
||
all_traces = CryptoDashApp.plot_candle_vol_data(18, 180) | ||
@test ~isempty(all_traces) | ||
|
||
# Check candlestick data | ||
candle_trace = all_traces[1] | ||
|
||
for candle in [:high, :low, :open, :close] | ||
@test candle_trace.fields[candle] |> length == 180 | ||
end | ||
|
||
bar_trace = all_traces[2] | ||
@test bar_trace.fields[:y] |> length == 180 | ||
|
||
end | ||
|
||
@testset "plot_cumul_daily_return_hist" begin | ||
|
||
all_traces = CryptoDashApp.plot_cumul_daily_return_hist(12, 60) | ||
@test ~isempty(all_traces) | ||
|
||
# Cumulative return | ||
@test all_traces[1].fields[:y] |> length == 59 | ||
|
||
# Green and red returns will change with time, hence cannot be tested here | ||
|
||
# Daily change histogram | ||
@test all_traces[4].fields[:y] |> length == 78 | ||
|
||
end | ||
|
||
@testset "plot_fcas_data" begin | ||
|
||
trace1 = CryptoDashApp.plot_fcas_data(13)[1] | ||
|
||
# Unable to get FCAS metrics from AV, so skipping tests for now [30-07-2022] | ||
@test_skip ~isempty(trace1) | ||
@test_skip typeof(trace1) == PlotlyBase.GenericTrace{Dict{Symbol, Any}} | ||
|
||
end | ||
|
||
@testset "plot_macd_signal" begin | ||
|
||
all_traces = CryptoDashApp.plot_macd_signal(2, 42) | ||
@test ~isempty(all_traces) | ||
|
||
for trace in all_traces | ||
trace.fields[:y] |> length == 43 | ||
end | ||
|
||
end | ||
|
||
@testset "plot_linear_regression" begin | ||
|
||
all_traces = CryptoDashApp.plot_linear_regression(17, 200) | ||
@test ~isempty(all_traces) | ||
|
||
for trace in all_traces[1:4] | ||
@test trace.fields[:y] |> length == 200 | ||
end | ||
|
||
end |
Oops, something went wrong.
e5b0ccb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register
Release notes:
e5b0ccb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request created: JuliaRegistries/General/65352
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: