def get_account_history_pager_elastic(account_id, page): account_id = _get_account_id(account_id) from_ = int(page) * 20 operations = es_wrapper.get_account_history( account_id=account_id, from_=from_, size=20, sort_by='-block_data.block_time') results = [] for op in operations: results.append({ "op": op["operation_history"]["op_object"], "op_type": op["operation_type"], "block_num": op["block_data"]["block_num"], "id": op["account_history"]["operation_id"], "op_in_trx": op["operation_history"]["op_in_trx"], "result": op["operation_history"]["operation_result"], "timestamp": op["block_data"]["block_time"], "trx_in_block": op["operation_history"]["trx_in_block"], "virtual_op": op["operation_history"]["virtual_op"] }) return results
def get_account_history(account_id, page, search_after): account_id = _get_account_id(account_id) from_ = page * 20 operations = es_wrapper.get_account_history( account_id=account_id, from_=from_, search_after=search_after, size=20, sort_by='-account_history.operation_id.keyword') results = [] for op in operations: results.append({ "op": op["operation_history"]["op_object"], "op_type": op["operation_type"], "block_num": op["block_data"]["block_num"], "id": op["account_history"]["operation_id"], "op_in_trx": op["operation_history"]["op_in_trx"], "result": json.loads(op["operation_history"]["operation_result"]), "timestamp": op["block_data"]["block_time"], "trx_in_block": op["operation_history"]["trx_in_block"], "virtual_op": op["operation_history"]["virtual_op"] }) return results
def get_trade_history2(base, quote, limit): baseID = bitshares_ws_client.request('database', 'lookup_asset_symbols', [[base], 0])[0] quoteID = bitshares_ws_client.request('database', 'lookup_asset_symbols', [[quote], 0])[0] now = str(datetime.datetime.now().isoformat()) results = bitshares_ws_client.request( 'database', 'get_trade_history', [quote, base, now, "2019-01-01T00:00:00", limit]) for result in results: operations = es_wrapper.get_account_history( account_id=result["side2_account_id"], operation_type=4, size=1000) amountNeedle = str(int(str(result["value"]).replace('.', ''))) quoteNeedle = str(int(str(result["amount"]).replace('.', ''))) is_maker = True for operation in operations: if 'operation_history' in operation: operationHistory = operation['operation_history'] if 'op' in operationHistory: items = json.loads(operationHistory['op']) for item in items: if type( item ) is not int and 'receives' in item and 'pays' in item: if str( item['receives'] ['amount']).find(amountNeedle) == 0 and str( item['pays']['amount'] ).find(quoteNeedle) == 0 and item['receives'][ 'asset_id'] == quoteID['id'] and item[ 'pays']['asset_id'] == baseID['id']: is_maker = item['is_maker'] if 'is_maker' in result: result.pop("is_maker") result["side1"] = get_account( result.pop("side1_account_id"))[0]["name"] result["side2"] = get_account( result.pop("side2_account_id"))[0]["name"] result["time"] = result.pop("date") result["marketPair"] = base + '_' + quote result["tradeID"] = result.pop("sequence") result["baseVolume"] = result.pop("value") result["quoteVolume"] = result.pop("amount") result["isBuyerMaker"] = is_maker == False #result["markets"] = get_markets(quote) return results