INSTRUCTION stringlengths 1 46.3k | RESPONSE stringlengths 75 80.2k |
|---|---|
Aroon Down.
Formula:
AROONDWN = (((PERIOD) - (PERIODS SINCE PERIOD LOW)) / (PERIOD)) * 100 | def aroon_down(data, period):
"""
Aroon Down.
Formula:
AROONDWN = (((PERIOD) - (PERIODS SINCE PERIOD LOW)) / (PERIOD)) * 100
"""
catch_errors.check_for_period_error(data, period)
period = int(period)
a_down = [((period -
list(reversed(data[idx+1-period:idx+1])).index(np.min... |
Momentum.
Formula:
DATA[i] - DATA[i - period] | def momentum(data, period):
"""
Momentum.
Formula:
DATA[i] - DATA[i - period]
"""
catch_errors.check_for_period_error(data, period)
momentum = [data[idx] - data[idx+1-period] for idx in range(period-1, len(data))]
momentum = fill_for_noncomputable_vals(data, momentum)
return moment... |
Upper Price Channel.
Formula:
upc = EMA(t) * (1 + upper_percent / 100) | def upper_price_channel(data, period, upper_percent):
"""
Upper Price Channel.
Formula:
upc = EMA(t) * (1 + upper_percent / 100)
"""
catch_errors.check_for_period_error(data, period)
emas = ema(data, period)
upper_channel = [val * (1+float(upper_percent)/100) for val in emas]
retur... |
Lower Price Channel.
Formula:
lpc = EMA(t) * (1 - lower_percent / 100) | def lower_price_channel(data, period, lower_percent):
"""
Lower Price Channel.
Formula:
lpc = EMA(t) * (1 - lower_percent / 100)
"""
catch_errors.check_for_period_error(data, period)
emas = ema(data, period)
lower_channel = [val * (1-float(lower_percent)/100) for val in emas]
retur... |
Exponential Moving Average.
Formula:
p0 + (1 - w) * p1 + (1 - w)^2 * p2 + (1 + w)^3 * p3 +...
/ 1 + (1 - w) + (1 - w)^2 + (1 - w)^3 +...
where: w = 2 / (N + 1) | def exponential_moving_average(data, period):
"""
Exponential Moving Average.
Formula:
p0 + (1 - w) * p1 + (1 - w)^2 * p2 + (1 + w)^3 * p3 +...
/ 1 + (1 - w) + (1 - w)^2 + (1 - w)^3 +...
where: w = 2 / (N + 1)
"""
catch_errors.check_for_period_error(data, period)
emas... |
Commodity Channel Index.
Formula:
CCI = (TP - SMA(TP)) / (0.015 * Mean Deviation) | def commodity_channel_index(close_data, high_data, low_data, period):
"""
Commodity Channel Index.
Formula:
CCI = (TP - SMA(TP)) / (0.015 * Mean Deviation)
"""
catch_errors.check_for_input_len_diff(close_data, high_data, low_data)
catch_errors.check_for_period_error(close_data, period)
... |
Moving Average Convergence Divergence.
Formula:
EMA(DATA, P1) - EMA(DATA, P2) | def moving_average_convergence_divergence(data, short_period, long_period):
"""
Moving Average Convergence Divergence.
Formula:
EMA(DATA, P1) - EMA(DATA, P2)
"""
catch_errors.check_for_period_error(data, short_period)
catch_errors.check_for_period_error(data, long_period)
macd = ema(da... |
Williams %R.
Formula:
wr = (HighestHigh - close / HighestHigh - LowestLow) * -100 | def williams_percent_r(close_data):
"""
Williams %R.
Formula:
wr = (HighestHigh - close / HighestHigh - LowestLow) * -100
"""
highest_high = np.max(close_data)
lowest_low = np.min(close_data)
wr = [((highest_high - close) / (highest_high - lowest_low)) * -100 for close in close_data]
... |
Money Flow Index.
Formula:
MFI = 100 - (100 / (1 + PMF / NMF)) | def money_flow_index(close_data, high_data, low_data, volume, period):
"""
Money Flow Index.
Formula:
MFI = 100 - (100 / (1 + PMF / NMF))
"""
catch_errors.check_for_input_len_diff(
close_data, high_data, low_data, volume
)
catch_errors.check_for_period_error(close_data, peri... |
Typical Price.
Formula:
TPt = (HIGHt + LOWt + CLOSEt) / 3 | def typical_price(close_data, high_data, low_data):
"""
Typical Price.
Formula:
TPt = (HIGHt + LOWt + CLOSEt) / 3
"""
catch_errors.check_for_input_len_diff(close_data, high_data, low_data)
tp = [(high_data[idx] + low_data[idx] + close_data[idx]) / 3 for idx in range(0, len(close_data))]
... |
True Range.
Formula:
TRt = MAX(abs(Ht - Lt), abs(Ht - Ct-1), abs(Lt - Ct-1)) | def true_range(close_data, period):
"""
True Range.
Formula:
TRt = MAX(abs(Ht - Lt), abs(Ht - Ct-1), abs(Lt - Ct-1))
"""
catch_errors.check_for_period_error(close_data, period)
tr = [np.max([np.max(close_data[idx+1-period:idx+1]) -
np.min(close_data[idx+1-period:idx+1]),
... |
Double Smoothed Stochastic.
Formula:
dss = 100 * EMA(Close - Lowest Low) / EMA(Highest High - Lowest Low) | def double_smoothed_stochastic(data, period):
"""
Double Smoothed Stochastic.
Formula:
dss = 100 * EMA(Close - Lowest Low) / EMA(Highest High - Lowest Low)
"""
catch_errors.check_for_period_error(data, period)
lows = [data[idx] - np.min(data[idx+1-period:idx+1]) for idx in range(period-1, ... |
Volume Adjusted Moving Average.
Formula:
VAMA = SUM(CLOSE * VolumeRatio) / period | def volume_adjusted_moving_average(close_data, volume, period):
"""
Volume Adjusted Moving Average.
Formula:
VAMA = SUM(CLOSE * VolumeRatio) / period
"""
catch_errors.check_for_input_len_diff(close_data, volume)
catch_errors.check_for_period_error(close_data, period)
avg_vol = np.mean(... |
Triangular Moving Average.
Formula:
TMA = SMA(SMA()) | def triangular_moving_average(data, period):
"""
Triangular Moving Average.
Formula:
TMA = SMA(SMA())
"""
catch_errors.check_for_period_error(data, period)
tma = sma(sma(data, period), period)
return tma |
Weighted Moving Average.
Formula:
(P1 + 2 P2 + 3 P3 + ... + n Pn) / K
where K = (1+2+...+n) = n(n+1)/2 and Pn is the most recent price | def weighted_moving_average(data, period):
"""
Weighted Moving Average.
Formula:
(P1 + 2 P2 + 3 P3 + ... + n Pn) / K
where K = (1+2+...+n) = n(n+1)/2 and Pn is the most recent price
"""
catch_errors.check_for_period_error(data, period)
k = (period * (period + 1)) / 2.0
wmas = []
... |
The only real difference between TenkanSen and KijunSen is the period value | def conversion_base_line_helper(data, period):
"""
The only real difference between TenkanSen and KijunSen is the period value
"""
catch_errors.check_for_period_error(data, period)
cblh = [(np.max(data[idx+1-period:idx+1]) +
np.min(data[idx+1-period:idx+1])) / 2 for idx in range(period-1... |
Senkou A (Leading Span A)
Formula:
(TenkanSen + KijunSen) / 2 :: Shift Forward 26 bars | def senkou_a(data):
"""
Senkou A (Leading Span A)
Formula:
(TenkanSen + KijunSen) / 2 :: Shift Forward 26 bars
"""
sa = (tenkansen(data) + kijunsen(data)) / 2
# shift forward
shift_by = np.repeat(np.nan, 26)
sa = np.append(shift_by, sa)
return sa |
Senkou B (Leading Span B)
Formula:
(H + L) / 2 :: default period=52 :: shifted forward 26 bars | def senkou_b(data, period=52):
"""
Senkou B (Leading Span B)
Formula:
(H + L) / 2 :: default period=52 :: shifted forward 26 bars
"""
sb = conversion_base_line_helper(data, period)
shift_by = np.repeat(np.nan, 26)
sb = np.append(shift_by, sb)
return sb |
Volatility.
Formula:
SDt / SVt | def volatility(data, period):
"""
Volatility.
Formula:
SDt / SVt
"""
volatility = sd(data, period) / sv(data, period)
return volatility |
Chande Momentum Oscillator.
Formula:
cmo = 100 * ((sum_up - sum_down) / (sum_up + sum_down)) | def chande_momentum_oscillator(close_data, period):
"""
Chande Momentum Oscillator.
Formula:
cmo = 100 * ((sum_up - sum_down) / (sum_up + sum_down))
"""
catch_errors.check_for_period_error(close_data, period)
close_data = np.array(close_data)
moving_period_diffs = [[(close_data[idx+1-... |
Price Oscillator.
Formula:
(short EMA - long EMA / long EMA) * 100 | def price_oscillator(data, short_period, long_period):
"""
Price Oscillator.
Formula:
(short EMA - long EMA / long EMA) * 100
"""
catch_errors.check_for_period_error(data, short_period)
catch_errors.check_for_period_error(data, long_period)
ema_short = ema(data, short_period)
ema_l... |
Check for Period Error.
This method checks if the developer is trying to enter a period that is
larger than the data set being entered. If that is the case an exception is
raised with a custom message that informs the developer that their period
is greater than the data set. | def check_for_period_error(data, period):
"""
Check for Period Error.
This method checks if the developer is trying to enter a period that is
larger than the data set being entered. If that is the case an exception is
raised with a custom message that informs the developer that their period
is ... |
Check for Input Length Difference.
This method checks if multiple data sets that are inputted are all the same
size. If they are not the same length an error is raised with a custom
message that informs the developer that the data set's lengths are not the
same. | def check_for_input_len_diff(*args):
"""
Check for Input Length Difference.
This method checks if multiple data sets that are inputted are all the same
size. If they are not the same length an error is raised with a custom
message that informs the developer that the data set's lengths are not the
... |
StochRSI.
Formula:
SRSI = ((RSIt - RSI LOW) / (RSI HIGH - LOW RSI)) * 100 | def stochrsi(data, period):
"""
StochRSI.
Formula:
SRSI = ((RSIt - RSI LOW) / (RSI HIGH - LOW RSI)) * 100
"""
rsi = relative_strength_index(data, period)[period:]
stochrsi = [100 * ((rsi[idx] - np.min(rsi[idx+1-period:idx+1])) / (np.max(rsi[idx+1-period:idx+1]) - np.min(rsi[idx+1-period:idx... |
Upper Bollinger Band.
Formula:
u_bb = SMA(t) + STD(SMA(t-n:t)) * std_mult | def upper_bollinger_band(data, period, std_mult=2.0):
"""
Upper Bollinger Band.
Formula:
u_bb = SMA(t) + STD(SMA(t-n:t)) * std_mult
"""
catch_errors.check_for_period_error(data, period)
period = int(period)
simple_ma = sma(data, period)[period-1:]
upper_bb = []
for idx in rang... |
Middle Bollinger Band.
Formula:
m_bb = sma() | def middle_bollinger_band(data, period, std=2.0):
"""
Middle Bollinger Band.
Formula:
m_bb = sma()
"""
catch_errors.check_for_period_error(data, period)
period = int(period)
mid_bb = sma(data, period)
return mid_bb |
Lower Bollinger Band.
Formula:
u_bb = SMA(t) - STD(SMA(t-n:t)) * std_mult | def lower_bollinger_band(data, period, std=2.0):
"""
Lower Bollinger Band.
Formula:
u_bb = SMA(t) - STD(SMA(t-n:t)) * std_mult
"""
catch_errors.check_for_period_error(data, period)
period = int(period)
simple_ma = sma(data, period)[period-1:]
lower_bb = []
for idx in range(len... |
Bandwidth.
Formula:
bw = u_bb - l_bb / m_bb | def bandwidth(data, period, std=2.0):
"""
Bandwidth.
Formula:
bw = u_bb - l_bb / m_bb
"""
catch_errors.check_for_period_error(data, period)
period = int(period)
bandwidth = ((upper_bollinger_band(data, period, std) -
lower_bollinger_band(data, period, std)) /
... |
Range.
Formula:
bb_range = u_bb - l_bb | def bb_range(data, period, std=2.0):
"""
Range.
Formula:
bb_range = u_bb - l_bb
"""
catch_errors.check_for_period_error(data, period)
period = int(period)
bb_range = (upper_bollinger_band(data, period, std) -
lower_bollinger_band(data, period, std)
)
... |
Percent Bandwidth.
Formula:
%_bw = data() - l_bb() / bb_range() | def percent_bandwidth(data, period, std=2.0):
"""
Percent Bandwidth.
Formula:
%_bw = data() - l_bb() / bb_range()
"""
catch_errors.check_for_period_error(data, period)
period = int(period)
percent_bandwidth = ((np.array(data) -
lower_bollinger_band(data, period... |
%B.
Formula:
%B = ((data - lb) / (ub - lb)) * 100 | def percent_b(data, period, upper_bb_std=2.0, lower_bb_std=2.0):
"""
%B.
Formula:
%B = ((data - lb) / (ub - lb)) * 100
"""
lb = lower_bollinger_band(data, period, lower_bb_std)
ub = upper_bollinger_band(data, period, upper_bb_std)
percent_b = ((np.array(data) - lb) / (ub - lb)) * 100
... |
Standard Deviation.
Formula:
std = sqrt(avg(abs(x - avg(x))^2)) | def standard_deviation(data, period):
"""
Standard Deviation.
Formula:
std = sqrt(avg(abs(x - avg(x))^2))
"""
catch_errors.check_for_period_error(data, period)
stds = [np.std(data[idx+1-period:idx+1], ddof=1) for idx in range(period-1, len(data))]
stds = fill_for_noncomputable_vals(da... |
Detrended Price Oscillator.
Formula:
DPO = DATA[i] - Avg(DATA[period/2 + 1]) | def detrended_price_oscillator(data, period):
"""
Detrended Price Oscillator.
Formula:
DPO = DATA[i] - Avg(DATA[period/2 + 1])
"""
catch_errors.check_for_period_error(data, period)
period = int(period)
dop = [data[idx] - np.mean(data[idx+1-(int(period/2)+1):idx+1]) for idx in range(peri... |
Upper Band.
Formula:
ub = cb(t) * (1 + env_percentage) | def upper_band(data, period, env_percentage):
"""
Upper Band.
Formula:
ub = cb(t) * (1 + env_percentage)
"""
cb = center_band(data, period)
ub = [val * (1 + float(env_percentage)) for val in cb]
return ub |
Lower Band.
Formula:
lb = cb * (1 - env_percentage) | def lower_band(data, period, env_percentage):
"""
Lower Band.
Formula:
lb = cb * (1 - env_percentage)
"""
cb = center_band(data, period)
lb = [val * (1 - float(env_percentage)) for val in cb]
return lb |
Smoothed Moving Average.
Formula:
smma = avg(data(n)) - avg(data(n)/n) + data(t)/n | def smoothed_moving_average(data, period):
"""
Smoothed Moving Average.
Formula:
smma = avg(data(n)) - avg(data(n)/n) + data(t)/n
"""
catch_errors.check_for_period_error(data, period)
series = pd.Series(data)
return series.ewm(alpha = 1.0/period).mean().values.flatten() |
Chaikin Money Flow.
Formula:
CMF = SUM[(((Cn - Ln) - (Hn - Cn)) / (Hn - Ln)) * V] / SUM(Vn) | def chaikin_money_flow(close_data, high_data, low_data, volume, period):
"""
Chaikin Money Flow.
Formula:
CMF = SUM[(((Cn - Ln) - (Hn - Cn)) / (Hn - Ln)) * V] / SUM(Vn)
"""
catch_errors.check_for_input_len_diff(
close_data, high_data, low_data, volume)
catch_errors.check_for_period_... |
%D.
Formula:
%D = SMA(%K, 3) | def percent_d(data, period):
"""
%D.
Formula:
%D = SMA(%K, 3)
"""
p_k = percent_k(data, period)
percent_d = sma(p_k, 3)
return percent_d |
Hull Moving Average.
Formula:
HMA = WMA(2*WMA(n/2) - WMA(n)), sqrt(n) | def hull_moving_average(data, period):
"""
Hull Moving Average.
Formula:
HMA = WMA(2*WMA(n/2) - WMA(n)), sqrt(n)
"""
catch_errors.check_for_period_error(data, period)
hma = wma(
2 * wma(data, int(period/2)) - wma(data, period), int(np.sqrt(period))
)
return hma |
Standard Variance.
Formula:
(Ct - AVGt)^2 / N | def standard_variance(data, period):
"""
Standard Variance.
Formula:
(Ct - AVGt)^2 / N
"""
catch_errors.check_for_period_error(data, period)
sv = [np.var(data[idx+1-period:idx+1], ddof=1) for idx in range(period-1, len(data))]
sv = fill_for_noncomputable_vals(data, sv)
return sv |
Up Move.
Formula:
UPMOVE = Ht - Ht-1 | def calculate_up_moves(high_data):
"""
Up Move.
Formula:
UPMOVE = Ht - Ht-1
"""
up_moves = [high_data[idx] - high_data[idx-1] for idx in range(1, len(high_data))]
return [np.nan] + up_moves |
Down Move.
Formula:
DWNMOVE = Lt-1 - Lt | def calculate_down_moves(low_data):
"""
Down Move.
Formula:
DWNMOVE = Lt-1 - Lt
"""
down_moves = [low_data[idx-1] - low_data[idx] for idx in range(1, len(low_data))]
return [np.nan] + down_moves |
Positive Directional Movement (+DM).
Formula:
+DM: if UPMOVE > DWNMOVE and UPMOVE > 0 then +DM = UPMOVE else +DM = 0 | def positive_directional_movement(high_data, low_data):
"""
Positive Directional Movement (+DM).
Formula:
+DM: if UPMOVE > DWNMOVE and UPMOVE > 0 then +DM = UPMOVE else +DM = 0
"""
catch_errors.check_for_input_len_diff(high_data, low_data)
up_moves = calculate_up_moves(high_data)
down_m... |
Negative Directional Movement (-DM).
-DM: if DWNMOVE > UPMOVE and DWNMOVE > 0 then -DM = DWNMOVE else -Dm = 0 | def negative_directional_movement(high_data, low_data):
"""
Negative Directional Movement (-DM).
-DM: if DWNMOVE > UPMOVE and DWNMOVE > 0 then -DM = DWNMOVE else -Dm = 0
"""
catch_errors.check_for_input_len_diff(high_data, low_data)
up_moves = calculate_up_moves(high_data)
down_moves = cal... |
Positive Directional Index (+DI).
Formula:
+DI = 100 * SMMA(+DM) / ATR | def positive_directional_index(close_data, high_data, low_data, period):
"""
Positive Directional Index (+DI).
Formula:
+DI = 100 * SMMA(+DM) / ATR
"""
catch_errors.check_for_input_len_diff(close_data, high_data, low_data)
pdi = (100 *
smma(positive_directional_movement(high_data... |
Negative Directional Index (-DI).
Formula:
-DI = 100 * SMMA(-DM) / ATR | def negative_directional_index(close_data, high_data, low_data, period):
"""
Negative Directional Index (-DI).
Formula:
-DI = 100 * SMMA(-DM) / ATR
"""
catch_errors.check_for_input_len_diff(close_data, high_data, low_data)
ndi = (100 *
smma(negative_directional_movement(high_data... |
Average Directional Index.
Formula:
ADX = 100 * SMMA(abs((+DI - -DI) / (+DI + -DI))) | def average_directional_index(close_data, high_data, low_data, period):
"""
Average Directional Index.
Formula:
ADX = 100 * SMMA(abs((+DI - -DI) / (+DI + -DI)))
"""
avg_di = (abs(
(positive_directional_index(
close_data, high_data, low_data, period) -
... |
Linear Weighted Moving Average.
Formula:
LWMA = SUM(DATA[i]) * i / SUM(i) | def linear_weighted_moving_average(data, period):
"""
Linear Weighted Moving Average.
Formula:
LWMA = SUM(DATA[i]) * i / SUM(i)
"""
catch_errors.check_for_period_error(data, period)
idx_period = list(range(1, period+1))
lwma = [(sum([i * idx_period[data[idx-(period-1):idx+1].index(i)]
... |
Volume Oscillator.
Formula:
vo = 100 * (SMA(vol, short) - SMA(vol, long) / SMA(vol, long)) | def volume_oscillator(volume, short_period, long_period):
"""
Volume Oscillator.
Formula:
vo = 100 * (SMA(vol, short) - SMA(vol, long) / SMA(vol, long))
"""
catch_errors.check_for_period_error(volume, short_period)
catch_errors.check_for_period_error(volume, long_period)
vo = (100 * ((... |
Triple Exponential Moving Average.
Formula:
TEMA = (3*EMA - 3*EMA(EMA)) + EMA(EMA(EMA)) | def triple_exponential_moving_average(data, period):
"""
Triple Exponential Moving Average.
Formula:
TEMA = (3*EMA - 3*EMA(EMA)) + EMA(EMA(EMA))
"""
catch_errors.check_for_period_error(data, period)
tema = ((3 * ema(data, period) - (3 * ema(ema(data, period), period))) +
ema(em... |
Money Flow.
Formula:
MF = VOLUME * TYPICAL PRICE | def money_flow(close_data, high_data, low_data, volume):
"""
Money Flow.
Formula:
MF = VOLUME * TYPICAL PRICE
"""
catch_errors.check_for_input_len_diff(
close_data, high_data, low_data, volume
)
mf = volume * tp(close_data, high_data, low_data)
return mf |
Positive Volume Index (PVI).
Formula:
PVI0 = 1
IF Vt > Vt-1
PVIt = PVIt-1 + (CLOSEt - CLOSEt-1 / CLOSEt-1 * PVIt-1)
ELSE:
PVIt = PVIt-1 | def positive_volume_index(close_data, volume):
"""
Positive Volume Index (PVI).
Formula:
PVI0 = 1
IF Vt > Vt-1
PVIt = PVIt-1 + (CLOSEt - CLOSEt-1 / CLOSEt-1 * PVIt-1)
ELSE:
PVIt = PVIt-1
"""
catch_errors.check_for_input_len_diff(close_data, volume)
pvi = np.zeros(len... |
Negative Volume Index (NVI).
Formula:
NVI0 = 1
IF Vt < Vt-1
NVIt = NVIt-1 + (CLOSEt - CLOSEt-1 / CLOSEt-1 * NVIt-1)
ELSE:
NVIt = NVIt-1 | def negative_volume_index(close_data, volume):
"""
Negative Volume Index (NVI).
Formula:
NVI0 = 1
IF Vt < Vt-1
NVIt = NVIt-1 + (CLOSEt - CLOSEt-1 / CLOSEt-1 * NVIt-1)
ELSE:
NVIt = NVIt-1
"""
catch_errors.check_for_input_len_diff(close_data, volume)
nvi = np.zeros(len... |
Logs out and quits the current web driver/selenium session. | def close(self):
"""Logs out and quits the current web driver/selenium session."""
if not self.driver:
return
try:
self.driver.implicitly_wait(1)
self.driver.find_element_by_id('link-logout').click()
except NoSuchElementException:
pass
... |
Performs a request, and checks that the status is OK, and that the
content-type matches expectations.
Args:
url: URL to request
method: either 'get' or 'post'
expected_content_type: prefix to match response content-type against
**kwargs: passed to the request met... | def request_and_check(self, url, method='get',
expected_content_type=None, **kwargs):
"""Performs a request, and checks that the status is OK, and that the
content-type matches expectations.
Args:
url: URL to request
method: either 'get' or 'post'
... |
Returns the raw JSON transaction data as downloaded from Mint. The JSON
transaction data includes some additional information missing from the
CSV data, such as whether the transaction is pending or completed, but
leaves off the year for current year transactions.
Warning: In order to ... | def get_transactions_json(self, include_investment=False,
skip_duplicates=False, start_date=None, id=0):
"""Returns the raw JSON transaction data as downloaded from Mint. The JSON
transaction data includes some additional information missing from the
CSV data, such... |
Returns the raw CSV transaction data as downloaded from Mint.
If include_investment == True, also includes transactions that Mint
classifies as investment-related. You may find that the investment
transaction data is not sufficiently detailed to actually be useful,
however. | def get_transactions_csv(self, include_investment=False, acct=0):
"""Returns the raw CSV transaction data as downloaded from Mint.
If include_investment == True, also includes transactions that Mint
classifies as investment-related. You may find that the investment
transaction data is ... |
Returns the transaction data as a Pandas DataFrame. | def get_transactions(self, include_investment=False):
"""Returns the transaction data as a Pandas DataFrame."""
assert_pd()
s = StringIO(self.get_transactions_csv(
include_investment=include_investment))
s.seek(0)
df = pd.read_csv(s, parse_dates=['Date'])
df.c... |
Retrieve the payments JSON from this instance's Horizon server.
Retrieve the payments JSON response for the account associated with
this :class:`Address`.
:param cursor: A paging token, specifying where to start returning records from.
When streaming this can be set to "now" to str... | def payments(self, cursor=None, order='asc', limit=10, sse=False):
"""Retrieve the payments JSON from this instance's Horizon server.
Retrieve the payments JSON response for the account associated with
this :class:`Address`.
:param cursor: A paging token, specifying where to start retu... |
Retrieve the offers JSON from this instance's Horizon server.
Retrieve the offers JSON response for the account associated with
this :class:`Address`.
:param cursor: A paging token, specifying where to start returning records from.
When streaming this can be set to "now" to stream ... | def offers(self, cursor=None, order='asc', limit=10, sse=False):
"""Retrieve the offers JSON from this instance's Horizon server.
Retrieve the offers JSON response for the account associated with
this :class:`Address`.
:param cursor: A paging token, specifying where to start returning ... |
Retrieve the transactions JSON from this instance's Horizon server.
Retrieve the transactions JSON response for the account associated with
this :class:`Address`.
:param cursor: A paging token, specifying where to start returning records from.
When streaming this can be set to "now... | def transactions(self, cursor=None, order='asc', limit=10, sse=False):
"""Retrieve the transactions JSON from this instance's Horizon server.
Retrieve the transactions JSON response for the account associated with
this :class:`Address`.
:param cursor: A paging token, specifying where t... |
Retrieve the operations JSON from this instance's Horizon server.
Retrieve the operations JSON response for the account associated with
this :class:`Address`.
:param cursor: A paging token, specifying where to start returning records from.
When streaming this can be set to "now" to... | def operations(self, cursor=None, order='asc', limit=10, sse=False):
"""Retrieve the operations JSON from this instance's Horizon server.
Retrieve the operations JSON response for the account associated with
this :class:`Address`.
:param cursor: A paging token, specifying where to star... |
Retrieve the trades JSON from this instance's Horizon server.
Retrieve the trades JSON response for the account associated with
this :class:`Address`.
:param cursor: A paging token, specifying where to start returning records from.
When streaming this can be set to "now" to stream ... | def trades(self, cursor=None, order='asc', limit=10, sse=False):
"""Retrieve the trades JSON from this instance's Horizon server.
Retrieve the trades JSON response for the account associated with
this :class:`Address`.
:param cursor: A paging token, specifying where to start returning ... |
Retrieve the effects JSON from this instance's Horizon server.
Retrieve the effects JSON response for the account associated with
this :class:`Address`.
:param cursor: A paging token, specifying where to start returning records from.
When streaming this can be set to "now" to strea... | def effects(self, cursor=None, order='asc', limit=10, sse=False):
"""Retrieve the effects JSON from this instance's Horizon server.
Retrieve the effects JSON response for the account associated with
this :class:`Address`.
:param cursor: A paging token, specifying where to start returni... |
Submit the transaction using a pooled connection, and retry on failure.
`POST /transactions
<https://www.stellar.org/developers/horizon/reference/endpoints/transactions-create.html>`_
Uses form-encoded data to send over to Horizon.
:return: The JSON response indicating the success/fai... | def submit(self, te):
"""Submit the transaction using a pooled connection, and retry on failure.
`POST /transactions
<https://www.stellar.org/developers/horizon/reference/endpoints/transactions-create.html>`_
Uses form-encoded data to send over to Horizon.
:return: The JSON re... |
Returns information and links relating to a single account.
`GET /accounts/{account}
<https://www.stellar.org/developers/horizon/reference/endpoints/accounts-single.html>`_
:param str address: The account ID to retrieve details about.
:return: The account details in a JSON response.
... | def account(self, address):
"""Returns information and links relating to a single account.
`GET /accounts/{account}
<https://www.stellar.org/developers/horizon/reference/endpoints/accounts-single.html>`_
:param str address: The account ID to retrieve details about.
:return: The... |
This endpoint represents a single data associated with a given
account.
`GET /accounts/{account}/data/{key}
<https://www.stellar.org/developers/horizon/reference/endpoints/data-for-account.html>`_
:param str address: The account ID to look up a data item from.
:param str key: T... | def account_data(self, address, key):
"""This endpoint represents a single data associated with a given
account.
`GET /accounts/{account}/data/{key}
<https://www.stellar.org/developers/horizon/reference/endpoints/data-for-account.html>`_
:param str address: The account ID to lo... |
This endpoint represents all effects that changed a given account.
`GET /accounts/{account}/effects{?cursor,limit,order}
<https://www.stellar.org/developers/horizon/reference/endpoints/effects-for-account.html>`_
:param str address: The account ID to look up effects for.
:param cursor:... | def account_effects(self, address, cursor=None, order='asc', limit=10, sse=False):
"""This endpoint represents all effects that changed a given account.
`GET /accounts/{account}/effects{?cursor,limit,order}
<https://www.stellar.org/developers/horizon/reference/endpoints/effects-for-account.html... |
This endpoint represents all assets. It will give you all the assets
in the system along with various statistics about each.
See the documentation below for details on query parameters that are
available.
`GET /assets{?asset_code,asset_issuer,cursor,limit,order}
<https://www.st... | def assets(self, asset_code=None, asset_issuer=None, cursor=None, order='asc', limit=10):
"""This endpoint represents all assets. It will give you all the assets
in the system along with various statistics about each.
See the documentation below for details on query parameters that are
... |
The transaction details endpoint provides information on a single
transaction.
`GET /transactions/{hash}
<https://www.stellar.org/developers/horizon/reference/endpoints/transactions-single.html>`_
:param str tx_hash: The hex-encoded transaction hash.
:return: A single transacti... | def transaction(self, tx_hash):
"""The transaction details endpoint provides information on a single
transaction.
`GET /transactions/{hash}
<https://www.stellar.org/developers/horizon/reference/endpoints/transactions-single.html>`_
:param str tx_hash: The hex-encoded transactio... |
This endpoint represents all operations that are part of a given
transaction.
`GET /transactions/{hash}/operations{?cursor,limit,order}
<https://www.stellar.org/developers/horizon/reference/endpoints/operations-for-transaction.html>`_
:param str tx_hash: The hex-encoded transaction has... | def transaction_operations(self, tx_hash, cursor=None, order='asc', include_failed=False, limit=10):
"""This endpoint represents all operations that are part of a given
transaction.
`GET /transactions/{hash}/operations{?cursor,limit,order}
<https://www.stellar.org/developers/horizon/ref... |
This endpoint represents all effects that occurred as a result of a
given transaction.
`GET /transactions/{hash}/effects{?cursor,limit,order}
<https://www.stellar.org/developers/horizon/reference/endpoints/effects-for-transaction.html>`_
:param str tx_hash: The hex-encoded transaction ... | def transaction_effects(self, tx_hash, cursor=None, order='asc', limit=10):
"""This endpoint represents all effects that occurred as a result of a
given transaction.
`GET /transactions/{hash}/effects{?cursor,limit,order}
<https://www.stellar.org/developers/horizon/reference/endpoints/ef... |
Return, for each orderbook, a summary of the orderbook and the bids
and asks associated with that orderbook.
See the external docs below for information on the arguments required.
`GET /order_book
<https://www.stellar.org/developers/horizon/reference/endpoints/orderbook-details.html>`_... | def order_book(self, selling_asset_code, buying_asset_code, selling_asset_issuer=None, buying_asset_issuer=None,
limit=10):
"""Return, for each orderbook, a summary of the orderbook and the bids
and asks associated with that orderbook.
See the external docs below for informat... |
The ledger details endpoint provides information on a single ledger.
`GET /ledgers/{sequence}
<https://www.stellar.org/developers/horizon/reference/endpoints/ledgers-single.html>`_
:param int ledger_id: The id of the ledger to look up.
:return: The details of a single ledger.
:... | def ledger(self, ledger_id):
"""The ledger details endpoint provides information on a single ledger.
`GET /ledgers/{sequence}
<https://www.stellar.org/developers/horizon/reference/endpoints/ledgers-single.html>`_
:param int ledger_id: The id of the ledger to look up.
:return: T... |
This endpoint represents all effects that occurred in the given
ledger.
`GET /ledgers/{id}/effects{?cursor,limit,order}
<https://www.stellar.org/developers/horizon/reference/endpoints/effects-for-ledger.html>`_
:param int ledger_id: The id of the ledger to look up.
:param int c... | def ledger_effects(self, ledger_id, cursor=None, order='asc', limit=10):
"""This endpoint represents all effects that occurred in the given
ledger.
`GET /ledgers/{id}/effects{?cursor,limit,order}
<https://www.stellar.org/developers/horizon/reference/endpoints/effects-for-ledger.html>`_
... |
This endpoint represents all transactions in a given ledger.
`GET /ledgers/{id}/transactions{?cursor,limit,order}
<https://www.stellar.org/developers/horizon/reference/endpoints/transactions-for-ledger.html>`_
:param int ledger_id: The id of the ledger to look up.
:param int cursor: A ... | def ledger_transactions(self, ledger_id, cursor=None, order='asc', include_failed=False, limit=10):
"""This endpoint represents all transactions in a given ledger.
`GET /ledgers/{id}/transactions{?cursor,limit,order}
<https://www.stellar.org/developers/horizon/reference/endpoints/transactions-f... |
This endpoint represents all effects.
`GET /effects{?cursor,limit,order}
<https://www.stellar.org/developers/horizon/reference/endpoints/effects-all.html>`_
:param cursor: A paging token, specifying where to start returning records from.
When streaming this can be set to "now" to s... | def effects(self, cursor=None, order='asc', limit=10, sse=False):
"""This endpoint represents all effects.
`GET /effects{?cursor,limit,order}
<https://www.stellar.org/developers/horizon/reference/endpoints/effects-all.html>`_
:param cursor: A paging token, specifying where to start ret... |
This endpoint represents all operations that are part of validated
transactions.
`GET /operations{?cursor,limit,order}
<https://www.stellar.org/developers/horizon/reference/endpoints/operations-all.html>`_
:param cursor: A paging token, specifying where to start returning records from.... | def operations(self, cursor=None, order='asc', limit=10, include_failed=False, sse=False):
"""This endpoint represents all operations that are part of validated
transactions.
`GET /operations{?cursor,limit,order}
<https://www.stellar.org/developers/horizon/reference/endpoints/operations... |
The operation details endpoint provides information on a single
operation.
`GET /operations/{id}
<https://www.stellar.org/developers/horizon/reference/endpoints/operations-single.html>`_
:param id op_id: The operation ID to get details on.
:return: Details on a single operation... | def operation(self, op_id):
"""The operation details endpoint provides information on a single
operation.
`GET /operations/{id}
<https://www.stellar.org/developers/horizon/reference/endpoints/operations-single.html>`_
:param id op_id: The operation ID to get details on.
... |
This endpoint represents all effects that occurred as a result of a
given operation.
`GET /operations/{id}/effects{?cursor,limit,order}
<https://www.stellar.org/developers/horizon/reference/endpoints/effects-for-operation.html>`_
:param int op_id: The operation ID to get effects on.
... | def operation_effects(self, op_id, cursor=None, order='asc', limit=10):
"""This endpoint represents all effects that occurred as a result of a
given operation.
`GET /operations/{id}/effects{?cursor,limit,order}
<https://www.stellar.org/developers/horizon/reference/endpoints/effects-for-... |
Load a list of assets available to the source account id and find
any payment paths from those source assets to the desired
destination asset.
See the below docs for more information on required and optional
parameters for further specifying your search.
`GET /paths
<ht... | def paths(self, destination_account, destination_amount, source_account, destination_asset_code,
destination_asset_issuer=None):
"""Load a list of assets available to the source account id and find
any payment paths from those source assets to the desired
destination asset.
... |
Load a list of trades, optionally filtered by an orderbook.
See the below docs for more information on required and optional
parameters for further specifying your search.
`GET /trades
<https://www.stellar.org/developers/horizon/reference/endpoints/trades.html>`_
:param str ba... | def trades(self, base_asset_code=None, counter_asset_code=None, base_asset_issuer=None, counter_asset_issuer=None,
offer_id=None, cursor=None, order='asc', limit=10):
"""Load a list of trades, optionally filtered by an orderbook.
See the below docs for more information on required and op... |
Load a list of aggregated historical trade data, optionally filtered
by an orderbook.
`GET /trade_aggregations
<https://www.stellar.org/developers/horizon/reference/endpoints/trade_aggregations.html>`_
:param int start_time: Lower time boundary represented as millis since epoch.
... | def trade_aggregations(self, resolution, base_asset_code, counter_asset_code,
base_asset_issuer=None, counter_asset_issuer=None, start_time=None,
end_time=None, order='asc', limit=10, offset=0):
"""Load a list of aggregated historical trade data, optionally ... |
This endpoint represents all trades for a given offer.
`GET /offers/{offer_id}/trades{?cursor,limit,order}
<https://www.stellar.org/developers/horizon/reference/endpoints/trades-for-offer.html>`_
:param int offer_id: The offer ID to get trades on.
:param int cursor: A paging token, spe... | def offer_trades(self, offer_id, cursor=None, order='asc', limit=10):
"""This endpoint represents all trades for a given offer.
`GET /offers/{offer_id}/trades{?cursor,limit,order}
<https://www.stellar.org/developers/horizon/reference/endpoints/trades-for-offer.html>`_
:param int offer_... |
Fetch the base fee from the latest ledger.
In the future, we'll fetch the base fee from `/fee_stats`
:return: base free
:rtype: int | def base_fee(self):
"""Fetch the base fee from the latest ledger.
In the future, we'll fetch the base fee from `/fee_stats`
:return: base free
:rtype: int
"""
latest_ledger = self.ledgers(order='desc', limit=1)
try:
base_fee = latest_ledger['_embedded'... |
Sign this transaction envelope with a given keypair.
Note that the signature must not already be in this instance's list of
signatures.
:param keypair: The keypair to use for signing this transaction
envelope.
:type keypair: :class:`Keypair <stellar_base.keypair.Keypair>`
... | def sign(self, keypair):
"""Sign this transaction envelope with a given keypair.
Note that the signature must not already be in this instance's list of
signatures.
:param keypair: The keypair to use for signing this transaction
envelope.
:type keypair: :class:`Keypa... |
Sign this transaction envelope with a Hash(X) signature.
See Stellar's documentation on `Multi-Sig
<https://www.stellar.org/developers/guides/concepts/multi-sig.html>`_
for more details on Hash(x) signatures.
:param preimage: 32 byte hash or hex encoded string, the "x" value to be hash... | def sign_hashX(self, preimage):
"""Sign this transaction envelope with a Hash(X) signature.
See Stellar's documentation on `Multi-Sig
<https://www.stellar.org/developers/guides/concepts/multi-sig.html>`_
for more details on Hash(x) signatures.
:param preimage: 32 byte hash or h... |
Get the signature base of this transaction envelope.
Return the "signature base" of this transaction, which is the value
that, when hashed, should be signed to create a signature that
validators on the Stellar Network will accept.
It is composed of a 4 prefix bytes followed by the xdr-... | def signature_base(self):
"""Get the signature base of this transaction envelope.
Return the "signature base" of this transaction, which is the value
that, when hashed, should be signed to create a signature that
validators on the Stellar Network will accept.
It is composed of ... |
Get an XDR object representation of this
:class:`TransactionEnvelope`. | def to_xdr_object(self):
"""Get an XDR object representation of this
:class:`TransactionEnvelope`.
"""
tx = self.tx.to_xdr_object()
return Xdr.types.TransactionEnvelope(tx, self.signatures) |
Get the base64 encoded XDR string representing this
:class:`TransactionEnvelope`. | def xdr(self):
"""Get the base64 encoded XDR string representing this
:class:`TransactionEnvelope`.
"""
te = Xdr.StellarXDRPacker()
te.pack_TransactionEnvelope(self.to_xdr_object())
te = base64.b64encode(te.get_buffer())
return te |
Create a new :class:`TransactionEnvelope` from an XDR string.
:param xdr: The XDR string that represents a transaction
envelope.
:type xdr: bytes, str | def from_xdr(cls, xdr):
"""Create a new :class:`TransactionEnvelope` from an XDR string.
:param xdr: The XDR string that represents a transaction
envelope.
:type xdr: bytes, str
"""
xdr_decoded = base64.b64decode(xdr)
te = Xdr.StellarXDRUnpacker(xdr_decoded)... |
table for caclulating CRC (list of 256 integers)
:param bytes data: Data for calculating CRC.
:param int crc: Initial value.
:param list table: Table for caclulating CRC (list of 256 integers)
:return: calculated value of CRC | def _crc16(data, crc, table):
"""table for caclulating CRC (list of 256 integers)
:param bytes data: Data for calculating CRC.
:param int crc: Initial value.
:param list table: Table for caclulating CRC (list of 256 integers)
:return: calculated value of CRC
"""
bytes_to_int = lambda x: ord(... |
Send a federation query to a Stellar Federation service.
For more info, see the `complete guide on Stellar Federation.
<https://www.stellar.org/developers/guides/concepts/federation.html>`_.
:param str address_or_id: The address which you expect te retrieve
federation information about.
:param... | def federation(address_or_id, fed_type='name', domain=None, allow_http=False):
"""Send a federation query to a Stellar Federation service.
For more info, see the `complete guide on Stellar Federation.
<https://www.stellar.org/developers/guides/concepts/federation.html>`_.
:param str address_or_id: The... |
Send a federation query to a Stellar Federation service.
Note: The preferred method of making this call is via
:function:`federation`, as it handles error checking and parsing of
arguments.
:param str address_or_id: The address which you expect te retrieve
federation information about.
:pa... | def _get_federation_info(address_or_id, federation_service, fed_type='name'):
"""Send a federation query to a Stellar Federation service.
Note: The preferred method of making this call is via
:function:`federation`, as it handles error checking and parsing of
arguments.
:param str address_or_id: T... |
Retrieve the FEDERATION_SERVER config from a domain's stellar.toml.
:param str domain: The domain the .toml file is hosted at.
:param bool allow_http: Specifies whether the request should go over plain
HTTP vs HTTPS. Note it is recommend that you *always* use HTTPS.
:return str: The FEDERATION_SERV... | def get_federation_service(domain, allow_http=False):
"""Retrieve the FEDERATION_SERVER config from a domain's stellar.toml.
:param str domain: The domain the .toml file is hosted at.
:param bool allow_http: Specifies whether the request should go over plain
HTTP vs HTTPS. Note it is recommend that... |
Retrieve the AUTH_SERVER config from a domain's stellar.toml.
:param str domain: The domain the .toml file is hosted at.
:param bool allow_http: Specifies whether the request should go over plain
HTTP vs HTTPS. Note it is recommend that you *always* use HTTPS.
:return str: The AUTH_SERVER url. | def get_auth_server(domain, allow_http=False):
"""Retrieve the AUTH_SERVER config from a domain's stellar.toml.
:param str domain: The domain the .toml file is hosted at.
:param bool allow_http: Specifies whether the request should go over plain
HTTP vs HTTPS. Note it is recommend that you *always*... |
Retrieve the stellar.toml file from a given domain.
Retrieve the stellar.toml file for information about interacting with
Stellar's federation protocol for a given Stellar Anchor (specified by a
domain).
:param str domain: The domain the .toml file is hosted at.
:param bool allow_http: Specifies w... | def get_stellar_toml(domain, allow_http=False):
"""Retrieve the stellar.toml file from a given domain.
Retrieve the stellar.toml file for information about interacting with
Stellar's federation protocol for a given Stellar Anchor (specified by a
domain).
:param str domain: The domain the .toml fil... |
Add an :class:`Operation <stellar_base.operation.Operation>` to
this transaction.
This method will only add an operation if it is not already in the
transaction's list of operations, i.e. every operation in the
transaction should be unique.
:param Operation operation: The opera... | def add_operation(self, operation):
"""Add an :class:`Operation <stellar_base.operation.Operation>` to
this transaction.
This method will only add an operation if it is not already in the
transaction's list of operations, i.e. every operation in the
transaction should be unique.... |
Creates an XDR Transaction object that represents this
:class:`Transaction`. | def to_xdr_object(self):
"""Creates an XDR Transaction object that represents this
:class:`Transaction`.
"""
source_account = account_xdr_object(self.source)
memo = self.memo.to_xdr_object()
operations = [o.to_xdr_object() for o in self.operations]
ext = Xdr.null... |
Packs and base64 encodes this :class:`Transaction` as an XDR
string. | def xdr(self):
"""Packs and base64 encodes this :class:`Transaction` as an XDR
string.
"""
tx = Xdr.StellarXDRPacker()
tx.pack_Transaction(self.to_xdr_object())
return base64.b64encode(tx.get_buffer()) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.