Title: | Open Access to Cryptocurrency Market Data, Sentiment Indicators and Interactive Charts |
Version: | 1.3.2 |
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. |
License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
Encoding: | UTF-8 |
RoxygenNote: | 7.3.2 |
Suggests: | data.table, knitr, quantmod, rmarkdown, testthat (≥ 3.0.0), tidyverse |
Config/testthat/edition: | 3 |
Imports: | cli (≥ 3.6.3), curl (≥ 5.2.1), jsonlite (≥ 1.8.8), lifecycle (≥ 1.0.4), plotly (≥ 4.10.4), TTR (≥ 0.24.4), utils, xts (≥ 0.14.0), zoo (≥ 1.8-12) |
Depends: | R (≥ 4.0.0) |
LazyData: | true |
VignetteBuilder: | knitr |
URL: | https://serkor1.github.io/cryptoQuotes/, https://github.com/serkor1/cryptoQuotes |
BugReports: | https://github.com/serkor1/cryptoQuotes/issues |
NeedsCompilation: | no |
Packaged: | 2024-11-07 12:08:12 UTC; serkan |
Author: | Serkan Korkmaz |
Maintainer: | Serkan Korkmaz <serkor1@duck.com> |
Repository: | CRAN |
Date/Publication: | 2024-11-07 12:30:11 UTC |
cryptoQuotes: 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.
Author(s)
Maintainer: Serkan Korkmaz serkor1@duck.com (ORCID) [contributor, copyright holder]
Other contributors:
Jonas Cuzulan Hirani jjh@vive.dk (ORCID) [contributor]
See Also
Useful links:
Report bugs at https://github.com/serkor1/cryptoQuotes/issues
USDT Denominated ATOM (ATOMUSDT) 15-Minute Intervals
Description
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.
Usage
ATOM
Format
An xts::xts()
-object with 97 rows and 5 columns,
- 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
Examples
# Load the dataset
data("ATOM")
# chart
chart(
ticker = ATOM,
main = kline(),
sub = list(volume())
)
USDT Denominated Bitcoin (BTCUSDT) Weekly Intervals
Description
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.
Usage
BTC
Format
An xts::xts()
-object with 52 rows and 5 columns,
- 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
Examples
# Load the dataset
data("BTC")
# chart
chart(
ticker = BTC,
main = kline(),
sub = list(volume())
)
USDT Denominated DOGECOIN (DOGEUSDT) 1-Minute Intervals
Description
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.
Usage
DOGE
Format
An xts::xts()
-object with 61 rows and 5 columns,
- 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
Examples
# Load the dataset
data("DOGE")
# chart
chart(
ticker = DOGE,
main = kline(),
sub = list(volume())
)
Fear and Greed Index (FGI) values for the cryptocurrency market in daily intervals
Description
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.
Usage
FGIndex
Format
An xts::xts()
-object with 364 rows and 1 columns,
Details
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
Examples
# Load the dataset
data("FGIndex")
# Get a summary of index values
summary(FGIndex)
GET-requests
Description
GET-requests
Usage
GET(url, endpoint = NULL, query = NULL, path = NULL)
Arguments
url |
character of length 1. The baseurl |
endpoint |
character of length 1. The API endpoint |
query |
A named list of queries. |
path |
A list of paths. |
Value
A list crated by jsonlite::fromJSON()
See Also
Other development tools:
chart_layout()
,
convert_date()
,
default_dates()
,
fetch()
,
flatten()
,
is.date()
Examples
## Not run:
# script start;
exchange <- "bybit"
futures <- FALSE
# 1) define baseurl
base_url <- cryptoQuotes:::baseUrl(
source = exchange,
futures = futures
)
# 2) define endpoint
end_point <- cryptoQuotes:::endPoint(
source = "bybit",
futures = futures,
type = "ohlc"
)
# 2) define actual
# parameters based on
# API docs
queries <- list(
symbol = "BTCUSDT",
category = "spot",
limit = 100,
interval = "D"
)
# 3) perform GET request
cryptoQuotes:::GET(
url = base_url,
endpoint = end_point,
query = queries
)
# script end;
## End(Not run)
Add eventlines to the chart
Description
A high-level plotly::layout()
-function.
The function adds shapes
and annotations
to the main chart()
.
Usage
add_event(data, ...)
Arguments
data |
a data.frame-type object with |
... |
For internal use. Please ignore. |
Details
The data.frame must include the following columns,
Value
A plotly::plot_ly()
-object with shapes
and annotations
Author(s)
Serkan Korkmaz
See Also
Other chart indicators:
alma()
,
bollinger_bands()
,
chart()
,
dema()
,
donchian_channel()
,
ema()
,
evwma()
,
fgi()
,
hma()
,
lsr()
,
macd()
,
rsi()
,
sma()
,
smi()
,
volume()
,
vwap()
,
wma()
,
zlema()
Other subchart indicators:
fgi()
,
lsr()
,
macd()
,
rsi()
,
smi()
,
volume()
Other main chart indicators:
alma()
,
bollinger_bands()
,
dema()
,
donchian_channel()
,
ema()
,
evwma()
,
hma()
,
sma()
,
vwap()
,
wma()
,
zlema()
Examples
# script start;
# 1) Generate random events
# of buys and sells and convert
# to data.frame
#
# Note: tibbles, data.tables are also supported
# but only base R is shown here to avoid
# too many dependencies
set.seed(1903)
event_data <- cryptoQuotes::ATOM[
sample(
x = 1:nrow(cryptoQuotes::ATOM),
size = 2
)
]
# 1.1) Extract the index
# from the event data
index <- zoo::index(
event_data
)
# 1.2) Convert the coredata
# into a data.frame
event_data <- as.data.frame(
zoo::coredata(
event_data
)
)
# 1.3) Add the index into the data.frame
# case insensitive
event_data$index <- index
# 1.4) add events to the data.
# here we use Buys and Sells.
event_data$event <- rep(
x = c('Buy', 'Sell'),
lenght.out = nrow(event_data)
)
# 1.5) add colors based
# on the event; here buy is colored
# darkgrey, and if the position is closed
# with profit the color is green
event_data$color <- ifelse(
event_data$event == 'Buy',
yes = 'darkgrey',
no = ifelse(
test = subset(
x = event_data,
event == 'Buy')$close < subset(x = event_data, event == 'Sell')$close,
yes = 'green',
no = 'red'
)
)
# 1.6) modify the event to add
# closing price at each event
event_data$event <- paste0(
event_data$event, ' @', event_data$close
)
# 2) Chart the the klines
# and add the buy and sell events
cryptoQuotes::chart(
ticker = cryptoQuotes::ATOM,
main = cryptoQuotes::kline(),
sub = list(
cryptoQuotes::volume()
),
indicator = list(
cryptoQuotes::bollinger_bands()
),
event_data = event_data,
options = list(
dark = TRUE,
deficiency = FALSE
)
)
# script end;
Add Arnaud Legoux Moving Average (ALMA) to the chart
Description
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()
.
Usage
alma(
price = "close",
n = 9,
offset = 0.85,
sigma = 6,
...
)
Arguments
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. |
Value
A plotly::plot_ly()
-object
Author(s)
Serkan Korkmaz
See Also
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()
Examples
# script start;
cryptoQuotes::chart(
ticker = BTC,
main = kline(),
indicator = list(
cryptoQuotes::ema(n = 7),
cryptoQuotes::sma(n = 14),
cryptoQuotes::wma(n = 21)
)
)
# script end;
Assert truthfulness of conditions before evaluation
Description
This function is a wrapper of stopifnot()
, tryCatch()
and
cli::cli_abort()
and asserts the truthfulness of the passed expression(s).
Usage
assert(..., error_message = NULL)
Arguments
... |
expressions >= 1. If named the names are used as error messages, otherwise R's internal error-messages are thrown |
error_message |
character. An error message, supports cli::cli-formatting. |
Value
NULL if all statements in ... are TRUE
See Also
stopifnot()
, cli::cli_abort()
, tryCatch()
Examples
## Not run:
# script start;
# 1) unnamed assert
# expressions
foo <- function(
a,
b) {
# assert without
# named expressions
cryptoQuotes:::assert(
is.numeric(a),
is.numeric(b)
)
a + b
}
# 1.1) returns
# the regular R error
# messages in cli-format
foo(
a = "1",
b = "2"
)
# 2) named assert
# expressions
foo <- function(
a,
b) {
cryptoQuotes:::assert(
"{.arg a} is not {.cls numeric}" = is.numeric(a),
"{.arg a} is not {.cls numeric}" = is.numeric(b)
)
a + b
}
# 2.2) Returns
# custom error-messages
# in cli-format
foo(
a = "1",
b = "2"
)
# 3) custom error
# messages on
foo <- function(
a) {
cryptoQuotes:::assert(
is.numeric(a),
error_message = sprintf(
fmt = "{.val %s} is not a numeric value.",
a
)
)
a
}
# 2.2) Returns
# custom error-messages with
# passed values in cli-format
foo(
a = "1"
)
# script end;
## End(Not run)
Get available exchanges
Description
Get a vector of all available exchanges passed into the source
argument of the get-functions.
Usage
available_exchanges(
type = "ohlc"
)
Arguments
type |
character-vector of length 1. One of,
|
Details
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()
Value
An invisible()
character-vector containing available exchanges
Author(s)
Serkan Korkmaz
See Also
Other supported calls:
available_intervals()
,
available_tickers()
Examples
# 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
Description
Get available intervals for the available_tickers()
on the available_exchanges()
.
Usage
available_intervals(
source = "binance",
type = "ohlc",
futures = TRUE
)
Arguments
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. |
Details
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()
Value
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"
Author(s)
Serkan Korkmaz
See Also
Other supported calls:
available_exchanges()
,
available_tickers()
Examples
## 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
Description
Get actively traded cryptocurrency pairs on the available_exchanges()
.
Usage
available_tickers(source = "binance", futures = TRUE)
Arguments
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. |
Details
The naming-conventions across, and within, available_exchanges()
are not
necessarily the same. This function lists all actively traded tickers.
Value
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"
Author(s)
Serkan Korkmaz
See Also
Other supported calls:
available_exchanges()
,
available_intervals()
Examples
## 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)
Add Bollinger Bands to the chart
Description
A high-level plotly::add_lines()
-wrapper function that interacts
with the TTR::BBands()
-function. The function adds bollinger bands
to the main chart()
.
Usage
bollinger_bands(
n = 20,
sd = 2,
maType = "SMA",
color = '#4682b4',
...
)
Arguments
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 |
Value
An invisible plotly::plot_ly()
-object.
Author(s)
Serkan Korkmaz
See Also
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()
Examples
# script start;
# Charting BTC using
# candlesticks as main
# chart
cryptoQuotes::chart(
ticker = BTC,
main = cryptoQuotes::kline(),
sub = list(
cryptoQuotes::volume()
)
)
# script end;
calibrate the time window of a list of xts objects
Description
This function is a high-level wrapper of do.call and lapply which
modifies each xts object stored in a list()
.
Usage
calibrate_window(list, FUN, ...)
Arguments
list |
A list of xts objects. |
FUN |
A function applied to each element of the list |
... |
optional arguments passed to |
Value
Returns a xts object.
See Also
Other utility:
remove_bound()
,
split_window()
,
write_xts()
Examples
# 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;
Build an interactive financial chart
Description
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.
Usage
chart(
ticker,
main = kline(),
sub = list(),
indicator = list(),
event_data = NULL,
options = list()
)
Arguments
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 |
Details
Options
-
dark
A <logical>-value of length 1. TRUE by default. Sets the overall theme of thechart()
-
slider
A <logical>-value of length 1. FALSE by default. If TRUE, aplotly::rangeslider()
is added. -
deficiency
A <logical>-value of length 1. FALSE by default. If TRUE, allchart()
-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. Seehcl.pals()
for all possible color palettes.
Charting Events
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()
.
Value
A plotly::plot_ly()
object.
Sample Output
Author(s)
Serkan Korkmaz
See Also
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()
Examples
# 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;
Create a list of layout elements on subcharts
Description
Create a list of layout elements on subcharts
Usage
chart_layout(x, layout_element, layout_attribute)
Arguments
x |
|
layout_element |
character-vector of length 1. plotly::layout elements. See example. |
layout_attribute |
character-vector of length 1. plotly::layout element value. See example. |
Value
A list of layout elements.
See Also
Other development tools:
GET()
,
convert_date()
,
default_dates()
,
fetch()
,
flatten()
,
is.date()
Examples
## Not run:
chart_layout(
x = 1:plot_list_length,
layout_element = "yaxis",
layout_attribute = list(
gridcolor = if (dark) "#40454c" else '#D3D3D3' # Was CCCCCC
)
)
## End(Not run)
Convert dates passed to UNIX
Description
This function converts dates to UNIX time if passed to the API, and converts it to POSIXct from API
Usage
convert_date(x, multiplier)
Arguments
x |
|
multiplier |
Details
If x is numeric, then the function assumes that its a return value
Value
A vector of same length as x.
See Also
Other development tools:
GET()
,
chart_layout()
,
default_dates()
,
fetch()
,
flatten()
,
is.date()
Get the minimum and maximum date range
Description
All available_exchanges()
have different limitations on the
returned data this function is adaptive in nature so enforces
compliance on the limits
Usage
default_dates(interval, from = NULL, to = NULL, length = 200, limit = NULL)
Arguments
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. |
length |
a numeric-value of length 1.
The desired distance between |
Value
A vector of minimum and maximum dates.
Author(s)
Serkan Korkmaz
See Also
Other development tools:
GET()
,
chart_layout()
,
convert_date()
,
fetch()
,
flatten()
,
is.date()
Add Double Exponential Moving Average (DEMA) to the chart
Description
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()
.
Usage
dema(
price = "close",
n = 10,
v = 1,
wilder = FALSE,
ratio = NULL,
...
)
Arguments
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. |
Value
A plotly::plot_ly()
-object
Author(s)
Serkan Korkmaz
See Also
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()
Examples
# script start;
cryptoQuotes::chart(
ticker = BTC,
main = kline(),
indicator = list(
cryptoQuotes::ema(n = 7),
cryptoQuotes::sma(n = 14),
cryptoQuotes::wma(n = 21)
)
)
# script end;
Add Donchian Channels to the chart
Description
A high-level plotly::add_lines()
-wrapper function that interacts
with the TTR::DonchianChannel()
-function.
The function adds Donchian Channels
to the main chart()
.
Usage
donchian_channel(
n = 10,
include.lag = FALSE,
color = '#4682b4',
...
)
Arguments
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. |
Value
An invisible plotly::plot_ly()
-object.
Author(s)
Serkan Korkmaz
See Also
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()
Examples
# script start;
# Charting BTC using
# candlesticks as main
# chart
cryptoQuotes::chart(
ticker = BTC,
main = cryptoQuotes::kline(),
sub = list(
cryptoQuotes::volume()
)
)
# script end;
Add Exponentially-Weighted Moving Average (EMA) to the chart
Description
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()
.
Usage
ema(
price = "close",
n = 10,
wilder = FALSE,
ratio = NULL,
...
)
Arguments
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. |
Value
A plotly::plot_ly()
-object
Author(s)
Serkan Korkmaz
See Also
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()
Examples
# script start;
cryptoQuotes::chart(
ticker = BTC,
main = kline(),
indicator = list(
cryptoQuotes::ema(n = 7),
cryptoQuotes::sma(n = 14),
cryptoQuotes::wma(n = 21)
)
)
# script end;
Add Elastic Volume-Weighted Moving Average (EVWMA) to the chart
Description
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()
.
Usage
evwma(
price = "close",
n = 10,
...
)
Arguments
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. |
Value
A plotly::plot_ly()
-object
Author(s)
Serkan Korkmaz
See Also
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()
Examples
# script start;
cryptoQuotes::chart(
ticker = BTC,
main = kline(),
indicator = list(
cryptoQuotes::ema(n = 7),
cryptoQuotes::sma(n = 14),
cryptoQuotes::wma(n = 21)
)
)
# script end;
Fetch time-based API-endpoint responses
Description
This function is a high-level wrapper around the development tools available and should reduce the amount of coding.
Usage
fetch(ticker, source, futures, interval, type, to, from, ...)
Arguments
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. |
type |
character-vector of length 1. One of,
|
to |
An optional character-, date- or POSIXct-vector of length 1. NULL by default. |
from |
An optional character-, date- or POSIXct-vector of length 1. NULL by default. |
... |
additional parameters passed down the endpoint |
Details
This function can only be used to fetch time-based objects,
and can therefore not be used to get, for example, available_tickers()
.
Value
It returns an xts::xts-object from the desired endpoint.
Author(s)
Serkan Korkmaz
See Also
Other development tools:
GET()
,
chart_layout()
,
convert_date()
,
default_dates()
,
flatten()
,
is.date()
Chart the Fear and Greed Index
Description
A high-level plotly::plot_ly()
-wrapper function.
The function adds a subchart with the fear and greed
-index.
Usage
fgi(index, ...)
Arguments
index |
A |
... |
For internal use. Please ignore. |
Details
Classification
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
About the Fear and Greed Index
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).
Source
This index is fetched from alternative.me, and can be different from the one provided by coinmarketcap.
Value
An invisible plotly::plot_ly()
-object.
Author(s)
Serkan Korkmaz
See Also
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()
Examples
## 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)
flatten nested lists
Description
Flatten a nested list, regardless of its level of nesting.
Usage
flatten(x)
Arguments
x |
A list |
Value
An unnested list
See Also
Other development tools:
GET()
,
chart_layout()
,
convert_date()
,
default_dates()
,
fetch()
,
is.date()
Examples
# script start;
# 1) create a nested list
nested_list <- list(
a = 1,
b = list(
c = 2,
d = 3
)
)
# 2) flatten the
# nested list
cryptoQuotes:::flatten(
nested_list
)
# script end;
Get the daily Fear and Greed Index in the cryptocurrency market
Description
Get the daily fear and greed index.
Usage
get_fgindex(
from = NULL,
to = NULL
)
Arguments
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. |
Details
Classification
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
About the Fear and Greed Index
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).
Source
This index is fetched from alternative.me, and can be different from the one provided by coinmarketcap.
Value
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
Author(s)
Serkan Korkmaz
See Also
Other get-functions:
get_fundingrate()
,
get_lsratio()
,
get_openinterest()
,
get_quote()
Examples
## 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 futures contracts
Description
Get the funding rate on a cryptocurrency pair from
the available_exchanges()
in any actively
traded available_tickers()
on the futures markets.
Usage
get_fundingrate(
ticker,
source = 'binance',
from = NULL,
to = NULL
)
Arguments
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. |
Value
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
Author(s)
Serkan Korkmaz
See Also
Other get-functions:
get_fgindex()
,
get_lsratio()
,
get_openinterest()
,
get_quote()
Examples
## 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 to short ratio of a cryptocurrency pair
Description
Get the long-short ratio for any available_tickers()
from the available_exchanges()
Usage
get_lsratio(
ticker,
interval = '1d',
source = 'binance',
from = NULL,
to = NULL,
top = FALSE
)
Arguments
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. |
Details
On time-zones and dates
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()
.
On returns
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.
Value
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
Author(s)
Jonas Cuzulan Hirani
See Also
Other get-functions:
get_fgindex()
,
get_fundingrate()
,
get_openinterest()
,
get_quote()
Examples
## 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 perpetual futures contracts
Description
Get the open interest on a cryptocurrency pair from the
available_exchanges()
in any actively traded available_tickers()
on the FUTURES markets.
Usage
get_openinterest(
ticker,
interval = '1d',
source = 'binance',
from = NULL,
to = NULL
)
Arguments
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. |
Details
On time-zones and dates
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()
.
On returns
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.
Value
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
Author(s)
Serkan Korkmaz
See Also
Other get-functions:
get_fgindex()
,
get_fundingrate()
,
get_lsratio()
,
get_quote()
Examples
## 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 the Open, High, Low, Close and Volume data on a cryptocurrency pair
Description
Get a quote on a cryptocurrency pair from the available_exchanges()
in
various available_intervals()
for any
actively traded available_tickers()
.
Usage
get_quote(
ticker,
source = 'binance',
futures = TRUE,
interval = '1d',
from = NULL,
to = NULL
)
Arguments
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. |
Details
On time-zones and dates
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()
.
On returns
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.
Value
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
Author(s)
Serkan Korkmaz
See Also
Other get-functions:
get_fgindex()
,
get_fundingrate()
,
get_lsratio()
,
get_openinterest()
Examples
## 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)
Add Hull Moving Average (HMA) to the chart
Description
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()
.
Usage
hma(
price = "close",
n = 20,
...
)
Arguments
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. |
Value
A plotly::plot_ly()
-object
Author(s)
Serkan Korkmaz
See Also
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()
Examples
# script start;
cryptoQuotes::chart(
ticker = BTC,
main = kline(),
indicator = list(
cryptoQuotes::ema(n = 7),
cryptoQuotes::sma(n = 14),
cryptoQuotes::wma(n = 21)
)
)
# script end;
Check if values are valid dates
Description
This function check is equivalent to is.numeric()
, is.logical()
,
and checks for the date type classes POSIXct, POSIXt and Date.
And wether the character vector can be formatted to dates.
Usage
is.date(x)
Arguments
x |
object to be tested |
Value
TRUE if its either POSIXct, POSIXt or Date. FALSE otherwise.
See Also
Other development tools:
GET()
,
chart_layout()
,
convert_date()
,
default_dates()
,
fetch()
,
flatten()
Candlestick Chart
Description
A high-level plotly::plot_ly()
-function for charting
Open, High, Low and Close prices.
Usage
kline(...)
Arguments
... |
For internal use. Please ignore. |
Value
An invisible plotly::plot_ly()
-object.
Author(s)
Serkan Korkmaz
See Also
Other price charts:
chart()
,
ohlc()
,
pline()
Examples
# script start;
# Charting BTC using
# candlesticks as main
# chart
cryptoQuotes::chart(
ticker = BTC,
main = cryptoQuotes::kline(),
sub = list(
cryptoQuotes::volume()
)
)
# script end;
Chart the long-short ratio
Description
A high-level plotly::plot_ly()
-wrapper function.
The function adds a subchart to the chart with long-short ratio
.
Usage
lsr(ratio, ...)
Arguments
ratio |
A |
... |
For internal use. Please ignore. |
Value
An invisible plotly::plot_ly()
-object.
Author(s)
Serkan Korkmaz
See Also
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()
Examples
## 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)
Chart the Moving Average Convergence Divergence (MACD) indicator
Description
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.
Usage
macd(
nFast = 12,
nSlow = 26,
nSig = 9,
maType = "SMA",
percent = TRUE,
...
)
Arguments
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. |
Value
An invisible plotly::plot_ly()
-object.
Author(s)
Serkan Korkmaz
See Also
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()
Examples
# 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;
OHLC Barchart
Description
A high-level plotly::plot_ly()
-function for charting
Open, High, Low and Close prices.
Usage
ohlc(...)
Arguments
... |
For internal use. Please ignore. |
Value
An invisible plotly::plot_ly()
-object.
Author(s)
Serkan Korkmaz
See Also
Other price charts:
chart()
,
kline()
,
pline()
Examples
# script start;
# Charting BTC using
# OHLC-bars as main
# chart
cryptoQuotes::chart(
ticker = BTC,
main = cryptoQuotes::ohlc(),
sub = list(
cryptoQuotes::volume()
)
)
# script end;
Line Chart
Description
A high-level plotly::plot_ly()
-function for charting
Open, High, Low and Close prices.
Usage
pline(price = "close", ...)
Arguments
price |
|
... |
For internal use. Please ignore. |
Value
An invisible plotly::plot_ly()
-object.
Author(s)
Serkan Korkmaz
See Also
Other price charts:
chart()
,
kline()
,
ohlc()
Examples
# 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;
remove upper and lower bounds from an XTS object
Description
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
Usage
remove_bound(xts, bounds = c("upper"))
Arguments
xts |
A xts-object that needs its bounds modified. |
bounds |
A character vector of length 1.
Has to be one of |
Value
Returns an xts-class object with its bounds removed.
See Also
Other utility:
calibrate_window()
,
split_window()
,
write_xts()
Examples
# 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;
Chart the Relative Strength Index (RSI)
Description
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.
Usage
rsi(
price = "close",
n = 14,
maType = "SMA",
upper_limit = 80,
lower_limit = 20,
color = '#4682b4',
...
)
Arguments
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. |
Value
An invisible plotly::plot_ly()
-object.
Author(s)
Serkan Korkmaz
See Also
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()
Examples
# 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;
Add Simple Moving Average (SMA) indicators to the chart
Description
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()
.
Usage
sma(
price = "close",
n = 10,
...
)
Arguments
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. |
Value
A plotly::plot_ly()
-object
Author(s)
Serkan Korkmaz
See Also
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()
Examples
# script start;
cryptoQuotes::chart(
ticker = BTC,
main = kline(),
indicator = list(
cryptoQuotes::ema(n = 7),
cryptoQuotes::sma(n = 14),
cryptoQuotes::wma(n = 21)
)
)
# script end;
Chart the Stochastic Momentum Index (SMI)
Description
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.
Usage
smi(
nFastK = 14,
nFastD = 3,
nSlowD = 3,
maType,
bounded = TRUE,
smooth = 1,
upper_limit = 40,
lower_limit = -40,
color = "#4682b4",
...
)
Arguments
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. |
Value
An invisible plotly::plot_ly()
-object.
Author(s)
Serkan Korkmaz
See Also
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()
Examples
# 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;
split xts object iteratively in lists of desired intervals
Description
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
Usage
split_window(xts, by, bounds = "upper")
Arguments
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 |
Value
Returns a list of iteratively restricted xts objects
See Also
Other utility:
calibrate_window()
,
remove_bound()
,
write_xts()
Examples
# 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;
Chart the trading volume
Description
A high-level plotly::plot_ly()
-function.
The function adds a subchart with the trading trading
.
Usage
volume(...)
Arguments
... |
For internal use. Please ignore. |
Value
An invisible plotly::plot_ly()
-object.
Author(s)
Serkan Korkmaz
See Also
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()
Examples
# 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;
Add Volume-Weighted Moving Average (VWAP) to the chart
Description
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()
.
Usage
vwap(
price = "close",
n = 10,
ratio = NULL,
...
)
Arguments
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. |
Value
A plotly::plot_ly()
-object
Author(s)
Serkan Korkmaz
See Also
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()
Examples
# script start;
cryptoQuotes::chart(
ticker = BTC,
main = kline(),
indicator = list(
cryptoQuotes::ema(n = 7),
cryptoQuotes::sma(n = 14),
cryptoQuotes::wma(n = 21)
)
)
# script end;
Add Weighted Moving Average (WMA) to the chart
Description
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()
.
Usage
wma(
price = "close",
n = 10,
wts = 1:n,
...
)
Arguments
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. |
Value
A plotly::plot_ly()
-object
Author(s)
Serkan Korkmaz
See Also
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()
Examples
# script start;
cryptoQuotes::chart(
ticker = BTC,
main = kline(),
indicator = list(
cryptoQuotes::ema(n = 7),
cryptoQuotes::sma(n = 14),
cryptoQuotes::wma(n = 21)
)
)
# script end;
Read and Write xts
-objects
Description
The write_xts()
- and read_xts()
-functions are zoo::write.zoo()
- and zoo::read.zoo()
-wrapper functions.
Usage
# write XTS-object
write_xts(
x,
file,
...
)
# read XTS-object
read_xts(
file
)
Arguments
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 |
Details
When reading and writing <[xts]>-objects the attributes does not follow the object.
Author(s)
Serkan Korkmaz
See Also
Other utility:
calibrate_window()
,
remove_bound()
,
split_window()
Other utility:
calibrate_window()
,
remove_bound()
,
split_window()
Add Zero Lag Exponential Moving Average (ZLEMA) to the chart
Description
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()
.
Usage
zlema(
price = "close",
n = 10,
ratio = NULL,
...
)
Arguments
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. |
Value
A plotly::plot_ly()
-object
Author(s)
Serkan Korkmaz
See Also
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()
Examples
# script start;
cryptoQuotes::chart(
ticker = BTC,
main = kline(),
indicator = list(
cryptoQuotes::ema(n = 7),
cryptoQuotes::sma(n = 14),
cryptoQuotes::wma(n = 21)
)
)
# script end;