Title: | Open Access to Cryptocurrency Market Data, Sentiment Indicators and Interactive Charts |
---|---|
Description: | This high-level API client provides open access to cryptocurrency market data, sentiment indicators, and interactive charting tools. The data is sourced from major cryptocurrency exchanges via 'curl' and returned in 'xts'-format. The data comes in open, high, low, and close (OHLC) format with flexible granularity, ranging from seconds to months. This flexibility makes it ideal for developing and backtesting trading strategies or conducting detailed market analysis. |
Authors: | Serkan Korkmaz [cre, aut, ctb, cph] , Jonas Cuzulan Hirani [ctb] |
Maintainer: | Serkan Korkmaz <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.3.2 |
Built: | 2024-11-08 10:25:12 UTC |
Source: | CRAN |
A high-level plotly::add_lines()
-wrapper function that
interacts with {TTR}'s moving average family of functions.
The function adds moving average indicators to the main chart()
.
alma( price = "close", n = 9, offset = 0.85, sigma = 6, ... )
alma( price = "close", n = 9, offset = 0.85, sigma = 6, ... )
price |
A character-vector of length 1. "close" by default
The name of the vector to passed into |
n |
Number of periods to average over. Must be between 1 and
|
offset |
Percentile at which the center of the distribution should occur. |
sigma |
Standard deviation of the distribution. |
... |
For internal use. Please ignore. |
A plotly::plot_ly()
-object
Serkan Korkmaz
Other chart indicators:
add_event()
,
bollinger_bands()
,
chart()
,
dema()
,
donchian_channel()
,
ema()
,
evwma()
,
fgi()
,
hma()
,
lsr()
,
macd()
,
rsi()
,
sma()
,
smi()
,
volume()
,
vwap()
,
wma()
,
zlema()
Other moving average indicators:
dema()
,
ema()
,
evwma()
,
hma()
,
sma()
,
vwap()
,
wma()
,
zlema()
Other main chart indicators:
add_event()
,
bollinger_bands()
,
dema()
,
donchian_channel()
,
ema()
,
evwma()
,
hma()
,
sma()
,
vwap()
,
wma()
,
zlema()
# script start; cryptoQuotes::chart( ticker = BTC, main = kline(), indicator = list( cryptoQuotes::ema(n = 7), cryptoQuotes::sma(n = 14), cryptoQuotes::wma(n = 21) ) ) # script end;
# script start; cryptoQuotes::chart( ticker = BTC, main = kline(), indicator = list( cryptoQuotes::ema(n = 7), cryptoQuotes::sma(n = 14), cryptoQuotes::wma(n = 21) ) ) # script end;
This dataset contains time-series data for the ATOM (ATOM) denominated in USDT (Tether), captured in 15-minute intervals. The data spans from December 30 to December 31, 2023.
ATOM
ATOM
An xts::xts()
-object with 97 rows and 5 columns,
<POSIXct> The time-index
<numeric> Opening price
<numeric> Highest price
<numeric> Lowest price
<numeric> Closing price
<numeric> Trading volume
# Load the dataset data("ATOM") # chart chart( ticker = ATOM, main = kline(), sub = list(volume()) )
# Load the dataset data("ATOM") # chart chart( ticker = ATOM, main = kline(), sub = list(volume()) )
Get a vector of all available exchanges passed into the source
argument of the get-functions.
available_exchanges( type = "ohlc" )
available_exchanges( type = "ohlc" )
type |
character-vector of length 1. One of,
|
The endpoints supported by the available_exchanges()
are not uniform,
so exchanges available for, say, get_lsratio()
is not necessarily
the same as those available for get_quote()
An invisible()
character-vector containing available exchanges
Serkan Korkmaz
Other supported calls:
available_intervals()
,
available_tickers()
# script start; # 1) available exchanges # on ohlc-v endpoint cryptoQuotes::available_exchanges( type = "ohlc" ) # 2) available exchanges # on long-short ratios cryptoQuotes::available_exchanges( type = "lsratio" ) # script end;
# script start; # 1) available exchanges # on ohlc-v endpoint cryptoQuotes::available_exchanges( type = "ohlc" ) # 2) available exchanges # on long-short ratios cryptoQuotes::available_exchanges( type = "lsratio" ) # script end;
Get available intervals for the available_tickers()
on the available_exchanges()
.
available_intervals( source = "binance", type = "ohlc", futures = TRUE )
available_intervals( source = "binance", type = "ohlc", futures = TRUE )
source |
A character-vector of length 1. |
type |
character-vector of length 1. One of,
|
futures |
A logical-vector of length 1. TRUE by default. Returns futures market if TRUE, spot market otherwise. |
The endpoints supported by the available_exchanges()
are not uniform,
so exchanges available for, say, get_lsratio()
is not necessarily
the same as those available for get_quote()
An invisible()
character-vector containing the available intervals on
the exchange, market and endpoint.
Sample output
#> i Available Intervals at "bybit" (futures): #> v 1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 12h, 1d, 1M, 1w #> [1] "1m" "3m" "5m" "15m" "30m" "1h"
Serkan Korkmaz
Other supported calls:
available_exchanges()
,
available_tickers()
## Not run: # script start; # available intervals # at kucoin futures market cryptoQuotes::available_intervals( source = 'kucoin', futures = TRUE, type = "ohlc" ) # available intervals # at kraken spot market cryptoQuotes::available_intervals( source = 'kraken', futures = FALSE, type = "ohlc" ) # script end; ## End(Not run)
## Not run: # script start; # available intervals # at kucoin futures market cryptoQuotes::available_intervals( source = 'kucoin', futures = TRUE, type = "ohlc" ) # available intervals # at kraken spot market cryptoQuotes::available_intervals( source = 'kraken', futures = FALSE, type = "ohlc" ) # script end; ## End(Not run)
Get actively traded cryptocurrency pairs on the available_exchanges()
.
available_tickers(source = "binance", futures = TRUE)
available_tickers(source = "binance", futures = TRUE)
source |
A character-vector of length 1. |
futures |
A logical-vector of length 1. TRUE by default. Returns futures market if TRUE, spot market otherwise. |
The naming-conventions across, and within, available_exchanges()
are not
necessarily the same. This function lists all actively traded tickers.
A character-vector of actively traded cryptocurrency pairs on the exchange, and the specified market.
Sample output
#> [1] "10000000AIDOGEUSDT" "1000000BABYDOGEUSDT" "1000000MOGUSDT" #> [4] "1000000PEIPEIUSDT" "10000COQUSDT" "10000LADYSUSDT"
Serkan Korkmaz
Other supported calls:
available_exchanges()
,
available_intervals()
## Not run: # 1) available tickers # in Binance spot market head( cryptoQuotes::available_tickers( source = 'binance', futures = FALSE ) ) # 2) available tickers # on Kraken futures market head( cryptoQuotes::available_tickers( source = 'kraken', futures = TRUE ) ) ## End(Not run)
## Not run: # 1) available tickers # in Binance spot market head( cryptoQuotes::available_tickers( source = 'binance', futures = FALSE ) ) # 2) available tickers # on Kraken futures market head( cryptoQuotes::available_tickers( source = 'kraken', futures = TRUE ) ) ## End(Not run)
A high-level plotly::add_lines()
-wrapper function that interacts
with the TTR::BBands()
-function. The function adds bollinger bands
to the main chart()
.
bollinger_bands( n = 20, sd = 2, maType = "SMA", color = '#4682b4', ... )
bollinger_bands( n = 20, sd = 2, maType = "SMA", color = '#4682b4', ... )
n |
Number of periods for moving average. |
sd |
The number of standard deviations to use. |
maType |
A function or a string naming the function to be called. |
color |
|
... |
Other arguments to be passed to the |
An invisible plotly::plot_ly()
-object.
Serkan Korkmaz
Other chart indicators:
add_event()
,
alma()
,
chart()
,
dema()
,
donchian_channel()
,
ema()
,
evwma()
,
fgi()
,
hma()
,
lsr()
,
macd()
,
rsi()
,
sma()
,
smi()
,
volume()
,
vwap()
,
wma()
,
zlema()
Other main chart indicators:
add_event()
,
alma()
,
dema()
,
donchian_channel()
,
ema()
,
evwma()
,
hma()
,
sma()
,
vwap()
,
wma()
,
zlema()
# script start; # Charting BTC using # candlesticks as main # chart cryptoQuotes::chart( ticker = BTC, main = cryptoQuotes::kline(), sub = list( cryptoQuotes::volume() ) ) # script end;
# script start; # Charting BTC using # candlesticks as main # chart cryptoQuotes::chart( ticker = BTC, main = cryptoQuotes::kline(), sub = list( cryptoQuotes::volume() ) ) # script end;
This dataset contains time-series data for Bitcoin (BTC) denominated in USDT (Tether), captured in weekly intervals. The data spans from January 1, 2023, to December 31, 2023.
BTC
BTC
An xts::xts()
-object with 52 rows and 5 columns,
<POSIXct> The time-index
<numeric> Opening price
<numeric> Highest price
<numeric> Lowest price
<numeric> Closing price
<numeric> Trading volume
# Load the dataset data("BTC") # chart chart( ticker = BTC, main = kline(), sub = list(volume()) )
# Load the dataset data("BTC") # chart chart( ticker = BTC, main = kline(), sub = list(volume()) )
This function is a high-level wrapper of do.call and lapply which
modifies each xts object stored in a list()
.
calibrate_window(list, FUN, ...)
calibrate_window(list, FUN, ...)
list |
A list of xts objects. |
FUN |
A function applied to each element of the list |
... |
optional arguments passed to |
Returns a xts object.
Other utility:
remove_bound()
,
split_window()
,
write_xts()
# script start; # 1) check index of BTCUSDT and # the Fear and Greed Index setequal( zoo::index(BTC), zoo::index(FGIndex) ) # 2) to align the indices, # we use the convincience functions # by splitting the FGI by the BTC index. FGIndex <- cryptoQuotes::split_window( xts = cryptoQuotes::FGIndex, by = zoo::index(BTC), # Remove upper bounds of the # index to avoid overlap between # the dates. # # This ensures that the FGI is split # according to start of each weekly # BTC candle bounds = 'upper' ) # 3) as splitWindow returns a list # it needs to passed into calibrateWindow # to ensure comparability FGIndex <- cryptoQuotes::calibrate_window( list = FGIndex, # As each element in the list can include # more than one row, each element needs to be aggregated # or summarised. # # using xts::first gives the first element # of each list, along with its values FUN = xts::first ) # 3) check if candles aligns # accordingly stopifnot( setequal( zoo::index(BTC), zoo::index(FGIndex) ) ) # script end;
# script start; # 1) check index of BTCUSDT and # the Fear and Greed Index setequal( zoo::index(BTC), zoo::index(FGIndex) ) # 2) to align the indices, # we use the convincience functions # by splitting the FGI by the BTC index. FGIndex <- cryptoQuotes::split_window( xts = cryptoQuotes::FGIndex, by = zoo::index(BTC), # Remove upper bounds of the # index to avoid overlap between # the dates. # # This ensures that the FGI is split # according to start of each weekly # BTC candle bounds = 'upper' ) # 3) as splitWindow returns a list # it needs to passed into calibrateWindow # to ensure comparability FGIndex <- cryptoQuotes::calibrate_window( list = FGIndex, # As each element in the list can include # more than one row, each element needs to be aggregated # or summarised. # # using xts::first gives the first element # of each list, along with its values FUN = xts::first ) # 3) check if candles aligns # accordingly stopifnot( setequal( zoo::index(BTC), zoo::index(FGIndex) ) ) # script end;
A high-level plotly::plot_ly()
- and plotly::subplot()
-wrapper function
for building interactive financial charts using
the affiliated chart-functions. The chart consists of a main chart, and
an optional subchart. The main chart supports overlaying various trading
indicators like sma and bollinger_bands.
chart( ticker, main = kline(), sub = list(), indicator = list(), event_data = NULL, options = list() )
chart( ticker, main = kline(), sub = list(), indicator = list(), event_data = NULL, options = list() )
ticker |
An object with Open, High, Low, Close and Volume columns that
can be coerced to a |
main |
A |
sub |
An optional list of |
indicator |
An optional list of |
event_data |
An optional data.frame with event line(s) to be added
to the |
options |
dark
A <logical>-value of length 1. TRUE by default.
Sets the overall theme of the chart()
slider
A <logical>-value of length 1. FALSE by default.
If TRUE, a plotly::rangeslider()
is added.
deficiency
A <logical>-value of length 1. FALSE by default.
If TRUE, all chart()
-elements are colorblind friendly
size
A <numeric>-value of length 1. The relative size of the
main chart. 0.6 by default. Must be between 0 and 1, non-inclusive.
scale
A <numeric>-value of length 1. 1 by default. Scales
all fonts on the chart.
width
A <numeric>-value of length 1. 0.9 by default. Sets
the width of all line elements on the chart.
static
A <logical>-value of length 1. FALSE by default. If FALSE
the chart can be edited, annotated and explored interactively.
palette
A <character>-vector of length 1. "hawaii" by default. See hcl.pals()
for
all possible color palettes.
If event_data
is passed, vertical eventlines with appropriate labels and
coloring are added to the chart()
.
This function is rigid, as it will fail if event, label and
index columns are not passed.
For more details please see add_event()
.
A plotly::plot_ly()
object.
Sample Output
Serkan Korkmaz
Other chart indicators:
add_event()
,
alma()
,
bollinger_bands()
,
dema()
,
donchian_channel()
,
ema()
,
evwma()
,
fgi()
,
hma()
,
lsr()
,
macd()
,
rsi()
,
sma()
,
smi()
,
volume()
,
vwap()
,
wma()
,
zlema()
Other price charts:
kline()
,
ohlc()
,
pline()
# script start; # 1) charting weekly # BTC using candlesticks # and indicators cryptoQuotes::chart( ticker = BTC, main = cryptoQuotes::kline(), sub = list( cryptoQuotes::volume(), cryptoQuotes::macd() ), indicator = list( cryptoQuotes::bollinger_bands(), cryptoQuotes::sma(), cryptoQuotes::alma() ), options = list( dark = TRUE, deficiency = FALSE ) ) # script end;
# script start; # 1) charting weekly # BTC using candlesticks # and indicators cryptoQuotes::chart( ticker = BTC, main = cryptoQuotes::kline(), sub = list( cryptoQuotes::volume(), cryptoQuotes::macd() ), indicator = list( cryptoQuotes::bollinger_bands(), cryptoQuotes::sma(), cryptoQuotes::alma() ), options = list( dark = TRUE, deficiency = FALSE ) ) # script end;
A high-level plotly::add_lines()
-wrapper function that
interacts with {TTR}'s moving average family of functions.
The function adds moving average indicators to the main chart()
.
dema( price = "close", n = 10, v = 1, wilder = FALSE, ratio = NULL, ... )
dema( price = "close", n = 10, v = 1, wilder = FALSE, ratio = NULL, ... )
price |
A character-vector of length 1. "close" by default.
The name of the vector to passed into |
n |
Number of periods to average over. Must be between 1 and
|
v |
The 'volume factor' (a number in [0,1]). See Notes. |
wilder |
logical; if |
ratio |
A smoothing/decay ratio. |
... |
For internal use. Please ignore. |
A plotly::plot_ly()
-object
Serkan Korkmaz
Other chart indicators:
add_event()
,
alma()
,
bollinger_bands()
,
chart()
,
donchian_channel()
,
ema()
,
evwma()
,
fgi()
,
hma()
,
lsr()
,
macd()
,
rsi()
,
sma()
,
smi()
,
volume()
,
vwap()
,
wma()
,
zlema()
Other moving average indicators:
alma()
,
ema()
,
evwma()
,
hma()
,
sma()
,
vwap()
,
wma()
,
zlema()
Other main chart indicators:
add_event()
,
alma()
,
bollinger_bands()
,
donchian_channel()
,
ema()
,
evwma()
,
hma()
,
sma()
,
vwap()
,
wma()
,
zlema()
# script start; cryptoQuotes::chart( ticker = BTC, main = kline(), indicator = list( cryptoQuotes::ema(n = 7), cryptoQuotes::sma(n = 14), cryptoQuotes::wma(n = 21) ) ) # script end;
# script start; cryptoQuotes::chart( ticker = BTC, main = kline(), indicator = list( cryptoQuotes::ema(n = 7), cryptoQuotes::sma(n = 14), cryptoQuotes::wma(n = 21) ) ) # script end;
This dataset contains time-series data for the DOGECOIN (DOGE) denominated in USDT (Tether), captured in 1-minute intervals. The data spans 2022-01-14 07:00:00 CET to 2022-01-14 08:00:00 CET.
DOGE
DOGE
An xts::xts()
-object with 61 rows and 5 columns,
<POSIXct> The time-index
<numeric> Opening price
<numeric> Highest price
<numeric> Lowest price
<numeric> Closing price
<numeric> Trading volume
# Load the dataset data("DOGE") # chart chart( ticker = DOGE, main = kline(), sub = list(volume()) )
# Load the dataset data("DOGE") # chart chart( ticker = DOGE, main = kline(), sub = list(volume()) )
A high-level plotly::add_lines()
-wrapper function that interacts
with the TTR::DonchianChannel()
-function.
The function adds Donchian Channels
to the main chart()
.
donchian_channel( n = 10, include.lag = FALSE, color = '#4682b4', ... )
donchian_channel( n = 10, include.lag = FALSE, color = '#4682b4', ... )
n |
Number of periods for moving average. |
include.lag |
Should values be lagged so that today's prices are not included in the calculation? See Note. |
color |
|
... |
For internal use. Please ignore. |
An invisible plotly::plot_ly()
-object.
Serkan Korkmaz
Other chart indicators:
add_event()
,
alma()
,
bollinger_bands()
,
chart()
,
dema()
,
ema()
,
evwma()
,
fgi()
,
hma()
,
lsr()
,
macd()
,
rsi()
,
sma()
,
smi()
,
volume()
,
vwap()
,
wma()
,
zlema()
Other main chart indicators:
add_event()
,
alma()
,
bollinger_bands()
,
dema()
,
ema()
,
evwma()
,
hma()
,
sma()
,
vwap()
,
wma()
,
zlema()
# script start; # Charting BTC using # candlesticks as main # chart cryptoQuotes::chart( ticker = BTC, main = cryptoQuotes::kline(), sub = list( cryptoQuotes::volume() ) ) # script end;
# script start; # Charting BTC using # candlesticks as main # chart cryptoQuotes::chart( ticker = BTC, main = cryptoQuotes::kline(), sub = list( cryptoQuotes::volume() ) ) # script end;
A high-level plotly::add_lines()
-wrapper function that
interacts with {TTR}'s moving average family of functions.
The function adds moving average indicators to the main chart()
.
ema( price = "close", n = 10, wilder = FALSE, ratio = NULL, ... )
ema( price = "close", n = 10, wilder = FALSE, ratio = NULL, ... )
price |
A character-vector of length 1. "close" by default.
The name of the vector to passed into |
n |
Number of periods to average over. Must be between 1 and
|
wilder |
logical; if |
ratio |
A smoothing/decay ratio. |
... |
For internal use. Please ignore. |
A plotly::plot_ly()
-object
Serkan Korkmaz
Other chart indicators:
add_event()
,
alma()
,
bollinger_bands()
,
chart()
,
dema()
,
donchian_channel()
,
evwma()
,
fgi()
,
hma()
,
lsr()
,
macd()
,
rsi()
,
sma()
,
smi()
,
volume()
,
vwap()
,
wma()
,
zlema()
Other moving average indicators:
alma()
,
dema()
,
evwma()
,
hma()
,
sma()
,
vwap()
,
wma()
,
zlema()
Other main chart indicators:
add_event()
,
alma()
,
bollinger_bands()
,
dema()
,
donchian_channel()
,
evwma()
,
hma()
,
sma()
,
vwap()
,
wma()
,
zlema()
# script start; cryptoQuotes::chart( ticker = BTC, main = kline(), indicator = list( cryptoQuotes::ema(n = 7), cryptoQuotes::sma(n = 14), cryptoQuotes::wma(n = 21) ) ) # script end;
# script start; cryptoQuotes::chart( ticker = BTC, main = kline(), indicator = list( cryptoQuotes::ema(n = 7), cryptoQuotes::sma(n = 14), cryptoQuotes::wma(n = 21) ) ) # script end;
A high-level plotly::add_lines()
-wrapper function that
interacts with {TTR}'s moving average family of functions.
The function adds moving average indicators to the main chart()
.
evwma( price = "close", n = 10, ... )
evwma( price = "close", n = 10, ... )
price |
A character-vector of length 1. "close" by default.
The name of the vector to passed into |
n |
Number of periods to average over. Must be between 1 and
|
... |
For internal use. Please ignore. |
A plotly::plot_ly()
-object
Serkan Korkmaz
Other chart indicators:
add_event()
,
alma()
,
bollinger_bands()
,
chart()
,
dema()
,
donchian_channel()
,
ema()
,
fgi()
,
hma()
,
lsr()
,
macd()
,
rsi()
,
sma()
,
smi()
,
volume()
,
vwap()
,
wma()
,
zlema()
Other moving average indicators:
alma()
,
dema()
,
ema()
,
hma()
,
sma()
,
vwap()
,
wma()
,
zlema()
Other main chart indicators:
add_event()
,
alma()
,
bollinger_bands()
,
dema()
,
donchian_channel()
,
ema()
,
hma()
,
sma()
,
vwap()
,
wma()
,
zlema()
# script start; cryptoQuotes::chart( ticker = BTC, main = kline(), indicator = list( cryptoQuotes::ema(n = 7), cryptoQuotes::sma(n = 14), cryptoQuotes::wma(n = 21) ) ) # script end;
# script start; cryptoQuotes::chart( ticker = BTC, main = kline(), indicator = list( cryptoQuotes::ema(n = 7), cryptoQuotes::sma(n = 14), cryptoQuotes::wma(n = 21) ) ) # script end;
A high-level plotly::plot_ly()
-wrapper function.
The function adds a subchart with the fear and greed
-index.
fgi(index, ...)
fgi(index, ...)
index |
A |
... |
For internal use. Please ignore. |
The Fear and Greed Index goes from 0-100, and can be classified as follows,
0-24, Extreme Fear
25-44, Fear
45-55, Neutral
56-75, Greed
76-100, Extreme Greed
The fear and greed index is a market sentiment indicator that measures investor emotions to gauge whether they are generally fearful (indicating potential selling pressure) or greedy (indicating potential buying enthusiasm).
This index is fetched from alternative.me, and can be different from the one provided by coinmarketcap.
An invisible plotly::plot_ly()
-object.
Serkan Korkmaz
Other chart indicators:
add_event()
,
alma()
,
bollinger_bands()
,
chart()
,
dema()
,
donchian_channel()
,
ema()
,
evwma()
,
hma()
,
lsr()
,
macd()
,
rsi()
,
sma()
,
smi()
,
volume()
,
vwap()
,
wma()
,
zlema()
Other sentiment indicators:
lsr()
Other subchart indicators:
add_event()
,
lsr()
,
macd()
,
rsi()
,
smi()
,
volume()
## Not run: # script start; # 1) get the fear and greed index # for the last 14 days FGIndex <- cryptoQuotes::get_fgindex( from = Sys.Date() - 14 ) # 2) get the BTC price # for the last 14 days BTC <- cryptoQuotes::get_quote( ticker = "BTCUSDT", source = "bybit", futures = FALSE, from = Sys.Date() - 14 ) # 3) chart the daily BTC # along side the Fear and # Greed Index cryptoQuotes::chart( ticker = BTC, main = kline(), sub = list( fgi( FGIndex ) ) ) # script end; ## End(Not run)
## Not run: # script start; # 1) get the fear and greed index # for the last 14 days FGIndex <- cryptoQuotes::get_fgindex( from = Sys.Date() - 14 ) # 2) get the BTC price # for the last 14 days BTC <- cryptoQuotes::get_quote( ticker = "BTCUSDT", source = "bybit", futures = FALSE, from = Sys.Date() - 14 ) # 3) chart the daily BTC # along side the Fear and # Greed Index cryptoQuotes::chart( ticker = BTC, main = kline(), sub = list( fgi( FGIndex ) ) ) # script end; ## End(Not run)
This dataset contains daily values of the Fear and Greed Index for the year 2023, which is used to measure the sentiments of investors in the market. The data spans from January 1, 2023, to December 31, 2023.
FGIndex
FGIndex
An xts::xts()
-object with 364 rows and 1 columns,
The Fear and Greed Index goes from 0-100, and can be classified as follows,
0-24, Extreme Fear
25-44, Fear
45-55, Neutral
56-75, Greed
76-100, Extreme Greed
# Load the dataset data("FGIndex") # Get a summary of index values summary(FGIndex)
# Load the dataset data("FGIndex") # Get a summary of index values summary(FGIndex)
Get the daily fear and greed index.
get_fgindex( from = NULL, to = NULL )
get_fgindex( from = NULL, to = NULL )
from |
An optional character-, date- or POSIXct-vector of length 1. NULL by default. |
to |
An optional character-, date- or POSIXct-vector of length 1. NULL by default. |
The Fear and Greed Index goes from 0-100, and can be classified as follows,
0-24, Extreme Fear
25-44, Fear
45-55, Neutral
56-75, Greed
76-100, Extreme Greed
The fear and greed index is a market sentiment indicator that measures investor emotions to gauge whether they are generally fearful (indicating potential selling pressure) or greedy (indicating potential buying enthusiasm).
This index is fetched from alternative.me, and can be different from the one provided by coinmarketcap.
An <[xts]>-object containing,
index |
<POSIXct> the time-index |
fgi |
<numeric> the daily fear and greed index value |
Sample output
#> fgi #> 2024-05-12 02:00:00 56 #> 2024-05-13 02:00:00 57 #> 2024-05-14 02:00:00 66 #> 2024-05-15 02:00:00 64 #> 2024-05-16 02:00:00 70 #> 2024-05-17 02:00:00 74
Serkan Korkmaz
Other get-functions:
get_fundingrate()
,
get_lsratio()
,
get_openinterest()
,
get_quote()
## Not run: # script start; # 1) get the fear and greed index # for the last 7 days tail( fgi <- cryptoQuotes::get_fgindex( from = Sys.Date() - 7 ) ) # script end; ## End(Not run)
## Not run: # script start; # 1) get the fear and greed index # for the last 7 days tail( fgi <- cryptoQuotes::get_fgindex( from = Sys.Date() - 7 ) ) # script end; ## End(Not run)
Get the funding rate on a cryptocurrency pair from
the available_exchanges()
in any actively
traded available_tickers()
on the futures markets.
get_fundingrate( ticker, source = 'binance', from = NULL, to = NULL )
get_fundingrate( ticker, source = 'binance', from = NULL, to = NULL )
ticker |
A character-vector of length 1.
See |
source |
A character-vector of length 1. |
from |
An optional character-, date- or POSIXct-vector of length 1. NULL by default. |
to |
An optional character-, date- or POSIXct-vector of length 1. NULL by default. |
An <[xts]>-object containing,
index |
<POSIXct> the time-index |
funding_rate |
<numeric> the current funding rate |
Sample output
#> funding_rate #> 2024-03-09 17:00:00 0.00026407 #> 2024-03-10 01:00:00 0.00031010 #> 2024-03-10 09:00:00 0.00063451 #> 2024-03-10 17:00:00 0.00054479 #> 2024-03-11 01:00:00 0.00035489 #> 2024-03-11 09:00:00 0.00078428
Serkan Korkmaz
Other get-functions:
get_fgindex()
,
get_lsratio()
,
get_openinterest()
,
get_quote()
## Not run: # script start; # 1) check available # exchanges for funding rates cryptoQuotes::available_exchanges( type = "fundingrate" ) # 2) get BTC funding rate # for the last 7 days tail( BTC <- cryptoQuotes::get_fundingrate( ticker = "BTCUSDT", source = "binance", from = Sys.Date() - 7 ) ) # script end; ## End(Not run)
## Not run: # script start; # 1) check available # exchanges for funding rates cryptoQuotes::available_exchanges( type = "fundingrate" ) # 2) get BTC funding rate # for the last 7 days tail( BTC <- cryptoQuotes::get_fundingrate( ticker = "BTCUSDT", source = "binance", from = Sys.Date() - 7 ) ) # script end; ## End(Not run)
Get the long-short ratio for any available_tickers()
from the available_exchanges()
get_lsratio( ticker, interval = '1d', source = 'binance', from = NULL, to = NULL, top = FALSE )
get_lsratio( ticker, interval = '1d', source = 'binance', from = NULL, to = NULL, top = FALSE )
ticker |
A character-vector of length 1.
See |
interval |
A character-vector of length 1. |
source |
A character-vector of length 1. |
from |
An optional character-, date- or POSIXct-vector of length 1. NULL by default. |
to |
An optional character-, date- or POSIXct-vector of length 1. NULL by default. |
top |
A logical vector. FALSE by default. If TRUE it returns the top traders Long-Short ratios. |
Values passed to from
or to
must be coercible by as.Date()
,
or as.POSIXct()
, with a format of either "%Y-%m-%d"
or
"%Y-%m-%d %H:%M:%S"
. By default all dates are passed and
returned with Sys.timezone()
.
If only from
is provided 200 pips are returned up to Sys.time()
.
If only to
is provided 200 pips up to the specified date is returned.
An xts::xts-object containing,
index |
<POSIXct> the time-index |
long |
<numeric> the share of longs |
short |
<numeric> the share of shorts |
ls_ratio |
<numeric> the ratio of longs to shorts |
Sample output
#> long short ls_ratio #> 2024-05-12 02:00:00 0.6930 0.3070 2.2573290 #> 2024-05-13 02:00:00 0.6637 0.3363 1.9735355 #> 2024-05-14 02:00:00 0.5555 0.4445 1.2497188 #> 2024-05-15 02:00:00 0.6580 0.3420 1.9239766 #> 2024-05-16 02:00:00 0.4868 0.5132 0.9485581 #> 2024-05-17 02:00:00 0.5102 0.4898 1.0416497
Jonas Cuzulan Hirani
Other get-functions:
get_fgindex()
,
get_fundingrate()
,
get_openinterest()
,
get_quote()
## Not run: # script start; LS_BTC <- cryptoQuotes::get_lsratio( ticker = 'BTCUSDT', interval = '15m', from = Sys.Date() - 1, to = Sys.Date() ) # end of scrtipt; ## End(Not run)
## Not run: # script start; LS_BTC <- cryptoQuotes::get_lsratio( ticker = 'BTCUSDT', interval = '15m', from = Sys.Date() - 1, to = Sys.Date() ) # end of scrtipt; ## End(Not run)
Get the open interest on a cryptocurrency pair from the
available_exchanges()
in any actively traded available_tickers()
on the FUTURES markets.
get_openinterest( ticker, interval = '1d', source = 'binance', from = NULL, to = NULL )
get_openinterest( ticker, interval = '1d', source = 'binance', from = NULL, to = NULL )
ticker |
A character-vector of length 1.
See |
interval |
A character-vector of length 1. |
source |
A character-vector of length 1. |
from |
An optional character-, date- or POSIXct-vector of length 1. NULL by default. |
to |
An optional character-, date- or POSIXct-vector of length 1. NULL by default. |
Values passed to from
or to
must be coercible by as.Date()
,
or as.POSIXct()
, with a format of either "%Y-%m-%d"
or
"%Y-%m-%d %H:%M:%S"
. By default all dates are passed and
returned with Sys.timezone()
.
If only from
is provided 200 pips are returned up to Sys.time()
.
If only to
is provided 200 pips up to the specified date is returned.
An <[xts]>-object containing,
index |
<POSIXct> the time-index |
open_interest |
<numeric> open perpetual contracts on both both sides |
Sample output
#> open_interest #> 2024-05-12 02:00:00 70961.07 #> 2024-05-13 02:00:00 69740.49 #> 2024-05-14 02:00:00 71110.33 #> 2024-05-15 02:00:00 67758.06 #> 2024-05-16 02:00:00 73614.70 #> 2024-05-17 02:00:00 72377.85
Serkan Korkmaz
Other get-functions:
get_fgindex()
,
get_fundingrate()
,
get_lsratio()
,
get_quote()
## Not run: # script start; # 1) check available # exchanges for open interest cryptoQuotes::available_exchanges( type = 'interest' ) # 2) get BTC funding rate # for the last 7 days tail( BTC <- cryptoQuotes::get_openinterest( ticker = "BTCUSDT", source = "binance", from = Sys.Date() - 7 ) ) # script end; ## End(Not run)
## Not run: # script start; # 1) check available # exchanges for open interest cryptoQuotes::available_exchanges( type = 'interest' ) # 2) get BTC funding rate # for the last 7 days tail( BTC <- cryptoQuotes::get_openinterest( ticker = "BTCUSDT", source = "binance", from = Sys.Date() - 7 ) ) # script end; ## End(Not run)
Get a quote on a cryptocurrency pair from the available_exchanges()
in
various available_intervals()
for any
actively traded available_tickers()
.
get_quote( ticker, source = 'binance', futures = TRUE, interval = '1d', from = NULL, to = NULL )
get_quote( ticker, source = 'binance', futures = TRUE, interval = '1d', from = NULL, to = NULL )
ticker |
A character-vector of length 1.
See |
source |
A character-vector of length 1. |
futures |
A logical-vector of length 1. TRUE by default. Returns futures market if TRUE, spot market otherwise. |
interval |
A character-vector of length 1. |
from |
An optional character-, date- or POSIXct-vector of length 1. NULL by default. |
to |
An optional character-, date- or POSIXct-vector of length 1. NULL by default. |
Values passed to from
or to
must be coercible by as.Date()
,
or as.POSIXct()
, with a format of either "%Y-%m-%d"
or
"%Y-%m-%d %H:%M:%S"
. By default all dates are passed and
returned with Sys.timezone()
.
If only from
is provided 200 pips are returned up to Sys.time()
.
If only to
is provided 200 pips up to the specified date is returned.
An <[xts]>-object containing,
index |
<POSIXct> The time-index |
open |
<numeric> Opening price |
high |
<numeric> Highest price |
low |
<numeric> Lowest price |
close |
<numeric> Closing price |
volume |
<numeric> Trading volume |
Sample output
#> open high low close volume #> 2024-05-12 02:00:00 60809.2 61849.4 60557.3 61455.8 104043.9 #> 2024-05-13 02:00:00 61455.7 63440.0 60750.0 62912.1 261927.1 #> 2024-05-14 02:00:00 62912.2 63099.6 60950.0 61550.5 244345.3 #> 2024-05-15 02:00:00 61550.5 66440.0 61316.1 66175.4 365031.7 #> 2024-05-16 02:00:00 66175.4 66800.0 64567.0 65217.7 242455.3 #> 2024-05-17 02:00:00 65217.7 66478.5 65061.2 66218.8 66139.1
Serkan Korkmaz
Other get-functions:
get_fgindex()
,
get_fundingrate()
,
get_lsratio()
,
get_openinterest()
## Not run: # script start; # get quote on # BTCUSDT pair from # Binance in 30m # intervals from the # last 24 hours tail( BTC <- cryptoQuotes::get_quote( ticker = 'BTCUSDT', source = 'binance', interval = '30m', futures = FALSE, from = Sys.Date() - 1 ) ) # script end; ## End(Not run)
## Not run: # script start; # get quote on # BTCUSDT pair from # Binance in 30m # intervals from the # last 24 hours tail( BTC <- cryptoQuotes::get_quote( ticker = 'BTCUSDT', source = 'binance', interval = '30m', futures = FALSE, from = Sys.Date() - 1 ) ) # script end; ## End(Not run)
A high-level plotly::add_lines()
-wrapper function that
interacts with {TTR}'s moving average family of functions.
The function adds moving average indicators to the main chart()
.
hma( price = "close", n = 20, ... )
hma( price = "close", n = 20, ... )
price |
A character-vector of length 1. "close" by default.
The name of the vector to passed into |
n |
Number of periods to average over. Must be between 1 and
|
... |
For internal use. Please ignore. |
A plotly::plot_ly()
-object
Serkan Korkmaz
Other chart indicators:
add_event()
,
alma()
,
bollinger_bands()
,
chart()
,
dema()
,
donchian_channel()
,
ema()
,
evwma()
,
fgi()
,
lsr()
,
macd()
,
rsi()
,
sma()
,
smi()
,
volume()
,
vwap()
,
wma()
,
zlema()
Other moving average indicators:
alma()
,
dema()
,
ema()
,
evwma()
,
sma()
,
vwap()
,
wma()
,
zlema()
Other main chart indicators:
add_event()
,
alma()
,
bollinger_bands()
,
dema()
,
donchian_channel()
,
ema()
,
evwma()
,
sma()
,
vwap()
,
wma()
,
zlema()
# script start; cryptoQuotes::chart( ticker = BTC, main = kline(), indicator = list( cryptoQuotes::ema(n = 7), cryptoQuotes::sma(n = 14), cryptoQuotes::wma(n = 21) ) ) # script end;
# script start; cryptoQuotes::chart( ticker = BTC, main = kline(), indicator = list( cryptoQuotes::ema(n = 7), cryptoQuotes::sma(n = 14), cryptoQuotes::wma(n = 21) ) ) # script end;
A high-level plotly::plot_ly()
-function for charting
Open, High, Low and Close prices.
kline(...)
kline(...)
... |
For internal use. Please ignore. |
An invisible plotly::plot_ly()
-object.
Serkan Korkmaz
Other price charts:
chart()
,
ohlc()
,
pline()
# script start; # Charting BTC using # candlesticks as main # chart cryptoQuotes::chart( ticker = BTC, main = cryptoQuotes::kline(), sub = list( cryptoQuotes::volume() ) ) # script end;
# script start; # Charting BTC using # candlesticks as main # chart cryptoQuotes::chart( ticker = BTC, main = cryptoQuotes::kline(), sub = list( cryptoQuotes::volume() ) ) # script end;
A high-level plotly::plot_ly()
-wrapper function.
The function adds a subchart to the chart with long-short ratio
.
lsr(ratio, ...)
lsr(ratio, ...)
ratio |
A |
... |
For internal use. Please ignore. |
An invisible plotly::plot_ly()
-object.
Serkan Korkmaz
Other chart indicators:
add_event()
,
alma()
,
bollinger_bands()
,
chart()
,
dema()
,
donchian_channel()
,
ema()
,
evwma()
,
fgi()
,
hma()
,
macd()
,
rsi()
,
sma()
,
smi()
,
volume()
,
vwap()
,
wma()
,
zlema()
Other sentiment indicators:
fgi()
Other subchart indicators:
add_event()
,
fgi()
,
macd()
,
rsi()
,
smi()
,
volume()
## Not run: # script start; # 1) long-short ratio # on BTCUSDT pair LS_BTC <- cryptoQuotes::get_lsratio( ticker = 'BTCUSDT', interval = '15m', from = Sys.Date() - 1, to = Sys.Date() ) # 2) BTCSDT in same period # as the long-short ratio; BTC <- cryptoQuotes::get_quote( ticker = 'BTCUSDT', futures = TRUE, interval = '15m', from = Sys.Date() - 1, to = Sys.Date() ) # 3) plot BTCUSDT-pair # with long-short ratio cryptoQuotes::chart( ticker = BTC, main = cryptoQuotes::kline(), sub = list( cryptoQuotes::lsr( ratio = LS_BTC ) ) ) # end of scrtipt; ## End(Not run)
## Not run: # script start; # 1) long-short ratio # on BTCUSDT pair LS_BTC <- cryptoQuotes::get_lsratio( ticker = 'BTCUSDT', interval = '15m', from = Sys.Date() - 1, to = Sys.Date() ) # 2) BTCSDT in same period # as the long-short ratio; BTC <- cryptoQuotes::get_quote( ticker = 'BTCUSDT', futures = TRUE, interval = '15m', from = Sys.Date() - 1, to = Sys.Date() ) # 3) plot BTCUSDT-pair # with long-short ratio cryptoQuotes::chart( ticker = BTC, main = cryptoQuotes::kline(), sub = list( cryptoQuotes::lsr( ratio = LS_BTC ) ) ) # end of scrtipt; ## End(Not run)
A high-level plotly::plot_ly()
- and plotly::add_lines()
-function that
interacts with the TTR::MACD()
-function. The function adds subchart with a
TTR::MACD()
-indicator.
macd( nFast = 12, nSlow = 26, nSig = 9, maType = "SMA", percent = TRUE, ... )
macd( nFast = 12, nSlow = 26, nSig = 9, maType = "SMA", percent = TRUE, ... )
nFast |
Number of periods for fast moving average. |
nSlow |
Number of periods for slow moving average. |
nSig |
Number of periods for signal moving average. |
maType |
Either:
|
percent |
logical; if |
... |
For internal use. Please ignore. |
An invisible plotly::plot_ly()
-object.
Serkan Korkmaz
Other chart indicators:
add_event()
,
alma()
,
bollinger_bands()
,
chart()
,
dema()
,
donchian_channel()
,
ema()
,
evwma()
,
fgi()
,
hma()
,
lsr()
,
rsi()
,
sma()
,
smi()
,
volume()
,
vwap()
,
wma()
,
zlema()
Other subchart indicators:
add_event()
,
fgi()
,
lsr()
,
rsi()
,
smi()
,
volume()
Other momentum indicators:
rsi()
,
smi()
# script start; # 1) charting weekly # BTC using candlesticks # and indicators cryptoQuotes::chart( ticker = BTC, main = cryptoQuotes::kline(), sub = list( cryptoQuotes::volume(), cryptoQuotes::macd() ), indicator = list( cryptoQuotes::bollinger_bands(), cryptoQuotes::sma(), cryptoQuotes::alma() ), options = list( dark = TRUE, deficiency = FALSE ) ) # script end;
# script start; # 1) charting weekly # BTC using candlesticks # and indicators cryptoQuotes::chart( ticker = BTC, main = cryptoQuotes::kline(), sub = list( cryptoQuotes::volume(), cryptoQuotes::macd() ), indicator = list( cryptoQuotes::bollinger_bands(), cryptoQuotes::sma(), cryptoQuotes::alma() ), options = list( dark = TRUE, deficiency = FALSE ) ) # script end;
A high-level plotly::plot_ly()
-function for charting
Open, High, Low and Close prices.
ohlc(...)
ohlc(...)
... |
For internal use. Please ignore. |
An invisible plotly::plot_ly()
-object.
Serkan Korkmaz
Other price charts:
chart()
,
kline()
,
pline()
# script start; # Charting BTC using # OHLC-bars as main # chart cryptoQuotes::chart( ticker = BTC, main = cryptoQuotes::ohlc(), sub = list( cryptoQuotes::volume() ) ) # script end;
# script start; # Charting BTC using # OHLC-bars as main # chart cryptoQuotes::chart( ticker = BTC, main = cryptoQuotes::ohlc(), sub = list( cryptoQuotes::volume() ) ) # script end;
A high-level plotly::plot_ly()
-function for charting
Open, High, Low and Close prices.
pline(price = "close", ...)
pline(price = "close", ...)
price |
|
... |
For internal use. Please ignore. |
An invisible plotly::plot_ly()
-object.
Serkan Korkmaz
Other price charts:
chart()
,
kline()
,
ohlc()
# script start; # Charting BTC using # line charts with closing price # as main chart cryptoQuotes::chart( ticker = BTC, main = cryptoQuotes::pline(), sub = list( cryptoQuotes::volume() ) ) # script end;
# script start; # Charting BTC using # line charts with closing price # as main chart cryptoQuotes::chart( ticker = BTC, main = cryptoQuotes::pline(), sub = list( cryptoQuotes::volume() ) ) # script end;
The stats::window()
-function has inclusive upper and lower bounds,
which in some cases is an undesirable feature. This high level function
removes the bounds if desired
remove_bound(xts, bounds = c("upper"))
remove_bound(xts, bounds = c("upper"))
xts |
A xts-object that needs its bounds modified. |
bounds |
A character vector of length 1.
Has to be one of |
Returns an xts-class object with its bounds removed.
Other utility:
calibrate_window()
,
split_window()
,
write_xts()
# script start; # 1) check index of BTCUSDT and # the Fear and Greed Index setequal( zoo::index(BTC), zoo::index(FGIndex) ) # 2) to align the indices, # we use the convincience functions # by splitting the FGI by the BTC index. FGIndex <- cryptoQuotes::split_window( xts = cryptoQuotes::FGIndex, by = zoo::index(BTC), # Remove upper bounds of the # index to avoid overlap between # the dates. # # This ensures that the FGI is split # according to start of each weekly # BTC candle bounds = 'upper' ) # 3) as splitWindow returns a list # it needs to passed into calibrateWindow # to ensure comparability FGIndex <- cryptoQuotes::calibrate_window( list = FGIndex, # As each element in the list can include # more than one row, each element needs to be aggregated # or summarised. # # using xts::first gives the first element # of each list, along with its values FUN = xts::first ) # 3) check if candles aligns # accordingly stopifnot( setequal( zoo::index(BTC), zoo::index(FGIndex) ) ) # script end;
# script start; # 1) check index of BTCUSDT and # the Fear and Greed Index setequal( zoo::index(BTC), zoo::index(FGIndex) ) # 2) to align the indices, # we use the convincience functions # by splitting the FGI by the BTC index. FGIndex <- cryptoQuotes::split_window( xts = cryptoQuotes::FGIndex, by = zoo::index(BTC), # Remove upper bounds of the # index to avoid overlap between # the dates. # # This ensures that the FGI is split # according to start of each weekly # BTC candle bounds = 'upper' ) # 3) as splitWindow returns a list # it needs to passed into calibrateWindow # to ensure comparability FGIndex <- cryptoQuotes::calibrate_window( list = FGIndex, # As each element in the list can include # more than one row, each element needs to be aggregated # or summarised. # # using xts::first gives the first element # of each list, along with its values FUN = xts::first ) # 3) check if candles aligns # accordingly stopifnot( setequal( zoo::index(BTC), zoo::index(FGIndex) ) ) # script end;
A high-level plotly::plot_ly()
- and plotly::add_lines()
-function that
interacts with the TTR::RSI()
-function.
The function adds a subchart with a TTR::RSI()
-indicator.
rsi( price = "close", n = 14, maType = "SMA", upper_limit = 80, lower_limit = 20, color = '#4682b4', ... )
rsi( price = "close", n = 14, maType = "SMA", upper_limit = 80, lower_limit = 20, color = '#4682b4', ... )
price |
Price series that is coercible to xts or matrix. |
n |
Number of periods for moving averages. |
maType |
Either:
|
upper_limit |
A numeric-vector of length 1. 80 by default. Sets the upper limit of the TTR::RSI. |
lower_limit |
A numeric-vector of length 1. 20 by default. Sets the lower limit of the TTR::RSI. |
color |
|
... |
For internal use. Please ignore. |
An invisible plotly::plot_ly()
-object.
Serkan Korkmaz
Other chart indicators:
add_event()
,
alma()
,
bollinger_bands()
,
chart()
,
dema()
,
donchian_channel()
,
ema()
,
evwma()
,
fgi()
,
hma()
,
lsr()
,
macd()
,
sma()
,
smi()
,
volume()
,
vwap()
,
wma()
,
zlema()
Other subchart indicators:
add_event()
,
fgi()
,
lsr()
,
macd()
,
smi()
,
volume()
Other momentum indicators:
macd()
,
smi()
# script start; # 1) charting weekly # BTC using candlesticks # and indicators cryptoQuotes::chart( ticker = BTC, main = cryptoQuotes::kline(), sub = list( cryptoQuotes::volume(), cryptoQuotes::macd() ), indicator = list( cryptoQuotes::bollinger_bands(), cryptoQuotes::sma(), cryptoQuotes::alma() ), options = list( dark = TRUE, deficiency = FALSE ) ) # script end;
# script start; # 1) charting weekly # BTC using candlesticks # and indicators cryptoQuotes::chart( ticker = BTC, main = cryptoQuotes::kline(), sub = list( cryptoQuotes::volume(), cryptoQuotes::macd() ), indicator = list( cryptoQuotes::bollinger_bands(), cryptoQuotes::sma(), cryptoQuotes::alma() ), options = list( dark = TRUE, deficiency = FALSE ) ) # script end;
A high-level plotly::add_lines()
-wrapper function that
interacts with {TTR}'s moving average family of functions.
The function adds moving average indicators to the main chart()
.
sma( price = "close", n = 10, ... )
sma( price = "close", n = 10, ... )
price |
A character-vector of length 1. "close" by default.
The name of the vector to passed into |
n |
Number of periods to average over. Must be between 1 and
|
... |
For internal use. Please ignore. |
A plotly::plot_ly()
-object
Serkan Korkmaz
Other chart indicators:
add_event()
,
alma()
,
bollinger_bands()
,
chart()
,
dema()
,
donchian_channel()
,
ema()
,
evwma()
,
fgi()
,
hma()
,
lsr()
,
macd()
,
rsi()
,
smi()
,
volume()
,
vwap()
,
wma()
,
zlema()
Other moving average indicators:
alma()
,
dema()
,
ema()
,
evwma()
,
hma()
,
vwap()
,
wma()
,
zlema()
Other main chart indicators:
add_event()
,
alma()
,
bollinger_bands()
,
dema()
,
donchian_channel()
,
ema()
,
evwma()
,
hma()
,
vwap()
,
wma()
,
zlema()
# script start; cryptoQuotes::chart( ticker = BTC, main = kline(), indicator = list( cryptoQuotes::ema(n = 7), cryptoQuotes::sma(n = 14), cryptoQuotes::wma(n = 21) ) ) # script end;
# script start; cryptoQuotes::chart( ticker = BTC, main = kline(), indicator = list( cryptoQuotes::ema(n = 7), cryptoQuotes::sma(n = 14), cryptoQuotes::wma(n = 21) ) ) # script end;
A high-level plotly::plot_ly()
- and plotly::add_lines()
-function that
interacts with the TTR::SMI()
-function.
The function adds a subchart with a TTR::SMI()
-indicator.
smi( nFastK = 14, nFastD = 3, nSlowD = 3, maType, bounded = TRUE, smooth = 1, upper_limit = 40, lower_limit = -40, color = "#4682b4", ... )
smi( nFastK = 14, nFastD = 3, nSlowD = 3, maType, bounded = TRUE, smooth = 1, upper_limit = 40, lower_limit = -40, color = "#4682b4", ... )
nFastK |
Number of periods for fast %K (i.e. the number of past periods to use). |
nFastD |
Number of periods for fast %D (i.e. the number smoothing periods to apply to fast %K). |
nSlowD |
Number of periods for slow %D (i.e. the number smoothing periods to apply to fast %D). |
maType |
Either:
|
bounded |
Logical, should current period's values be used in the calculation? |
smooth |
Number of internal smoothing periods to be applied before calculating FastK. See Details. |
upper_limit |
A numeric-vector of length 1. 40 by default. Sets the upper limit of the TTR::SMI. |
lower_limit |
A numeric-vector of length 1. -40 by default. Sets the lower limit of the TTR::SMI. |
color |
|
... |
For internal use. Please ignore. |
An invisible plotly::plot_ly()
-object.
Serkan Korkmaz
Other chart indicators:
add_event()
,
alma()
,
bollinger_bands()
,
chart()
,
dema()
,
donchian_channel()
,
ema()
,
evwma()
,
fgi()
,
hma()
,
lsr()
,
macd()
,
rsi()
,
sma()
,
volume()
,
vwap()
,
wma()
,
zlema()
Other subchart indicators:
add_event()
,
fgi()
,
lsr()
,
macd()
,
rsi()
,
volume()
Other momentum indicators:
macd()
,
rsi()
# script start; # 1) charting weekly # BTC using candlesticks # and indicators cryptoQuotes::chart( ticker = BTC, main = cryptoQuotes::kline(), sub = list( cryptoQuotes::volume(), cryptoQuotes::macd() ), indicator = list( cryptoQuotes::bollinger_bands(), cryptoQuotes::sma(), cryptoQuotes::alma() ), options = list( dark = TRUE, deficiency = FALSE ) ) # script end;
# script start; # 1) charting weekly # BTC using candlesticks # and indicators cryptoQuotes::chart( ticker = BTC, main = cryptoQuotes::kline(), sub = list( cryptoQuotes::volume(), cryptoQuotes::macd() ), indicator = list( cryptoQuotes::bollinger_bands(), cryptoQuotes::sma(), cryptoQuotes::alma() ), options = list( dark = TRUE, deficiency = FALSE ) ) # script end;
The split_window()
-function is a high level wrapper
of the stats::window()
-function which restricts the intervals between
the first and second index value iteratively
split_window(xts, by, bounds = "upper")
split_window(xts, by, bounds = "upper")
xts |
A xts-object that needs needs to be split. |
by |
A reference |
bounds |
A character vector of length 1.
Has to be one of |
Returns a list of iteratively restricted xts objects
Other utility:
calibrate_window()
,
remove_bound()
,
write_xts()
# script start; # 1) check index of BTCUSDT and # the Fear and Greed Index setequal( zoo::index(BTC), zoo::index(FGIndex) ) # 2) to align the indices, # we use the convincience functions # by splitting the FGI by the BTC index. FGIndex <- cryptoQuotes::split_window( xts = cryptoQuotes::FGIndex, by = zoo::index(BTC), # Remove upper bounds of the # index to avoid overlap between # the dates. # # This ensures that the FGI is split # according to start of each weekly # BTC candle bounds = 'upper' ) # 3) as splitWindow returns a list # it needs to passed into calibrateWindow # to ensure comparability FGIndex <- cryptoQuotes::calibrate_window( list = FGIndex, # As each element in the list can include # more than one row, each element needs to be aggregated # or summarised. # # using xts::first gives the first element # of each list, along with its values FUN = xts::first ) # 3) check if candles aligns # accordingly stopifnot( setequal( zoo::index(BTC), zoo::index(FGIndex) ) ) # script end;
# script start; # 1) check index of BTCUSDT and # the Fear and Greed Index setequal( zoo::index(BTC), zoo::index(FGIndex) ) # 2) to align the indices, # we use the convincience functions # by splitting the FGI by the BTC index. FGIndex <- cryptoQuotes::split_window( xts = cryptoQuotes::FGIndex, by = zoo::index(BTC), # Remove upper bounds of the # index to avoid overlap between # the dates. # # This ensures that the FGI is split # according to start of each weekly # BTC candle bounds = 'upper' ) # 3) as splitWindow returns a list # it needs to passed into calibrateWindow # to ensure comparability FGIndex <- cryptoQuotes::calibrate_window( list = FGIndex, # As each element in the list can include # more than one row, each element needs to be aggregated # or summarised. # # using xts::first gives the first element # of each list, along with its values FUN = xts::first ) # 3) check if candles aligns # accordingly stopifnot( setequal( zoo::index(BTC), zoo::index(FGIndex) ) ) # script end;
A high-level plotly::plot_ly()
-function.
The function adds a subchart with the trading trading
.
volume(...)
volume(...)
... |
For internal use. Please ignore. |
An invisible plotly::plot_ly()
-object.
Serkan Korkmaz
Other chart indicators:
add_event()
,
alma()
,
bollinger_bands()
,
chart()
,
dema()
,
donchian_channel()
,
ema()
,
evwma()
,
fgi()
,
hma()
,
lsr()
,
macd()
,
rsi()
,
sma()
,
smi()
,
vwap()
,
wma()
,
zlema()
Other subchart indicators:
add_event()
,
fgi()
,
lsr()
,
macd()
,
rsi()
,
smi()
# script start; # 1) charting weekly # BTC using candlesticks # and indicators cryptoQuotes::chart( ticker = BTC, main = cryptoQuotes::kline(), sub = list( cryptoQuotes::volume(), cryptoQuotes::macd() ), indicator = list( cryptoQuotes::bollinger_bands(), cryptoQuotes::sma(), cryptoQuotes::alma() ), options = list( dark = TRUE, deficiency = FALSE ) ) # script end;
# script start; # 1) charting weekly # BTC using candlesticks # and indicators cryptoQuotes::chart( ticker = BTC, main = cryptoQuotes::kline(), sub = list( cryptoQuotes::volume(), cryptoQuotes::macd() ), indicator = list( cryptoQuotes::bollinger_bands(), cryptoQuotes::sma(), cryptoQuotes::alma() ), options = list( dark = TRUE, deficiency = FALSE ) ) # script end;
A high-level plotly::add_lines()
-wrapper function that
interacts with {TTR}'s moving average family of functions.
The function adds moving average indicators to the main chart()
.
vwap( price = "close", n = 10, ratio = NULL, ... )
vwap( price = "close", n = 10, ratio = NULL, ... )
price |
A character-vector of length 1. "close" by default.
The name of the vector to passed into |
n |
Number of periods to average over. Must be between 1 and
|
ratio |
A smoothing/decay ratio. |
... |
For internal use. Please ignore. |
A plotly::plot_ly()
-object
Serkan Korkmaz
Other chart indicators:
add_event()
,
alma()
,
bollinger_bands()
,
chart()
,
dema()
,
donchian_channel()
,
ema()
,
evwma()
,
fgi()
,
hma()
,
lsr()
,
macd()
,
rsi()
,
sma()
,
smi()
,
volume()
,
wma()
,
zlema()
Other moving average indicators:
alma()
,
dema()
,
ema()
,
evwma()
,
hma()
,
sma()
,
wma()
,
zlema()
Other main chart indicators:
add_event()
,
alma()
,
bollinger_bands()
,
dema()
,
donchian_channel()
,
ema()
,
evwma()
,
hma()
,
sma()
,
wma()
,
zlema()
# script start; cryptoQuotes::chart( ticker = BTC, main = kline(), indicator = list( cryptoQuotes::ema(n = 7), cryptoQuotes::sma(n = 14), cryptoQuotes::wma(n = 21) ) ) # script end;
# script start; cryptoQuotes::chart( ticker = BTC, main = kline(), indicator = list( cryptoQuotes::ema(n = 7), cryptoQuotes::sma(n = 14), cryptoQuotes::wma(n = 21) ) ) # script end;
A high-level plotly::add_lines()
-wrapper function that
interacts with {TTR}'s moving average family of functions.
The function adds moving average indicators to the main chart()
.
wma( price = "close", n = 10, wts = 1:n, ... )
wma( price = "close", n = 10, wts = 1:n, ... )
price |
A character-vector of length 1. "close" by default.
The name of the vector to passed into |
n |
Number of periods to average over. Must be between 1 and
|
wts |
Vector of weights. Length of |
... |
For internal use. Please ignore. |
A plotly::plot_ly()
-object
Serkan Korkmaz
Other chart indicators:
add_event()
,
alma()
,
bollinger_bands()
,
chart()
,
dema()
,
donchian_channel()
,
ema()
,
evwma()
,
fgi()
,
hma()
,
lsr()
,
macd()
,
rsi()
,
sma()
,
smi()
,
volume()
,
vwap()
,
zlema()
Other moving average indicators:
alma()
,
dema()
,
ema()
,
evwma()
,
hma()
,
sma()
,
vwap()
,
zlema()
Other main chart indicators:
add_event()
,
alma()
,
bollinger_bands()
,
dema()
,
donchian_channel()
,
ema()
,
evwma()
,
hma()
,
sma()
,
vwap()
,
zlema()
# script start; cryptoQuotes::chart( ticker = BTC, main = kline(), indicator = list( cryptoQuotes::ema(n = 7), cryptoQuotes::sma(n = 14), cryptoQuotes::wma(n = 21) ) ) # script end;
# script start; cryptoQuotes::chart( ticker = BTC, main = kline(), indicator = list( cryptoQuotes::ema(n = 7), cryptoQuotes::sma(n = 14), cryptoQuotes::wma(n = 21) ) ) # script end;
xts
-objectsThe write_xts()
- and read_xts()
-functions are zoo::write.zoo()
- and zoo::read.zoo()
-wrapper functions.
# write XTS-object write_xts( x, file, ... ) # read XTS-object read_xts( file )
# write XTS-object write_xts( x, file, ... ) # read XTS-object read_xts( file )
x |
An <[xts]>-object. |
file |
character string or strings giving the name of the file(s)
which the data
are to be read from/written to. See |
... |
further arguments passed to other functions. In the |
When reading and writing <[xts]>-objects the attributes does not follow the object.
Serkan Korkmaz
Other utility:
calibrate_window()
,
remove_bound()
,
split_window()
Other utility:
calibrate_window()
,
remove_bound()
,
split_window()
A high-level plotly::add_lines()
-wrapper function that
interacts with {TTR}'s moving average family of functions.
The function adds moving average indicators to the main chart()
.
zlema( price = "close", n = 10, ratio = NULL, ... )
zlema( price = "close", n = 10, ratio = NULL, ... )
price |
A character-vector of length 1. "close" by default.
The name of the vector to passed into |
n |
Number of periods to average over. Must be between 1 and
|
ratio |
A smoothing/decay ratio. |
... |
For internal use. Please ignore. |
A plotly::plot_ly()
-object
Serkan Korkmaz
Other chart indicators:
add_event()
,
alma()
,
bollinger_bands()
,
chart()
,
dema()
,
donchian_channel()
,
ema()
,
evwma()
,
fgi()
,
hma()
,
lsr()
,
macd()
,
rsi()
,
sma()
,
smi()
,
volume()
,
vwap()
,
wma()
Other moving average indicators:
alma()
,
dema()
,
ema()
,
evwma()
,
hma()
,
sma()
,
vwap()
,
wma()
Other main chart indicators:
add_event()
,
alma()
,
bollinger_bands()
,
dema()
,
donchian_channel()
,
ema()
,
evwma()
,
hma()
,
sma()
,
vwap()
,
wma()
# script start; cryptoQuotes::chart( ticker = BTC, main = kline(), indicator = list( cryptoQuotes::ema(n = 7), cryptoQuotes::sma(n = 14), cryptoQuotes::wma(n = 21) ) ) # script end;
# script start; cryptoQuotes::chart( ticker = BTC, main = kline(), indicator = list( cryptoQuotes::ema(n = 7), cryptoQuotes::sma(n = 14), cryptoQuotes::wma(n = 21) ) ) # script end;