idx
int64
0
252k
question
stringlengths
48
5.28k
target
stringlengths
5
1.23k
229,200
def validateCommit ( self , commit : Commit , sender : str ) -> bool : key = ( commit . viewNo , commit . ppSeqNo ) if not self . has_prepared ( key ) : self . enqueue_commit ( commit , sender ) return False if self . commits . hasCommitFrom ( commit , sender ) : raise SuspiciousNode ( sender , Suspicions . DUPLICATE_C...
Return whether the COMMIT specified is valid .
229,201
def addToCommits ( self , commit : Commit , sender : str ) : self . _bls_bft_replica . process_commit ( commit , sender ) self . commits . addVote ( commit , sender ) self . tryOrder ( commit )
Add the specified COMMIT to this replica s list of received commit requests .
229,202
def canOrder ( self , commit : Commit ) -> Tuple [ bool , Optional [ str ] ] : quorum = self . quorums . commit . value if not self . commits . hasQuorum ( commit , quorum ) : return False , "no quorum ({}): {} commits where f is {}" . format ( quorum , commit , self . f ) key = ( commit . viewNo , commit . ppSeqNo ) i...
Return whether the specified commitRequest can be returned to the node .
229,203
def all_prev_ordered ( self , commit : Commit ) : viewNo , ppSeqNo = commit . viewNo , commit . ppSeqNo if self . last_ordered_3pc == ( viewNo , ppSeqNo - 1 ) : return True toCheck = set ( ) toCheck . update ( set ( self . sentPrePrepares . keys ( ) ) ) toCheck . update ( set ( self . prePrepares . keys ( ) ) ) toCheck...
Return True if all previous COMMITs have been ordered
229,204
def process_checkpoint ( self , msg : Checkpoint , sender : str ) -> bool : self . logger . info ( '{} processing checkpoint {} from {}' . format ( self , msg , sender ) ) result , reason = self . validator . validate_checkpoint_msg ( msg ) if result == DISCARD : self . discard ( msg , "{} discard message {} from {} " ...
Process checkpoint messages
229,205
def _process_stashed_pre_prepare_for_time_if_possible ( self , key : Tuple [ int , int ] ) : self . logger . debug ( '{} going to process stashed PRE-PREPAREs with ' 'incorrect times' . format ( self ) ) q = self . quorums . f if len ( self . preparesWaitingForPrePrepare [ key ] ) > q : times = [ pr . ppTime for ( pr ,...
Check if any PRE - PREPAREs that were stashed since their time was not acceptable can now be accepted since enough PREPAREs are received
229,206
def _remove_till_caught_up_3pc ( self , last_caught_up_3PC ) : outdated_pre_prepares = { } for key , pp in self . prePrepares . items ( ) : if compare_3PC_keys ( key , last_caught_up_3PC ) >= 0 : outdated_pre_prepares [ key ] = pp for key , pp in self . sentPrePrepares . items ( ) : if compare_3PC_keys ( key , last_cau...
Remove any 3 phase messages till the last ordered key and also remove any corresponding request keys
229,207
def _remove_ordered_from_queue ( self , last_caught_up_3PC = None ) : to_remove = [ ] for i , msg in enumerate ( self . outBox ) : if isinstance ( msg , Ordered ) and ( not last_caught_up_3PC or compare_3PC_keys ( ( msg . viewNo , msg . ppSeqNo ) , last_caught_up_3PC ) >= 0 ) : to_remove . append ( i ) self . logger . ...
Remove any Ordered that the replica might be sending to node which is less than or equal to last_caught_up_3PC if last_caught_up_3PC is passed else remove all ordered needed in catchup
229,208
def _remove_stashed_checkpoints ( self , till_3pc_key = None ) : if till_3pc_key is None : self . stashedRecvdCheckpoints . clear ( ) self . logger . info ( '{} removing all stashed checkpoints' . format ( self ) ) return for view_no in list ( self . stashedRecvdCheckpoints . keys ( ) ) : if view_no < till_3pc_key [ 0 ...
Remove stashed received checkpoints up to till_3pc_key if provided otherwise remove all stashed received checkpoints
229,209
def checkPortAvailable ( ha ) : sockTypes = ( socket . SOCK_DGRAM , socket . SOCK_STREAM ) for typ in sockTypes : sock = socket . socket ( socket . AF_INET , typ ) try : sock . setsockopt ( socket . SOL_SOCKET , socket . SO_REUSEADDR , 1 ) sock . bind ( ha ) if typ == socket . SOCK_STREAM : l_onoff = 1 l_linger = 0 soc...
Checks whether the given port is available
229,210
def evenCompare ( a : str , b : str ) -> bool : ab = a . encode ( 'utf-8' ) bb = b . encode ( 'utf-8' ) ac = crypto_hash_sha256 ( ab ) bc = crypto_hash_sha256 ( bb ) return ac < bc
A deterministic but more evenly distributed comparator than simple alphabetical . Useful when comparing consecutive strings and an even distribution is needed . Provides an even chance of returning true as often as false
229,211
def center_band ( close_data , high_data , low_data , period ) : tp = typical_price ( close_data , high_data , low_data ) cb = sma ( tp , period ) return cb
Center Band .
229,212
def simple_moving_average ( data , period ) : catch_errors . check_for_period_error ( data , period ) with warnings . catch_warnings ( ) : warnings . simplefilter ( "ignore" , category = RuntimeWarning ) sma = [ np . mean ( data [ idx - ( period - 1 ) : idx + 1 ] ) for idx in range ( 0 , len ( data ) ) ] sma = fill_for...
Simple Moving Average .
229,213
def average_true_range_percent ( close_data , period ) : catch_errors . check_for_period_error ( close_data , period ) atrp = ( atr ( close_data , period ) / np . array ( close_data ) ) * 100 return atrp
Average True Range Percent .
229,214
def on_balance_volume ( close_data , volume ) : catch_errors . check_for_input_len_diff ( close_data , volume ) obv = np . zeros ( len ( volume ) ) obv [ 0 ] = 1 for idx in range ( 1 , len ( obv ) ) : if close_data [ idx ] > close_data [ idx - 1 ] : obv [ idx ] = obv [ idx - 1 ] + volume [ idx ] elif close_data [ idx ]...
On Balance Volume .
229,215
def rate_of_change ( data , period ) : catch_errors . check_for_period_error ( data , period ) rocs = [ ( ( data [ idx ] - data [ idx - ( period - 1 ) ] ) / data [ idx - ( period - 1 ) ] ) * 100 for idx in range ( period - 1 , len ( data ) ) ] rocs = fill_for_noncomputable_vals ( data , rocs ) return rocs
Rate of Change .
229,216
def average_true_range ( close_data , period ) : tr = true_range ( close_data , period ) atr = smoothed_moving_average ( tr , period ) atr [ 0 : period - 1 ] = tr [ 0 : period - 1 ] return atr
Average True Range .
229,217
def relative_strength_index ( data , period ) : 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 ] ) ] filtered_gain = [ val < 0 for val in changes ] gains = [ 0 if filtered_gain [ idx ] is T...
Relative Strength Index .
229,218
def vertical_horizontal_filter ( data , period ) : 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 ( [ abs ( data [ idx + 1 - period : idx + 1 ] [ i ] - data [ idx + 1 - period : idx + 1 ] [...
Vertical Horizontal Filter .
229,219
def buying_pressure ( close_data , low_data ) : 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_noncomputable_vals ( close_data , bp ) return bp
Buying Pressure .
229,220
def ultimate_oscillator ( close_data , low_data ) : 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 + a14 + a28 ) / 7 ) return uo
Ultimate Oscillator .
229,221
def aroon_up ( data , period ) : 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 [ idx + 1 - period : idx + 1 ] ) ) ) / float ( period ) ) * 100 for idx in range ( period - 1 , len (...
Aroon Up .
229,222
def aroon_down ( data , period ) : 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 ( data [ idx + 1 - period : idx + 1 ] ) ) ) / float ( period ) ) * 100 for idx in range ( period - 1 , l...
Aroon Down .
229,223
def upper_price_channel ( data , period , upper_percent ) : catch_errors . check_for_period_error ( data , period ) emas = ema ( data , period ) upper_channel = [ val * ( 1 + float ( upper_percent ) / 100 ) for val in emas ] return upper_channel
Upper Price Channel .
229,224
def lower_price_channel ( data , period , lower_percent ) : catch_errors . check_for_period_error ( data , period ) emas = ema ( data , period ) lower_channel = [ val * ( 1 - float ( lower_percent ) / 100 ) for val in emas ] return lower_channel
Lower Price Channel .
229,225
def exponential_moving_average ( data , period ) : catch_errors . check_for_period_error ( data , period ) emas = [ exponential_moving_average_helper ( data [ idx - period + 1 : idx + 1 ] , period ) for idx in range ( period - 1 , len ( data ) ) ] emas = fill_for_noncomputable_vals ( data , emas ) return emas
Exponential Moving Average .
229,226
def commodity_channel_index ( close_data , high_data , low_data , period ) : catch_errors . check_for_input_len_diff ( close_data , high_data , low_data ) catch_errors . check_for_period_error ( close_data , period ) tp = typical_price ( close_data , high_data , low_data ) cci = ( ( tp - sma ( tp , period ) ) / ( 0.015...
Commodity Channel Index .
229,227
def williams_percent_r ( close_data ) : 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 ] return wr
Williams %R .
229,228
def moving_average_convergence_divergence ( data , short_period , long_period ) : catch_errors . check_for_period_error ( data , short_period ) catch_errors . check_for_period_error ( data , long_period ) macd = ema ( data , short_period ) - ema ( data , long_period ) return macd
Moving Average Convergence Divergence .
229,229
def money_flow_index ( close_data , high_data , low_data , volume , period ) : catch_errors . check_for_input_len_diff ( close_data , high_data , low_data , volume ) catch_errors . check_for_period_error ( close_data , period ) mf = money_flow ( close_data , high_data , low_data , volume ) tp = typical_price ( close_da...
Money Flow Index .
229,230
def typical_price ( close_data , high_data , low_data ) : 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 ) ) ] return np . array ( tp )
Typical Price .
229,231
def true_range ( close_data , period ) : 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 ] ) , abs ( np . max ( close_data [ idx + 1 - period : idx + 1 ] ) - close_data [ idx - 1...
True Range .
229,232
def double_smoothed_stochastic ( data , period ) : 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 , len ( data ) ) ] sm_lows = ema ( ema ( lows , period ) , period ) highs = [ np . max ( data [ idx + 1 - peri...
Double Smoothed Stochastic .
229,233
def volume_adjusted_moving_average ( close_data , volume , period ) : catch_errors . check_for_input_len_diff ( close_data , volume ) catch_errors . check_for_period_error ( close_data , period ) avg_vol = np . mean ( volume ) vol_incr = avg_vol * 0.67 vol_ratio = [ val / vol_incr for val in volume ] close_vol = np . a...
Volume Adjusted Moving Average .
229,234
def double_exponential_moving_average ( data , period ) : catch_errors . check_for_period_error ( data , period ) dema = ( 2 * ema ( data , period ) ) - ema ( ema ( data , period ) , period ) return dema
Double Exponential Moving Average .
229,235
def triangular_moving_average ( data , period ) : catch_errors . check_for_period_error ( data , period ) tma = sma ( sma ( data , period ) , period ) return tma
Triangular Moving Average .
229,236
def weighted_moving_average ( data , period ) : catch_errors . check_for_period_error ( data , period ) k = ( period * ( period + 1 ) ) / 2.0 wmas = [ ] for idx in range ( 0 , len ( data ) - period + 1 ) : product = [ data [ idx + period_idx ] * ( period_idx + 1 ) for period_idx in range ( 0 , period ) ] wma = sum ( pr...
Weighted Moving Average .
229,237
def conversion_base_line_helper ( data , period ) : 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 , len ( data ) ) ] cblh = fill_for_noncomputable_vals ( data , cb...
The only real difference between TenkanSen and KijunSen is the period value
229,238
def chande_momentum_oscillator ( close_data , period ) : catch_errors . check_for_period_error ( close_data , period ) close_data = np . array ( close_data ) moving_period_diffs = [ [ ( close_data [ idx + 1 - period : idx + 1 ] [ i ] - close_data [ idx + 1 - period : idx + 1 ] [ i - 1 ] ) for i in range ( 1 , len ( clo...
Chande Momentum Oscillator .
229,239
def price_oscillator ( data , short_period , long_period ) : 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_long = ema ( data , long_period ) po = ( ( ema_short - ema_long ) / ema_long ) * 100 return ...
Price Oscillator .
229,240
def check_for_period_error ( data , period ) : period = int ( period ) data_len = len ( data ) if data_len < period : raise Exception ( "Error: data_len < period" )
Check for Period Error .
229,241
def check_for_input_len_diff ( * args ) : arrays_len = [ len ( arr ) for arr in args ] if not all ( a == arrays_len [ 0 ] for a in arrays_len ) : err_msg = ( "Error: mismatched data lengths, check to ensure that all " "input data is the same length and valid" ) raise Exception ( err_msg )
Check for Input Length Difference .
229,242
def upper_bollinger_band ( data , period , std_mult = 2.0 ) : catch_errors . check_for_period_error ( data , period ) period = int ( period ) simple_ma = sma ( data , period ) [ period - 1 : ] upper_bb = [ ] for idx in range ( len ( data ) - period + 1 ) : std_dev = np . std ( data [ idx : idx + period ] ) upper_bb . a...
Upper Bollinger Band .
229,243
def middle_bollinger_band ( data , period , std = 2.0 ) : catch_errors . check_for_period_error ( data , period ) period = int ( period ) mid_bb = sma ( data , period ) return mid_bb
Middle Bollinger Band .
229,244
def lower_bollinger_band ( data , period , std = 2.0 ) : 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 ( data ) - period + 1 ) : std_dev = np . std ( data [ idx : idx + period ] ) lower_bb . append...
Lower Bollinger Band .
229,245
def percent_bandwidth ( data , period , std = 2.0 ) : catch_errors . check_for_period_error ( data , period ) period = int ( period ) percent_bandwidth = ( ( np . array ( data ) - lower_bollinger_band ( data , period , std ) ) / bb_range ( data , period , std ) ) return percent_bandwidth
Percent Bandwidth .
229,246
def standard_deviation ( data , period ) : 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 ( data , stds ) return stds
Standard Deviation .
229,247
def detrended_price_oscillator ( data , period ) : 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 ( period - 1 , len ( data ) ) ] dop = fill_for_noncomputable_vals ( data , dop ...
Detrended Price Oscillator .
229,248
def smoothed_moving_average ( data , period ) : catch_errors . check_for_period_error ( data , period ) series = pd . Series ( data ) return series . ewm ( alpha = 1.0 / period ) . mean ( ) . values . flatten ( )
Smoothed Moving Average .
229,249
def chaikin_money_flow ( close_data , high_data , low_data , volume , period ) : catch_errors . check_for_input_len_diff ( close_data , high_data , low_data , volume ) catch_errors . check_for_period_error ( close_data , period ) close_data = np . array ( close_data ) high_data = np . array ( high_data ) low_data = np ...
Chaikin Money Flow .
229,250
def hull_moving_average ( data , period ) : 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
Hull Moving Average .
229,251
def standard_variance ( data , period ) : 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
Standard Variance .
229,252
def calculate_up_moves ( high_data ) : up_moves = [ high_data [ idx ] - high_data [ idx - 1 ] for idx in range ( 1 , len ( high_data ) ) ] return [ np . nan ] + up_moves
Up Move .
229,253
def calculate_down_moves ( low_data ) : down_moves = [ low_data [ idx - 1 ] - low_data [ idx ] for idx in range ( 1 , len ( low_data ) ) ] return [ np . nan ] + down_moves
Down Move .
229,254
def average_directional_index ( close_data , high_data , low_data , period ) : avg_di = ( abs ( ( positive_directional_index ( close_data , high_data , low_data , period ) - negative_directional_index ( close_data , high_data , low_data , period ) ) / ( positive_directional_index ( close_data , high_data , low_data , p...
Average Directional Index .
229,255
def linear_weighted_moving_average ( data , period ) : 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 ) ] for i in data [ idx - ( period - 1 ) : idx + 1 ] ] ) ) / sum ( range (...
Linear Weighted Moving Average .
229,256
def volume_oscillator ( volume , short_period , long_period ) : catch_errors . check_for_period_error ( volume , short_period ) catch_errors . check_for_period_error ( volume , long_period ) vo = ( 100 * ( ( sma ( volume , short_period ) - sma ( volume , long_period ) ) / sma ( volume , long_period ) ) ) return vo
Volume Oscillator .
229,257
def triple_exponential_moving_average ( data , period ) : catch_errors . check_for_period_error ( data , period ) tema = ( ( 3 * ema ( data , period ) - ( 3 * ema ( ema ( data , period ) , period ) ) ) + ema ( ema ( ema ( data , period ) , period ) , period ) ) return tema
Triple Exponential Moving Average .
229,258
def money_flow ( close_data , high_data , low_data , volume ) : 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
Money Flow .
229,259
def request_and_check ( self , url , method = 'get' , expected_content_type = None , ** kwargs ) : assert method in [ 'get' , 'post' ] result = self . driver . request ( method , url , ** kwargs ) if result . status_code != requests . codes . ok : raise RuntimeError ( 'Error requesting %r, status = %d' % ( url , result...
Performs a request and checks that the status is OK and that the content - type matches expectations .
229,260
def get_transactions_json ( self , include_investment = False , skip_duplicates = False , start_date = None , id = 0 ) : self . set_user_property ( 'hide_duplicates' , 'T' if skip_duplicates else 'F' ) try : start_date = datetime . strptime ( start_date , '%m/%d/%y' ) except ( TypeError , ValueError ) : start_date = No...
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 .
229,261
def get_detailed_transactions ( self , include_investment = False , skip_duplicates = False , remove_pending = True , start_date = None ) : assert_pd ( ) result = self . get_transactions_json ( include_investment , skip_duplicates , start_date ) df = pd . DataFrame ( result ) df [ 'odate' ] = df [ 'odate' ] . apply ( j...
Returns the JSON transaction data as a DataFrame and converts current year dates and prior year dates into consistent datetime format and reverses credit activity .
229,262
def get_transactions_csv ( self , include_investment = False , acct = 0 ) : params = None if include_investment or acct > 0 : params = { 'accountId' : acct } result = self . request_and_check ( '{}/transactionDownload.event' . format ( MINT_ROOT_URL ) , params = params , expected_content_type = 'text/csv' ) return resu...
Returns the raw CSV transaction data as downloaded from Mint .
229,263
def get_transactions ( self , include_investment = False ) : assert_pd ( ) s = StringIO ( self . get_transactions_csv ( include_investment = include_investment ) ) s . seek ( 0 ) df = pd . read_csv ( s , parse_dates = [ 'Date' ] ) df . columns = [ c . lower ( ) . replace ( ' ' , '_' ) for c in df . columns ] df . categ...
Returns the transaction data as a Pandas DataFrame .
229,264
def payments ( self , cursor = None , order = 'asc' , limit = 10 , sse = False ) : return self . horizon . account_payments ( address = self . address , cursor = cursor , order = order , limit = limit , sse = sse )
Retrieve the payments JSON from this instance s Horizon server .
229,265
def offers ( self , cursor = None , order = 'asc' , limit = 10 , sse = False ) : return self . horizon . account_offers ( self . address , cursor = cursor , order = order , limit = limit , sse = sse )
Retrieve the offers JSON from this instance s Horizon server .
229,266
def transactions ( self , cursor = None , order = 'asc' , limit = 10 , sse = False ) : return self . horizon . account_transactions ( self . address , cursor = cursor , order = order , limit = limit , sse = sse )
Retrieve the transactions JSON from this instance s Horizon server .
229,267
def operations ( self , cursor = None , order = 'asc' , limit = 10 , sse = False ) : return self . horizon . account_operations ( self . address , cursor = cursor , order = order , limit = limit , sse = sse )
Retrieve the operations JSON from this instance s Horizon server .
229,268
def trades ( self , cursor = None , order = 'asc' , limit = 10 , sse = False ) : return self . horizon . account_trades ( self . address , cursor = cursor , order = order , limit = limit , sse = sse )
Retrieve the trades JSON from this instance s Horizon server .
229,269
def effects ( self , cursor = None , order = 'asc' , limit = 10 , sse = False ) : return self . horizon . account_effects ( self . address , cursor = cursor , order = order , limit = limit , sse = sse )
Retrieve the effects JSON from this instance s Horizon server .
229,270
def submit ( self , te ) : params = { 'tx' : te } url = urljoin ( self . horizon_uri , 'transactions/' ) reply = None retry_count = self . num_retries while True : try : reply = self . _session . post ( url , data = params , timeout = self . request_timeout ) return check_horizon_reply ( reply . json ( ) ) except ( Req...
Submit the transaction using a pooled connection and retry on failure .
229,271
def account ( self , address ) : endpoint = '/accounts/{account_id}' . format ( account_id = address ) return self . query ( endpoint )
Returns information and links relating to a single account .
229,272
def account_data ( self , address , key ) : endpoint = '/accounts/{account_id}/data/{data_key}' . format ( account_id = address , data_key = key ) return self . query ( endpoint )
This endpoint represents a single data associated with a given account .
229,273
def account_effects ( self , address , cursor = None , order = 'asc' , limit = 10 , sse = False ) : endpoint = '/accounts/{account_id}/effects' . format ( account_id = address ) params = self . __query_params ( cursor = cursor , order = order , limit = limit ) return self . query ( endpoint , params , sse )
This endpoint represents all effects that changed a given account .
229,274
def assets ( self , asset_code = None , asset_issuer = None , cursor = None , order = 'asc' , limit = 10 ) : endpoint = '/assets' params = self . __query_params ( asset_code = asset_code , asset_issuer = asset_issuer , cursor = cursor , order = order , limit = limit ) return self . query ( endpoint , params )
This endpoint represents all assets . It will give you all the assets in the system along with various statistics about each .
229,275
def transaction ( self , tx_hash ) : endpoint = '/transactions/{tx_hash}' . format ( tx_hash = tx_hash ) return self . query ( endpoint )
The transaction details endpoint provides information on a single transaction .
229,276
def transaction_operations ( self , tx_hash , cursor = None , order = 'asc' , include_failed = False , limit = 10 ) : endpoint = '/transactions/{tx_hash}/operations' . format ( tx_hash = tx_hash ) params = self . __query_params ( cursor = cursor , order = order , limit = limit , include_failed = include_failed ) return...
This endpoint represents all operations that are part of a given transaction .
229,277
def transaction_effects ( self , tx_hash , cursor = None , order = 'asc' , limit = 10 ) : endpoint = '/transactions/{tx_hash}/effects' . format ( tx_hash = tx_hash ) params = self . __query_params ( cursor = cursor , order = order , limit = limit ) return self . query ( endpoint , params )
This endpoint represents all effects that occurred as a result of a given transaction .
229,278
def order_book ( self , selling_asset_code , buying_asset_code , selling_asset_issuer = None , buying_asset_issuer = None , limit = 10 ) : selling_asset = Asset ( selling_asset_code , selling_asset_issuer ) buying_asset = Asset ( buying_asset_code , buying_asset_issuer ) asset_params = { 'selling_asset_type' : selling_...
Return for each orderbook a summary of the orderbook and the bids and asks associated with that orderbook .
229,279
def ledger ( self , ledger_id ) : endpoint = '/ledgers/{ledger_id}' . format ( ledger_id = ledger_id ) return self . query ( endpoint )
The ledger details endpoint provides information on a single ledger .
229,280
def ledger_effects ( self , ledger_id , cursor = None , order = 'asc' , limit = 10 ) : endpoint = '/ledgers/{ledger_id}/effects' . format ( ledger_id = ledger_id ) params = self . __query_params ( cursor = cursor , order = order , limit = limit ) return self . query ( endpoint , params )
This endpoint represents all effects that occurred in the given ledger .
229,281
def ledger_transactions ( self , ledger_id , cursor = None , order = 'asc' , include_failed = False , limit = 10 ) : endpoint = '/ledgers/{ledger_id}/transactions' . format ( ledger_id = ledger_id ) params = self . __query_params ( cursor = cursor , order = order , limit = limit , include_failed = include_failed ) retu...
This endpoint represents all transactions in a given ledger .
229,282
def effects ( self , cursor = None , order = 'asc' , limit = 10 , sse = False ) : endpoint = '/effects' params = self . __query_params ( cursor = cursor , order = order , limit = limit ) return self . query ( endpoint , params , sse )
This endpoint represents all effects .
229,283
def operations ( self , cursor = None , order = 'asc' , limit = 10 , include_failed = False , sse = False ) : endpoint = '/operations' params = self . __query_params ( cursor = cursor , order = order , limit = limit , include_failed = include_failed ) return self . query ( endpoint , params , sse )
This endpoint represents all operations that are part of validated transactions .
229,284
def operation ( self , op_id ) : endpoint = '/operations/{op_id}' . format ( op_id = op_id ) return self . query ( endpoint )
The operation details endpoint provides information on a single operation .
229,285
def operation_effects ( self , op_id , cursor = None , order = 'asc' , limit = 10 ) : endpoint = '/operations/{op_id}/effects' . format ( op_id = op_id ) params = self . __query_params ( cursor = cursor , order = order , limit = limit ) return self . query ( endpoint , params )
This endpoint represents all effects that occurred as a result of a given operation .
229,286
def paths ( self , destination_account , destination_amount , source_account , destination_asset_code , destination_asset_issuer = None ) : destination_asset = Asset ( destination_asset_code , destination_asset_issuer ) destination_asset_params = { 'destination_asset_type' : destination_asset . type , 'destination_asse...
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 .
229,287
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 ) : base_asset = Asset ( base_asset_code , base_asset_issuer ) counter_asset = Asset ( counter_asset_code , counter_asset_issuer ...
Load a list of trades optionally filtered by an orderbook .
229,288
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 ) : allowed_resolutions = ( 60000 , 300000 , 900000 , 3600000 , 86400000 , 604800000 ) if resolution ...
Load a list of aggregated historical trade data optionally filtered by an orderbook .
229,289
def offer_trades ( self , offer_id , cursor = None , order = 'asc' , limit = 10 ) : endpoint = '/offers/{offer_id}/trades' . format ( offer_id = offer_id ) params = self . __query_params ( cursor = cursor , order = order , limit = limit ) return self . query ( endpoint , params )
This endpoint represents all trades for a given offer .
229,290
def sign ( self , keypair ) : assert isinstance ( keypair , Keypair ) tx_hash = self . hash_meta ( ) sig = keypair . sign_decorated ( tx_hash ) sig_dict = [ signature . __dict__ for signature in self . signatures ] if sig . __dict__ in sig_dict : raise SignatureExistError ( 'The keypair has already signed' ) else : sel...
Sign this transaction envelope with a given keypair .
229,291
def signature_base ( self ) : network_id = self . network_id tx_type = Xdr . StellarXDRPacker ( ) tx_type . pack_EnvelopeType ( Xdr . const . ENVELOPE_TYPE_TX ) tx_type = tx_type . get_buffer ( ) tx = Xdr . StellarXDRPacker ( ) tx . pack_Transaction ( self . tx . to_xdr_object ( ) ) tx = tx . get_buffer ( ) return netw...
Get the signature base of this transaction envelope .
229,292
def get_federation_service ( domain , allow_http = False ) : st = get_stellar_toml ( domain , allow_http ) if not st : return None return st . get ( 'FEDERATION_SERVER' )
Retrieve the FEDERATION_SERVER config from a domain s stellar . toml .
229,293
def get_auth_server ( domain , allow_http = False ) : st = get_stellar_toml ( domain , allow_http ) if not st : return None return st . get ( 'AUTH_SERVER' )
Retrieve the AUTH_SERVER config from a domain s stellar . toml .
229,294
def get_stellar_toml ( domain , allow_http = False ) : toml_link = '/.well-known/stellar.toml' if allow_http : protocol = 'http://' else : protocol = 'https://' url_list = [ '' , 'www.' , 'stellar.' ] url_list = [ protocol + url + domain + toml_link for url in url_list ] for url in url_list : r = requests . get ( url )...
Retrieve the stellar . toml file from a given domain .
229,295
def account_xdr_object ( self ) : return Xdr . types . PublicKey ( Xdr . const . KEY_TYPE_ED25519 , self . verifying_key . to_bytes ( ) )
Create PublicKey XDR object via public key bytes .
229,296
def xdr ( self ) : kp = Xdr . StellarXDRPacker ( ) kp . pack_PublicKey ( self . account_xdr_object ( ) ) return base64 . b64encode ( kp . get_buffer ( ) )
Generate base64 encoded XDR PublicKey object .
229,297
def verify ( self , data , signature ) : try : return self . verifying_key . verify ( signature , data ) except ed25519 . BadSignatureError : raise BadSignatureError ( "Signature verification failed." )
Verify the signature of a sequence of bytes .
229,298
def sign_decorated ( self , data ) : signature = self . sign ( data ) hint = self . signature_hint ( ) return Xdr . types . DecoratedSignature ( hint , signature )
Sign a bytes - like object and return the decorated signature .
229,299
def bytes_from_decode_data ( s ) : if isinstance ( s , ( str , unicode ) ) : try : return s . encode ( 'ascii' ) except UnicodeEncodeError : raise NotValidParamError ( 'String argument should contain only ASCII characters' ) if isinstance ( s , bytes_types ) : return s try : return memoryview ( s ) . tobytes ( ) except...
copy from base64 . _bytes_from_decode_data