_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q229700 | on_balance_volume | train | def on_balance_volume(close_data, volume):
"""
On Balance Volume.
Formula:
start = 1
if CLOSEt > CLOSEt-1
obv = obvt-1 + volumet
elif CLOSEt < CLOSEt-1
obv = obvt-1 - volumet
elif CLOSEt == CLOSTt-1
obv = obvt-1
"""
catch_errors.check_for_input_len_diff(close... | python | {
"resource": ""
} |
q229701 | rate_of_change | train | def rate_of_change(data, period):
"""
Rate of Change.
Formula:
(Close - Close n periods ago) / (Close n periods ago) * 100
"""
catch_errors.check_for_period_error(data, period)
rocs = [((data[idx] - data[idx - (period - 1)]) /
data[idx - (period - 1)]) * 100 for idx in range(perio... | python | {
"resource": ""
} |
q229702 | average_true_range | train | def average_true_range(close_data, period):
"""
Average True Range.
Formula:
ATRt = ATRt-1 * (n - 1) + TRt / n
"""
tr = true_range(close_data, period)
atr = smoothed_moving_average(tr, period)
atr[0:period-1] = tr[0:period-1]
return atr | python | {
"resource": ""
} |
q229703 | relative_strength_index | train | def relative_strength_index(data, period):
"""
Relative Strength Index.
Formula:
RSI = 100 - (100 / 1 + (prevGain/prevLoss))
"""
catch_errors.check_for_period_error(data, period)
period = int(period)
changes = [data_tup[1] - data_tup[0] for data_tup in zip(data[::1], data[1::1])]
... | python | {
"resource": ""
} |
q229704 | vertical_horizontal_filter | train | def vertical_horizontal_filter(data, period):
"""
Vertical Horizontal Filter.
Formula:
ABS(pHIGH - pLOW) / SUM(ABS(Pi - Pi-1))
"""
catch_errors.check_for_period_error(data, period)
vhf = [abs(np.max(data[idx+1-period:idx+1]) -
np.min(data[idx+1-period:idx+1])) /
sum([ab... | python | {
"resource": ""
} |
q229705 | buying_pressure | train | def buying_pressure(close_data, low_data):
"""
Buying Pressure.
Formula:
BP = current close - min()
"""
catch_errors.check_for_input_len_diff(close_data, low_data)
bp = [close_data[idx] - np.min([low_data[idx], close_data[idx-1]]) for idx in range(1, len(close_data))]
bp = fill_for_nonc... | python | {
"resource": ""
} |
q229706 | ultimate_oscillator | train | def ultimate_oscillator(close_data, low_data):
"""
Ultimate Oscillator.
Formula:
UO = 100 * ((4 * AVG7) + (2 * AVG14) + AVG28) / (4 + 2 + 1)
"""
a7 = 4 * average_7(close_data, low_data)
a14 = 2 * average_14(close_data, low_data)
a28 = average_28(close_data, low_data)
uo = 100 * ((a7... | python | {
"resource": ""
} |
q229707 | aroon_up | train | def aroon_up(data, period):
"""
Aroon Up.
Formula:
AROONUP = (((PERIOD) - (PERIODS since PERIOD high)) / (PERIOD)) * 100
"""
catch_errors.check_for_period_error(data, period)
period = int(period)
a_up = [((period -
list(reversed(data[idx+1-period:idx+1])).index(np.max(data[... | python | {
"resource": ""
} |
q229708 | aroon_down | train | 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... | python | {
"resource": ""
} |
q229709 | upper_price_channel | train | 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... | python | {
"resource": ""
} |
q229710 | lower_price_channel | train | 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... | python | {
"resource": ""
} |
q229711 | exponential_moving_average | train | 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... | python | {
"resource": ""
} |
q229712 | commodity_channel_index | train | 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)
... | python | {
"resource": ""
} |
q229713 | williams_percent_r | train | 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]
... | python | {
"resource": ""
} |
q229714 | moving_average_convergence_divergence | train | 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... | python | {
"resource": ""
} |
q229715 | money_flow_index | train | 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... | python | {
"resource": ""
} |
q229716 | typical_price | train | 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))]
... | python | {
"resource": ""
} |
q229717 | true_range | train | 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]),
... | python | {
"resource": ""
} |
q229718 | double_smoothed_stochastic | train | 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, ... | python | {
"resource": ""
} |
q229719 | volume_adjusted_moving_average | train | 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(... | python | {
"resource": ""
} |
q229720 | double_exponential_moving_average | train | def double_exponential_moving_average(data, period):
"""
Double Exponential Moving Average.
Formula:
DEMA = 2*EMA - EMA(EMA)
"""
catch_errors.check_for_period_error(data, period)
dema = (2 * ema(data, period)) - ema(ema(data, period), period)
return dema | python | {
"resource": ""
} |
q229721 | triangular_moving_average | train | 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 | python | {
"resource": ""
} |
q229722 | weighted_moving_average | train | 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 = []
... | python | {
"resource": ""
} |
q229723 | conversion_base_line_helper | train | 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... | python | {
"resource": ""
} |
q229724 | chande_momentum_oscillator | train | 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-... | python | {
"resource": ""
} |
q229725 | price_oscillator | train | 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... | python | {
"resource": ""
} |
q229726 | check_for_period_error | train | 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 ... | python | {
"resource": ""
} |
q229727 | check_for_input_len_diff | train | 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
... | python | {
"resource": ""
} |
q229728 | upper_bollinger_band | train | 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... | python | {
"resource": ""
} |
q229729 | middle_bollinger_band | train | 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 | python | {
"resource": ""
} |
q229730 | lower_bollinger_band | train | 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... | python | {
"resource": ""
} |
q229731 | percent_bandwidth | train | 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... | python | {
"resource": ""
} |
q229732 | standard_deviation | train | 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... | python | {
"resource": ""
} |
q229733 | detrended_price_oscillator | train | 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... | python | {
"resource": ""
} |
q229734 | smoothed_moving_average | train | 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() | python | {
"resource": ""
} |
q229735 | chaikin_money_flow | train | 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_... | python | {
"resource": ""
} |
q229736 | hull_moving_average | train | 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 | python | {
"resource": ""
} |
q229737 | standard_variance | train | 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 | python | {
"resource": ""
} |
q229738 | calculate_up_moves | train | 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 | python | {
"resource": ""
} |
q229739 | calculate_down_moves | train | 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 | python | {
"resource": ""
} |
q229740 | average_directional_index | train | 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) -
... | python | {
"resource": ""
} |
q229741 | linear_weighted_moving_average | train | 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)]
... | python | {
"resource": ""
} |
q229742 | volume_oscillator | train | 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 * ((... | python | {
"resource": ""
} |
q229743 | triple_exponential_moving_average | train | 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... | python | {
"resource": ""
} |
q229744 | money_flow | train | 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 | python | {
"resource": ""
} |
q229745 | Mint.request_and_check | train | 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'
... | python | {
"resource": ""
} |
q229746 | Mint.get_transactions_json | train | 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... | python | {
"resource": ""
} |
q229747 | Mint.get_detailed_transactions | train | def get_detailed_transactions(self, include_investment=False,
skip_duplicates=False,
remove_pending=True,
start_date=None):
"""Returns the JSON transaction data as a DataFrame, and converts
current year... | python | {
"resource": ""
} |
q229748 | Mint.get_transactions_csv | train | 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 ... | python | {
"resource": ""
} |
q229749 | Mint.get_transactions | train | 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... | python | {
"resource": ""
} |
q229750 | Address.payments | train | 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... | python | {
"resource": ""
} |
q229751 | Address.offers | train | 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 ... | python | {
"resource": ""
} |
q229752 | Address.transactions | train | 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... | python | {
"resource": ""
} |
q229753 | Address.operations | train | 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... | python | {
"resource": ""
} |
q229754 | Address.trades | train | 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 ... | python | {
"resource": ""
} |
q229755 | Address.effects | train | 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... | python | {
"resource": ""
} |
q229756 | Horizon.submit | train | 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... | python | {
"resource": ""
} |
q229757 | Horizon.account | train | 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... | python | {
"resource": ""
} |
q229758 | Horizon.account_data | train | 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... | python | {
"resource": ""
} |
q229759 | Horizon.account_effects | train | 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... | python | {
"resource": ""
} |
q229760 | Horizon.assets | train | 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
... | python | {
"resource": ""
} |
q229761 | Horizon.transaction | train | 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... | python | {
"resource": ""
} |
q229762 | Horizon.transaction_operations | train | 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... | python | {
"resource": ""
} |
q229763 | Horizon.transaction_effects | train | 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... | python | {
"resource": ""
} |
q229764 | Horizon.order_book | train | 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... | python | {
"resource": ""
} |
q229765 | Horizon.ledger | train | 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... | python | {
"resource": ""
} |
q229766 | Horizon.ledger_effects | train | 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>`_
... | python | {
"resource": ""
} |
q229767 | Horizon.ledger_transactions | train | 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... | python | {
"resource": ""
} |
q229768 | Horizon.effects | train | 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... | python | {
"resource": ""
} |
q229769 | Horizon.operations | train | 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... | python | {
"resource": ""
} |
q229770 | Horizon.operation | train | 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.
... | python | {
"resource": ""
} |
q229771 | Horizon.operation_effects | train | 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-... | python | {
"resource": ""
} |
q229772 | Horizon.paths | train | 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.
... | python | {
"resource": ""
} |
q229773 | Horizon.trades | train | 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... | python | {
"resource": ""
} |
q229774 | Horizon.trade_aggregations | train | 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 ... | python | {
"resource": ""
} |
q229775 | Horizon.offer_trades | train | 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_... | python | {
"resource": ""
} |
q229776 | TransactionEnvelope.sign | train | 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... | python | {
"resource": ""
} |
q229777 | TransactionEnvelope.signature_base | train | 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 ... | python | {
"resource": ""
} |
q229778 | get_federation_service | train | 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... | python | {
"resource": ""
} |
q229779 | get_auth_server | train | 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*... | python | {
"resource": ""
} |
q229780 | get_stellar_toml | train | 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... | python | {
"resource": ""
} |
q229781 | Keypair.account_xdr_object | train | def account_xdr_object(self):
"""Create PublicKey XDR object via public key bytes.
:return: Serialized XDR of PublicKey type.
"""
return Xdr.types.PublicKey(Xdr.const.KEY_TYPE_ED25519,
self.verifying_key.to_bytes()) | python | {
"resource": ""
} |
q229782 | Keypair.xdr | train | def xdr(self):
"""Generate base64 encoded XDR PublicKey object.
Return a base64 encoded PublicKey XDR object, for sending over the wire
when interacting with stellar.
:return: The base64 encoded PublicKey XDR structure.
"""
kp = Xdr.StellarXDRPacker()
kp.pack_Pu... | python | {
"resource": ""
} |
q229783 | Keypair.verify | train | def verify(self, data, signature):
"""Verify the signature of a sequence of bytes.
Verify the signature of a sequence of bytes using the verifying
(public) key and the data that was originally signed, otherwise throws
an exception.
:param bytes data: A sequence of bytes that we... | python | {
"resource": ""
} |
q229784 | Keypair.sign_decorated | train | def sign_decorated(self, data):
"""Sign a bytes-like object and return the decorated signature.
Sign a bytes-like object by signing the data using the signing
(private) key, and return a decorated signature, which includes the
last four bytes of the public key as a signature hint to go ... | python | {
"resource": ""
} |
q229785 | bytes_from_decode_data | train | def bytes_from_decode_data(s):
"""copy from base64._bytes_from_decode_data
"""
if isinstance(s, (str, unicode)):
try:
return s.encode('ascii')
except UnicodeEncodeError:
raise NotValidParamError(
'String argument should contain only ASCII characters')
... | python | {
"resource": ""
} |
q229786 | Operation.to_xdr_amount | train | def to_xdr_amount(value):
"""Converts an amount to the appropriate value to send over the network
as a part of an XDR object.
Each asset amount is encoded as a signed 64-bit integer in the XDR
structures. An asset amount unit (that which is seen by end users) is
scaled down by a... | python | {
"resource": ""
} |
q229787 | TextMemo.to_xdr_object | train | def to_xdr_object(self):
"""Creates an XDR Memo object for a transaction with MEMO_TEXT."""
return Xdr.types.Memo(type=Xdr.const.MEMO_TEXT, text=self.text) | python | {
"resource": ""
} |
q229788 | IdMemo.to_xdr_object | train | def to_xdr_object(self):
"""Creates an XDR Memo object for a transaction with MEMO_ID."""
return Xdr.types.Memo(type=Xdr.const.MEMO_ID, id=self.memo_id) | python | {
"resource": ""
} |
q229789 | HashMemo.to_xdr_object | train | def to_xdr_object(self):
"""Creates an XDR Memo object for a transaction with MEMO_HASH."""
return Xdr.types.Memo(type=Xdr.const.MEMO_HASH, hash=self.memo_hash) | python | {
"resource": ""
} |
q229790 | RetHashMemo.to_xdr_object | train | def to_xdr_object(self):
"""Creates an XDR Memo object for a transaction with MEMO_RETURN."""
return Xdr.types.Memo(
type=Xdr.const.MEMO_RETURN, retHash=self.memo_return) | python | {
"resource": ""
} |
q229791 | Builder.append_hashx_signer | train | def append_hashx_signer(self, hashx, signer_weight, source=None):
"""Add a HashX signer to an account.
Add a HashX signer to an account via a :class:`SetOptions
<stellar_base.operation.SetOptions` operation. This is a helper
function for :meth:`append_set_options_op`.
:param ha... | python | {
"resource": ""
} |
q229792 | Builder.append_pre_auth_tx_signer | train | def append_pre_auth_tx_signer(self,
pre_auth_tx,
signer_weight,
source=None):
"""Add a PreAuthTx signer to an account.
Add a PreAuthTx signer to an account via a :class:`SetOptions
<stellar_bas... | python | {
"resource": ""
} |
q229793 | Builder.next_builder | train | def next_builder(self):
"""Create a new builder based off of this one with its sequence number
incremented.
:return: A new Builder instance
:rtype: :class:`Builder`
"""
sequence = self.sequence + 1
next_builder = Builder(
horizon_uri=self.horizon.hor... | python | {
"resource": ""
} |
q229794 | Builder.get_sequence | train | def get_sequence(self):
"""Get the sequence number for a given account via Horizon.
:return: The current sequence number for a given account
:rtype: int
"""
if not self.address:
raise StellarAddressInvalidError('No address provided.')
address = self.horizon.... | python | {
"resource": ""
} |
q229795 | Asset.to_dict | train | def to_dict(self):
"""Generate a dict for this object's attributes.
:return: A dict representing an :class:`Asset`
"""
rv = {'code': self.code}
if not self.is_native():
rv['issuer'] = self.issuer
rv['type'] = self.type
else:
rv['type']... | python | {
"resource": ""
} |
q229796 | id_unique | train | def id_unique(dict_id, name, lineno):
"""Returns True if dict_id not already used. Otherwise, invokes error"""
if dict_id in name_dict:
global error_occurred
error_occurred = True
print(
"ERROR - {0:s} definition {1:s} at line {2:d} conflicts with {3:s}"
.format(... | python | {
"resource": ""
} |
q229797 | main | train | def main():
'''Base58 encode or decode FILE, or standard input, to standard output.'''
import sys
import argparse
stdout = buffer(sys.stdout)
parser = argparse.ArgumentParser(description=main.__doc__)
parser.add_argument(
'file',
metavar='FILE',
nargs='?',
type... | python | {
"resource": ""
} |
q229798 | Utils._Dhcpcd | train | def _Dhcpcd(self, interfaces, logger):
"""Use dhcpcd to activate the interfaces.
Args:
interfaces: list of string, the output device names to enable.
logger: logger object, used to write to SysLog and serial port.
"""
for interface in interfaces:
dhcpcd = ['/sbin/dhcpcd']
try:
... | python | {
"resource": ""
} |
q229799 | _CreateTempDir | train | def _CreateTempDir(prefix, run_dir=None):
"""Context manager for creating a temporary directory.
Args:
prefix: string, the prefix for the temporary directory.
run_dir: string, the base directory location of the temporary directory.
Yields:
string, the temporary directory created.
"""
temp_dir = ... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.