Socket
Socket
Sign inDemoInstall

alphavantage-ts

Package Overview
Dependencies
57
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.6 to 1.0.7

52

lib/stocks.ts
import Api from "./api";
export interface StockSeriesParameters {
outputsize?: string;
datatype?: string;
interval?: string;
}
export type OutputSize = "compact" | "full";
export type DataType = "json" | "csv";
export type TimeInterval = "1min" | "5min" | "15min" | "30min" | "60min";
class Stocks {

@@ -18,9 +18,30 @@ public api: Api;

symbol: string,
{ datatype = "json" }: { datatype: DataType }
) => {
return this.api.request(fn)({ symbol, datatype });
};
public dailySeries = (fn: string) => (
symbol: string,
{
outputsize = "compact",
datatype = "json"
}: { outputsize: OutputSize; datatype: DataType }
) => {
return this.api.request(fn)({
symbol,
outputsize,
datatype
});
};
public intraday = (
symbol: string,
{
outputsize = "compact",
datatype = "json",
interval = "1min"
}: StockSeriesParameters
}: { outputsize: OutputSize; datatype: DataType; interval: TimeInterval }
) => {
return this.api.request(fn)({
return this.api.request("TIME_SERIES_INTRADAY")({
symbol,

@@ -33,2 +54,10 @@ interval,

public daily = this.dailySeries("TIME_SERIES_DAILY");
public daily_adjusted = this.dailySeries("TIME_SERIES_DAILY_ADJUSTED");
public weekly = this.series("TIME_SERIES_WEEKLY");
public weekly_adjusted = this.series("TIME_SERIES_WEEKLY_ADJUSTED");
public monthly = this.series("TIME_SERIES_MONTHLY");
public monthly_adjusted = this.series("TIME_SERIES_MONTHLY_ADJUSTED");
public quote = this.series("GLOBAL_QUOTE");
public batch = (symbols: string | string[]) => {

@@ -43,13 +72,4 @@ return this.api.request("BATCH_STOCK_QUOTES")({

};
public intraday = this.series("TIME_SERIES_INTRADAY");
public daily = this.series("TIME_SERIES_DAILY");
public daily_adjusted = this.series("TIME_SERIES_DAILY_ADJUSTED");
public weekly = this.series("TIME_SERIES_WEEKLY");
public weekly_adjusted = this.series("TIME_SERIES_WEEKLY_ADJUSTED");
public monthly = this.series("TIME_SERIES_MONTHLY");
public monthly_adjusted = this.series("TIME_SERIES_MONTHLY_ADJUSTED");
public quote = this.series("GLOBAL_QUOTE");
}
export default Stocks;
import Api from "./api";
export interface TimeSeriesParameters {
symbol: string;
interval: string;
interval:
| "1min"
| "5min"
| "15min"
| "30min"
| "60min"
| "daily"
| "weekly"
| "monthly";
}
export interface MultiTimeSeriesParameters extends TimeSeriesParameters {
series_type: string;
series_type: "close" | "open" | "high" | "low";
}
export interface TimePeriodSeriesParameters extends MultiTimeSeriesParameters {
time_period: string;
time_period: number;
}

@@ -39,19 +46,19 @@

private timePeriodSeries = (fn: string) => ({
symbol,
interval,
time_period,
series_type
}: TimePeriodSeriesParameters) => {
private timePeriodSeries = (fn: string) => (
symbol: string,
{ interval, time_period, series_type }: TimePeriodSeriesParameters
) => {
return this.api.request(fn)({ symbol, interval, time_period, series_type });
};
private multiPeriodSeries = (fn: string) => ({
symbol,
interval,
series_type,
fastperiod,
slowperiod,
matype
}: MultiPeriodSeriesParameters) => {
private multiPeriodSeries = (fn: string) => (
symbol: string,
{
interval,
series_type,
fastperiod,
slowperiod,
matype
}: MultiPeriodSeriesParameters
) => {
return this.api.request(fn)({

@@ -67,13 +74,15 @@ symbol,

private multiPeriodAndMaSeries = (fn: string) => ({
symbol,
interval,
series_type,
fastperiod = 12,
slowperiod = 26,
signalperiod = 9,
fastmatype,
slowmatype,
signalmatype
}: MultiPeriodAndMaSeriesParameters) => {
private multiPeriodAndMaSeries = (fn: string) => (
symbol: string,
{
interval,
series_type,
fastperiod = 12,
slowperiod = 26,
signalperiod = 9,
fastmatype,
slowmatype,
signalmatype
}: MultiPeriodAndMaSeriesParameters
) => {
return this.api.request(fn)({

@@ -92,7 +101,6 @@ symbol,

private multiTimeSeriesParameters = (fn: string) => ({
symbol,
interval,
series_type
}: MultiTimeSeriesParameters) => {
private multiTimeSeriesParameters = (fn: string) => (
symbol: string,
{ interval, series_type }: MultiTimeSeriesParameters
) => {
return this.api.request(fn)({ symbol, interval, series_type });

@@ -108,9 +116,11 @@ };

public kama = this.timePeriodSeries("KAMA");
public mama = ({
symbol,
interval,
series_type,
fastlimit = 0.01,
slowlimit = 0.01
}: TimeSeriesParameters & any) =>
public mama = (
symbol: string,
{
interval,
series_type,
fastlimit = 0.01,
slowlimit = 0.01
}: TimeSeriesParameters & any
) =>
this.api.request("MAMA")({

@@ -126,11 +136,13 @@ symbol,

public macdext = this.multiPeriodAndMaSeries("MACDEXT");
public stoch = ({
symbol,
interval,
fastkperiod,
slowkperiod,
slowdperiod,
slowkmatype,
slowdmatype
}: TimeSeriesParameters & any) =>
public stoch = (
symbol: string,
{
interval,
fastkperiod,
slowkperiod,
slowdperiod,
slowkmatype,
slowdmatype
}: TimeSeriesParameters & any
) =>
this.api.request("STOCH")({

@@ -145,9 +157,11 @@ symbol,

});
public stochf = ({
symbol,
interval,
fastkperiod,
fastdperiod,
fastdmatype
}: TimeSeriesParameters & any) =>
public stochf = (
symbol: string,
{
interval,
fastkperiod,
fastdperiod,
fastdmatype
}: TimeSeriesParameters & any
) =>
this.api.request("STOCHF")({

@@ -161,11 +175,13 @@ symbol,

public rsi = this.timePeriodSeries("RSI");
public stochrsi = ({
symbol,
interval,
time_period,
series_type,
fastkperiod,
fastdperiod,
fastdmatype
}: TimeSeriesParameters & any) =>
public stochrsi = (
symbol: string,
{
interval,
time_period,
series_type,
fastkperiod,
fastdperiod,
fastdmatype
}: TimeSeriesParameters & any
) =>
this.api.request("STOCHRSI")({

@@ -195,9 +211,11 @@ symbol,

public trix = this.timePeriodSeries("TRIX");
public ultosc = ({
symbol,
interval,
timeperiod1,
timeperiod2,
timeperiod3
}: TimeSeriesParameters & any) =>
public ultosc = (
symbol: string,
{
interval,
timeperiod1,
timeperiod2,
timeperiod3
}: TimeSeriesParameters & any
) =>
this.api.request("ULTOSC")({

@@ -215,11 +233,13 @@ symbol,

public plus_dm = this.timePeriodSeries("PLUS_DM");
public bbands = ({
symbol,
interval,
time_period,
series_type,
nbdevup,
nbdevdn,
matype
}: TimeSeriesParameters & any) =>
public bbands = (
symbol: string,
{
interval,
time_period,
series_type,
nbdevup,
nbdevdn,
matype
}: TimeSeriesParameters & any
) =>
this.api.request("BBANDS")({

@@ -236,9 +256,6 @@ symbol,

public midprice = this.timePeriodSeries("MIDPRICE");
public sar = ({
symbol,
interval,
acceleration,
maximum
}: TimeSeriesParameters & any) =>
this.api.request("SAR")({ symbol, interval, acceleration, maximum });
public sar = (
symbol: string,
{ interval, acceleration, maximum }: TimeSeriesParameters & any
) => this.api.request("SAR")({ symbol, interval, acceleration, maximum });
public trange = this.timePeriodSeries("TRANGE");

@@ -248,9 +265,6 @@ public atr = this.timePeriodSeries("ATR");

public ad = this.timePeriodSeries("AD");
public adosc = ({
symbol,
interval,
fastperiod,
slowperiod
}: TimeSeriesParameters & any) =>
this.api.request("ADOSC")({ symbol, interval, fastperiod, slowperiod });
public adosc = (
symbol: string,
{ interval, fastperiod, slowperiod }: TimeSeriesParameters & any
) => this.api.request("ADOSC")({ symbol, interval, fastperiod, slowperiod });
public obv = this.timePeriodSeries("OBV");

@@ -257,0 +271,0 @@ public ht_trendline = this.multiTimeSeriesParameters("HT_TRENDLINE");

{
"name": "alphavantage-ts",
"version": "1.0.6",
"version": "1.0.7",
"description": "A simple interface to the Alpha Vantage API written in Typescript.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -108,11 +108,11 @@ # alphavantage-ts

```typescript
alpha.technicals.sma({ symbol, interval, time_period, series_type });
alpha.technicals.ema({ symbol, interval, time_period, series_type });
alpha.technicals.wma({ symbol, interval, time_period, series_type });
alpha.technicals.dema({ symbol, interval, time_period, series_type });
alpha.technicals.tema({ symbol, interval, time_period, series_type });
alpha.technicals.trima({ symbol, interval, time_period, series_type });
alpha.technicals.kama({ symbol, interval, time_period, series_type });
alpha.technicals.mama({ symbol, interval, series_type, fastlimit, slowlimit });
alpha.technicals.t3({ symbol, interval, time_period, series_type });
alpha.technicals.sma(symbol, { interval, time_period, series_type });
alpha.technicals.ema(symbol, { interval, time_period, series_type });
alpha.technicals.wma(symbol, { interval, time_period, series_type });
alpha.technicals.dema(symbol, { interval, time_period, series_type });
alpha.technicals.tema(symbol, { interval, time_period, series_type });
alpha.technicals.trima(symbol, { interval, time_period, series_type });
alpha.technicals.kama(symbol, { interval, time_period, series_type });
alpha.technicals.mama(symbol, { interval, series_type, fastlimit, slowlimit });
alpha.technicals.t3(symbol, { interval, time_period, series_type });
alpha.technicals.macd({

@@ -153,3 +153,3 @@ symbol,

});
alpha.technicals.rsi({ symbol, interval, time_period, series_type });
alpha.technicals.rsi(symbol, { interval, time_period, series_type });
alpha.technicals.stochrsi({

@@ -164,5 +164,5 @@ symbol,

});
alpha.technicals.willr({ symbol, interval, time_period });
alpha.technicals.adx({ symbol, interval, time_period });
alpha.technicals.adxr({ symbol, interval, time_period });
alpha.technicals.willr(symbol, { interval, time_period });
alpha.technicals.adx(symbol, { interval, time_period });
alpha.technicals.adxr(symbol, { interval, time_period });
alpha.technicals.apo({

@@ -184,12 +184,12 @@ symbol,

});
alpha.technicals.mom({ symbol, interval, time_period, series_type });
alpha.technicals.bop({ symbol, interval });
alpha.technicals.cci({ symbol, interval, time_period });
alpha.technicals.cmo({ symbol, interval, time_period, series_type });
alpha.technicals.roc({ symbol, interval, time_period, series_type });
alpha.technicals.rocr({ symbol, interval, time_period, series_type });
alpha.technicals.aroon({ symbol, interval, time_period });
alpha.technicals.aroonosc({ symbol, interval, time_period });
alpha.technicals.mfi({ symbol, interval, time_period });
alpha.technicals.trix({ symbol, interval, time_period, series_type });
alpha.technicals.mom(symbol, { interval, time_period, series_type });
alpha.technicals.bop(symbol, { interval });
alpha.technicals.cci(symbol, { interval, time_period });
alpha.technicals.cmo(symbol, { interval, time_period, series_type });
alpha.technicals.roc(symbol, { interval, time_period, series_type });
alpha.technicals.rocr(symbol, { interval, time_period, series_type });
alpha.technicals.aroon(symbol, { interval, time_period });
alpha.technicals.aroonosc(symbol, { interval, time_period });
alpha.technicals.mfi(symbol, { interval, time_period });
alpha.technicals.trix(symbol, { interval, time_period, series_type });
alpha.technicals.ultosc({

@@ -202,7 +202,7 @@ symbol,

});
alpha.technicals.dx({ symbol, interval, time_period });
alpha.technicals.minus_di({ symbol, interval, time_period });
alpha.technicals.plus_di({ symbol, interval, time_period });
alpha.technicals.minus_dm({ symbol, interval, time_period });
alpha.technicals.plus_dm({ symbol, interval, time_period });
alpha.technicals.dx(symbol, { interval, time_period });
alpha.technicals.minus_di(symbol, { interval, time_period });
alpha.technicals.plus_di(symbol, { interval, time_period });
alpha.technicals.minus_dm(symbol, { interval, time_period });
alpha.technicals.plus_dm(symbol, { interval, time_period });
alpha.technicals.bbands({

@@ -216,17 +216,17 @@ symbol,

});
alpha.technicals.midpoint({ symbol, interval, time_period, series_type });
alpha.technicals.midprice({ symbol, interval, time_period });
alpha.technicals.sar({ symbol, interval, acceleration, maximum });
alpha.technicals.trange({ symbol, interval });
alpha.technicals.atr({ symbol, interval, time_period });
alpha.technicals.natr({ symbol, interval, time_period });
alpha.technicals.ad({ symbol, interval });
alpha.technicals.adosc({ symbol, interval, fastperiod, slowperiod });
alpha.technicals.obv({ symbol, interval });
alpha.technicals.ht_trendline({ symbol, interval, series_type });
alpha.technicals.ht_sine({ symbol, interval, series_type });
alpha.technicals.ht_trendmode({ symbol, interval, series_type });
alpha.technicals.ht_dcperiod({ symbol, interval, series_type });
alpha.technicals.ht_dcphase({ symbol, interval, series_type });
alpha.technicals.ht_dcphasor({ symbol, interval, series_type });
alpha.technicals.midpoint(symbol, { interval, time_period, series_type });
alpha.technicals.midprice(symbol, { interval, time_period });
alpha.technicals.sar(symbol, { interval, acceleration, maximum });
alpha.technicals.trange(symbol, { interval });
alpha.technicals.atr(symbol, { interval, time_period });
alpha.technicals.natr(symbol, { interval, time_period });
alpha.technicals.ad(symbol, { interval });
alpha.technicals.adosc(symbol, { interval, fastperiod, slowperiod });
alpha.technicals.obv(symbol, { interval });
alpha.technicals.ht_trendline(symbol, { interval, series_type });
alpha.technicals.ht_sine(symbol, { interval, series_type });
alpha.technicals.ht_trendmode(symbol, { interval, series_type });
alpha.technicals.ht_dcperiod(symbol, { interval, series_type });
alpha.technicals.ht_dcphase(symbol, { interval, series_type });
alpha.technicals.ht_dcphasor(symbol, { interval, series_type });
```

@@ -233,0 +233,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc