Best Python code snippet using pandera_python
trading.py
Source:trading.py  
1# Copyright 2016 Intel Corporation2#3# Licensed under the Apache License, Version 2.0 (the "License");4# you may not use this file except in compliance with the License.5# You may obtain a copy of the License at6#7#     http://www.apache.org/licenses/LICENSE-2.08#9# Unless required by applicable law or agreed to in writing, software10# distributed under the License is distributed on an "AS IS" BASIS,11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12# See the License for the specific language governing permissions and13# limitations under the License.14# ------------------------------------------------------------------------------15import logging16from sawtooth.exceptions import InvalidTransactionError17from sawtooth_bond import bond_utils18from journal.transaction import Update19LOGGER = logging.getLogger(__name__)20class CreateQuoteUpdate(Update):21    def __init__(self, update_type, firm, bid_price, bid_qty, ask_price,22                 ask_qty, object_id=None, cusip=None, isin=None, nonce=None):23        super(CreateQuoteUpdate, self).__init__(update_type)24        self._firm = firm25        self._isin = isin26        self._cusip = cusip27        self._bid_price = bid_price28        self._bid_qty = bid_qty29        self._ask_price = ask_price30        self._ask_qty = ask_qty31        self._nonce = nonce32        if object_id is None:33            self._object_id = self.create_id()34        else:35            self._object_id = object_id36    def check_valid(self, store, txn):37        if self._object_id in store:38            raise InvalidTransactionError(39                "Object with id already exists: {}".format(self._object_id))40        try:41            firm = store.lookup('organization:pricing-source', self._firm)42        except KeyError:43            raise InvalidTransactionError(44                "No such pricing source: {}".format(self._firm))45        if self._isin is None and self._cusip is None:46            raise InvalidTransactionError(47                "Cusip or Isin must be set: {}".format(self._object_id))48        if self._isin is not None and self._cusip is None:49            try:50                store.lookup('bond:isin', self._isin)51            except KeyError:52                raise InvalidTransactionError(53                    "No such Bond: {}".format(self._firm))54        if self._isin is None and self._cusip is not None:55            try:56                store.lookup('bond:cusip', self._cusip)57            except KeyError:58                raise InvalidTransactionError(59                    "No such Bond: {}".format(self._cusip))60        if self._isin is not None and self._cusip is not None:61            try:62                cusip_id = store.lookup('bond:cusip', self._cusip)["object-id"]63                isin_id = store.lookup('bond:isin', self._isin)["object-id"]64            except KeyError:65                raise InvalidTransactionError(66                    "No such Bond: {}, {}".format(self._cusip, self._isin))67            if cusip_id != isin_id:68                raise InvalidTransactionError("Cusip {} and Isin {} do not "69                                              "belong to the same bond"70                                              .format(cusip_id, isin_id))71        try:72            submitter = store.lookup("participant:key-id", txn.OriginatorID)73        except KeyError:74            raise InvalidTransactionError("Only an authorized marketmaker can"75                                          " create a quote")76        if "authorization" not in firm:77            raise InvalidTransactionError("Only an authorized marketmaker can"78                                          " create a quote")79        participant = {"participant-id": submitter["object-id"],80                       "role": "marketmaker"}81        if participant not in firm["authorization"]:82            raise InvalidTransactionError("Only an authorized marketmaker can"83                                          " create a quote")84        try:85            bond_utils.bondprice_to_float(self._bid_price)86        except Exception:87            raise InvalidTransactionError("Bid price is not formatted "88                                          "correctly for "89                                          "quote {}".format(self._object_id))90        try:91            bond_utils.bondprice_to_float(self._ask_price)92        except Exception:93            raise InvalidTransactionError("Ask price is not formatted "94                                          "correctly for "95                                          "quote {}".format(self._object_id))96    def apply(self, store, txn):97        creator = store.lookup("participant:key-id", txn.OriginatorID)98        time = store.get("current_clock")["timestamp"]99        firm = store.lookup('organization:pricing-source', self._firm)100        obj = {101            'object-id': self._object_id,102            'object-type': 'quote',103            'creator-id': creator["object-id"],104            'firm': self._firm,105            'ref-count': 0,106            'bid-price': self._bid_price,107            'bid-qty': self._bid_qty,108            'ask-price': self._ask_price,109            'ask-qty': self._ask_qty,110            'timestamp': time,111            'status': 'Open'112        }113        if self._isin is not None:114            obj['isin'] = self._isin115            bond = store.lookup('bond:isin', self._isin)116        if self._cusip is not None:117            obj['cusip'] = self._cusip118            bond = store.lookup('bond:cusip', self._cusip)119        store[self._object_id] = obj120        firm["ref-count"] += 1121        store[firm["object-id"]] = firm122        bond["ref-count"] += 1123        store[bond["object-id"]] = bond124        if obj['status'] == 'Open':125            if 'open-quotes' in store:126                oq_obj = store['open-quotes']127                oq_obj['quote-list'].append(self._object_id)128            else:129                oq_obj = {130                    'object-id': 'open-quotes',131                    'object-type': 'open-quote-list',132                    'quote-list': [self._object_id]133                }134            store['open-quotes'] = oq_obj135class DeleteQuoteUpdate(Update):136    def __init__(self, update_type, object_id, nonce=None):137        super(DeleteQuoteUpdate, self).__init__(update_type)138        self._object_id = object_id139        self._nonce = nonce140    def check_valid(self, store, txn):141        if self._object_id not in store:142            raise InvalidTransactionError(143                "Object with id does not exist: {}".format(self._object_id))144        quote = store.get(self._object_id)145        try:146            participant = store.lookup('participant:key-id', txn.OriginatorID)147        except:148            raise InvalidTransactionError("Participant does not exist.")149        if participant["object-id"] != quote["creator-id"]:150            raise InvalidTransactionError(151                "A quote can only be deleted by its creator {}"152                .format(participant["object-id"]))153        if quote["ref-count"] != 0:154            raise InvalidTransactionError(155                "A quote can only be deleted if its ref-count is zero {}"156                .format(quote["ref-count"]))157    def apply(self, store, txn):158        # decrement refcount for bond and organization159        quote = store.get(self._object_id)160        organization = store.lookup("organization:pricing-source",161                                    quote["firm"])162        organization["ref-count"] -= 1163        store[organization["object-id"]] = organization164        if "isin" in quote:165            bond = store.lookup("bond:isin", quote["isin"])166        elif "cusip" in quote:167            bond = store.lookup("bond:cusip", quote["cusip"])168        bond["ref-count"] -= 1169        store[bond["object-id"]] = bond170        store.delete(self._object_id)171        if 'open-quotes' in store:172            oq_obj = store['open-quotes']173            if self._object_id in oq_obj['quote-list']:174                oq_obj['quote-list'].remove(self._object_id)175                store['open-quotes'] = oq_obj176class CreateOrderUpdate(Update):177    def __init__(self, update_type, action, quantity, order_type,178                 firm_id, quote_id=None, isin=None, cusip=None,179                 limit_price=None, limit_yield=None, object_id=None,180                 nonce=None):181        super(CreateOrderUpdate, self).__init__(update_type)182        self._isin = isin183        self._cusip = cusip184        self._action = action185        self._quantity = quantity186        self._limit_price = limit_price187        self._limit_yield = limit_yield188        self._order_type = order_type189        self._firm_id = firm_id190        self._quote_id = quote_id191        self._nonce = nonce192        if object_id is None:193            self._object_id = self.create_id()194        else:195            self._object_id = object_id196        # set in check_valid for use in apply197        self.__bond__ = None198        self.__organization__ = None199    def check_valid(self, store, txn):200        if self._object_id in store:201            raise InvalidTransactionError(202                "Object with id already exists: {}".format(self._object_id))203        if self._action not in ['Buy', 'Sell']:204            raise InvalidTransactionError(205                "Action must be either Buy or Sell"206            )207        for att in [self._action, self._object_id, self._order_type,208                    self._firm_id, self._quantity]:209            if att is None:210                raise InvalidTransactionError("Action, ObjectId, "211                                              "OrderType, FirmId, and "212                                              "Quantity are "213                                              "required.")214        if self._firm_id not in store:215            raise InvalidTransactionError("No organization with FirmId")216        try:217            store.get(self._firm_id, 'organization')218        except KeyError:219            raise InvalidTransactionError(220                "FirmId does not reference an organization")221        try:222            _ = store.lookup("participant:key-id", txn.OriginatorID)223        except KeyError:224            raise InvalidTransactionError("Only participants can create an "225                                          "order")226        if self._order_type == 'Limit':227            if self._limit_yield is None and self._limit_price is None:228                raise InvalidTransactionError("For Limit orders,"229                                              "either limit yield or "230                                              "limit price "231                                              "must be specified.")232        elif self._order_type == 'Market':233            if self._limit_price is not None or self._limit_yield is not None:234                raise InvalidTransactionError("Cannot set a market order with "235                                              "limit yield or limit price")236        else:237            raise InvalidTransactionError("OrderType must either be Market "238                                          "or Limit.")239        if self._limit_price is not None:240            try:241                bond_utils.bondprice_to_float(self._limit_price)242            except Exception:243                raise InvalidTransactionError("Limit price is not formatted "244                                              "correctly for order "245                                              "{}".format(self._object_id))246        if self._isin is not None:247            if self._cusip is not None:248                try:249                    bond_by_isin = store.lookup('bond:isin', self._isin)250                    bond_by_cusip = store.lookup('bond:cusip', self._cusip)251                    if bond_by_isin != bond_by_cusip:252                        raise InvalidTransactionError("Isin and Cusip "253                                                      "reference "254                                                      "different bonds.")255                    self.__bond__ = bond_by_isin256                except KeyError:257                    raise InvalidTransactionError("Missing bond with isin or "258                                                  "cusip")259            else:260                try:261                    self.__bond__ = store.lookup('bond:isin', self._isin)262                except KeyError:263                    raise InvalidTransactionError("Bond with that isin "264                                                  "doesn't exist.")265        else:266            if self._cusip is not None:267                try:268                    self.__bond__ = store.lookup('bond:cusip', self._cusip)269                except KeyError:270                    raise InvalidTransactionError("Bond with that cusip "271                                                  "doesn't exist.")272            else:273                raise InvalidTransactionError("At least one of isin or cusip "274                                              "is needed.")275        try:276            self.__organization__ = store.get(self._firm_id, 'organization')277        except KeyError:278            raise InvalidTransactionError("FirmId does not reference an "279                                          "organization.")280    def apply(self, store, txn):281        creator = store.lookup("participant:key-id", txn.OriginatorID)282        time = store.get("current_clock")["timestamp"]283        obj = {284            'object-id': self._object_id,285            'object-type': 'order',286            'action': self._action,287            'creator-id': creator['object-id'],288            'quantity': self._quantity,289            'order-type': self._order_type,290            'firm-id': self._firm_id,291            'ref-count': 0,292            'status': 'Open',293            'timestamp': time294        }295        if self._isin is not None:296            obj['isin'] = self._isin297        if self._cusip is not None:298            obj['cusip'] = self._cusip299        if self._limit_price is not None:300            obj['limit-price'] = self._limit_price301        if self._limit_yield is not None:302            obj['limit-yield'] = self._limit_yield303        if self._quote_id is not None:304            obj['quote-id'] = self._quote_id305            obj['status'] = 'Matched'306            obj["ref-count"] += 1307        self.__organization__['ref-count'] += 1308        store.set(self.__organization__['object-id'], self.__organization__)309        self.__bond__['ref-count'] += 1310        store.set(self.__bond__['object-id'], self.__bond__)311        store[self._object_id] = obj312        if obj['status'] == 'Open':313            if 'open-orders' in store:314                oo_obj = store['open-orders']315                oo_obj['order-list'].append(self._object_id)316            else:317                oo_obj = {318                    'object-id': 'open-orders',319                    'object-type': 'open-order-list',320                    'order-list': [self._object_id]321                }322            store['open-orders'] = oo_obj323class UpdateOrderUpdate(Update):324    def __init__(self, update_type, object_id, quote_id=None, status=None,325                 nonce=None):326        super(UpdateOrderUpdate, self).__init__(update_type)327        self._object_id = object_id328        self._quote_id = quote_id329        self._status = status330        self._nonce = nonce331    def check_valid(self, store, txn):332        if self._object_id not in store:333            raise InvalidTransactionError(334                "Order with object-id doesn't exist: {}".335                format(self._object_id))336        try:337            order_obj = store.get(self._object_id, 'order')338        except KeyError:339            raise InvalidTransactionError(340                "Object id doesn't refer to an order.")341        if self._quote_id is not None:342            if self._quote_id not in store:343                raise InvalidTransactionError(344                    "No quote with quote id: {}".format(self._quote_id))345            try:346                quote_obj = store.get(self._quote_id, 'quote')347            except KeyError:348                raise InvalidTransactionError(349                    "Quote id does not reference a quote")350            if quote_obj['status'] != 'Open':351                raise InvalidTransactionError(352                    "Referenced quote id: {} on order update for order: {} "353                    "has been closed".format(self._quote_id, self._object_id))354            try:355                if 'cusip' in quote_obj:356                    quote_bond = store.lookup('bond:cusip', quote_obj['cusip'])357                elif 'isin' in quote_obj:358                    quote_bond = store.lookup('bond:isin', quote_obj['isin'])359                if 'cusip' in order_obj:360                    order_bond = store.lookup('bond:cusip', order_obj['cusip'])361                elif 'isin' in order_obj:362                    order_bond = store.lookup('bond:isin', order_obj['isin'])363            except KeyError:364                raise InvalidTransactionError(365                    "Referenced order or quote bond does not appear "366                    "in store.")367            if quote_bond is None or order_bond is None:368                raise InvalidTransactionError(369                    "Could not lookup bond for both quote: {} and "370                    "order: {}".format(self._quote_id, self._object_id))371            if quote_bond['object-id'] != order_bond['object-id']:372                raise InvalidTransactionError(373                    "Referenced quote id: {} on order update for order: {} "374                    "does not match the bond on "375                    "the order".format(self._quote_id, self._object_id))376            if order_obj['action'] == 'Buy':377                if quote_obj['ask-qty'] < order_obj['quantity']:378                    raise InvalidTransactionError(379                        "Quote id: {} does not have sufficient quantity to "380                        "satisfy order: {}".format(self._quote_id,381                                                   self._object_id))382            elif order_obj['action'] == 'Sell':383                if quote_obj['bid-qty'] < order_obj['quantity']:384                    raise InvalidTransactionError(385                        "Quote id: {} does not have sufficient quantity to "386                        "satisfy order: {}".format(self._quote_id,387                                                   self._object_id))388        if (self._status is not None and389                self._status not in ['Open', 'Matched', 'Settled']):390            raise InvalidTransactionError(391                "Status must be either Open, Matched, or Settled."392            )393    def apply(self, store, txn):394        order_obj = store.get(self._object_id, 'order')395        if self._status is not None:396            if (order_obj['status'] == 'Open' and397                    self._status == "Matched"):398                oo_obj = store['open-orders']399                oo_obj['order-list'].remove(self._object_id)400                store['open-orders'] = oo_obj401            order_obj['status'] = self._status402        if self._quote_id is not None:403            order_obj['quote-id'] = self._quote_id404            quote_obj = store.get(self._quote_id, 'quote')405            if 'ref-count' not in quote_obj:406                quote_obj['ref-count'] = 1407            else:408                quote_obj['ref-count'] += 1409            if order_obj['action'] == 'Buy':410                quote_obj['ask-qty'] -= order_obj['quantity']411            elif order_obj['action'] == 'Sell':412                quote_obj['bid-qty'] -= order_obj['quantity']413            # If there is less than a round lot available in414            # either bid or ask quantity after a match, close415            # the quote.416            if (quote_obj['ask-qty'] < 100000 or417                    quote_obj['bid-qty'] < 100000):418                quote_obj['status'] = "Closed"419                oq_obj = store['open-quotes']420                oq_obj['quote-list'].remove(self._quote_id)421                store['open-quotes'] = oq_obj422            store[self._quote_id] = quote_obj423        store[self._object_id] = order_obj424class DeleteOrderUpdate(Update):425    def __init__(self, update_type, object_id, nonce=None):426        super(DeleteOrderUpdate, self).__init__(update_type)427        self._object_id = object_id428        self._nonce = nonce429    def check_valid(self, store, txn):430        if self._object_id not in store:431            raise InvalidTransactionError(432                "Object with id does not exist: {}".format(self._object_id))433        order = store.get(self._object_id)434        try:435            participant = store.lookup('participant:key-id',436                                       txn.OriginatorID)437        except:438            raise InvalidTransactionError("Participant does not exist.")439        if participant["object-id"] != order["creator-id"]:440            raise InvalidTransactionError(441                "An order can only be deleted by its creator {}"442                .format(participant["object-id"]))443        if order["ref-count"] != 0:444            raise InvalidTransactionError(445                "An order can only be deleted if its ref-count is zero {}"446                .format(order["ref-count"]))447    def apply(self, store, txn):448        order = store.get(self._object_id)449        organization = store.get(order["firm-id"])450        organization["ref-count"] -= 1451        store[organization["object-id"]] = organization452        if "isin" in order:453            bond = store.lookup("bond:isin", order["isin"])454        elif "cusip" in order:455            bond = store.lookup("bond:cusip", order["cusip"])456        bond["ref-count"] -= 1457        store[bond["object-id"]] = bond458        store.delete(self._object_id)459        if 'open-orders' in store:460            oo_obj = store['open-orders']461            if self._object_id in oo_obj['order-list']:462                oo_obj['order-list'].remove(self._object_id)...euronext.py
Source:euronext.py  
1#!/usr/bin/env python2# -*- coding: utf-8 -*-3import os4import sys5import bs46import re7import urllib.request8import json9import operator10import datetime11import time12from carnetOrdres import CarnetOrdres13from  histTransaction import HistTransaction14from pymongo import MongoClient15class CrawlerEuronext(CarnetOrdres, HistTransaction):16    def __init__(self):17        CarnetOrdres.__init__(self)18        HistTransaction.__init__(self)19        self.MONGOCLIENT= MongoClient('mongodb://localhost:27017/')20        self.DB= self.MONGOCLIENT["Volatility"]21    22    def crawlAllHist(self):23        collection= self.DB["actions_europeennes"].find({})24        compt=125        for obj in collection:26            _nom = str(obj["Nom"])27            _isin= str(obj["Isin"])28            _mic= str(obj["Mic"])29            print(str(compt)+"- Nom: "+_nom+" , ISIN: "+_isin+"-"+_mic)30            self.findDataHistEuronnext(_nom,_isin,_mic)31            time.sleep(5)32            compt+=133    def getAllAction(self):34        actions= self.DB["actions_europeennes"]35        self.EUROACTIONS= actions.find({},{"_id":0, "Capitaux":0})36    def genUrlHistEuronext(self,_isin, _mic):37        date_time = time.strftime("%d/%m/%Y")38        date_time+=" 02:00:00"39        pattern = "%d/%m/%Y %H:%M:%S"40        date_time="31/05/2017 02:00:00"41        today= int(time.mktime(time.strptime(date_time, pattern)))42        strtoday= str(today)+"000"43        44        url = "https://www.euronext.com/sites/www.euronext.com/modules/common/common_listings/custom/nyx_eu_listings/nyx_eu_listings_price_chart/pricechart/pricechart.php?q=intraday_data"45        url+="&from="+strtoday46        url+="&isin="+str(_isin)47        url+="&mic="+str(_mic)48        url+="&dateFormat=d/m/Y&locale=null"49        50        return url51    def verif_first_use(self, _id):52        collection=  self.DB["historiques_transactions"]53        if collection.find({"_id":_id}).count() > 0:54            return -155        else: 56            return 157    def findDataHistEuronnext(self,_nom,_isin,_mic):58        dictionnaire= {}59        historique={}60        ldic=[]61        now = datetime.datetime.now()62        dt_time= now.strftime("%Y-%m-%d %H:%M")63        #dt_time="31/05/2017 02:00:00"64        collection= self.DB["historiques_transactions"]65        idname=str(_nom+"_"+str(_isin)+"-"+str(_mic))66        url = self.genUrlHistEuronext(_isin,_mic)67        #print(url)68        self.setURLHISTTRANSACTION(url)69        self.crawlHistTransEuronext()70        #print("uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu")71        data = self.getDATAHISTTRANSACTION()72        if len(data) > 0:73            74            dt= data["data"]75            dt.sort(key=operator.itemgetter("tradeId"))76            77            for elem in dt:78                dic={}79                dic["TradeId"]=elem["tradeId"]80                dic["DateAndTime"]= elem["dateAndTime"]81                dic["TimeZone"]= elem["timeZone"]82                dic["Price"]= elem["price"]83                dic["NumberOfShares"]= elem["numberOfShares"]84                dic["TRADE_QUALIFIER"]= elem["TRADE_QUALIFIER"]85                ldic.append(dic)86            87            historique[str(dt_time)]=ldic88            first= self.verif_first_use(idname)89            90            if first == 1:91                dictionnaire["_id"]= idname92                dictionnaire["Nom"]=_nom93                dictionnaire["Isin"]=_isin94                dictionnaire["Mic"]=_mic95                dictionnaire["Historiques"]=historique96                #insertion dans la base de donnée97                document={}98                document[str(_nom+"_"+str(_isin)+"-"+str(_mic))]=dictionnaire99                collection.insert(dictionnaire)100            101            else:102                strhist=idname+".Historiques"103                document= collection.update({"_id":idname},\104                    {"$set":{"Historiques"+"."+str(dt_time):historique[str(dt_time)]}})105        else:106            print("Error de récupération sur Nom: "+_nom+" , ISIN: "+_isin+"-"+_mic)107            pass108# 22/05109url1="https://www.euronext.com/sites/www.euronext.com/modules/common/common_listings/custom/nyx_eu_listings/nyx_eu_listings_price_chart/pricechart/pricechart.php?q=intraday_data&from=1495411200000&isin=FR0011584549&mic=XPAR&dateFormat=d/m/Y&locale=null"110#precia 19/05111url2="https://www.euronext.com/sites/www.euronext.com/modules/common/common_listings/custom/nyx_eu_listings/nyx_eu_listings_price_chart/pricechart/pricechart.php?q=intraday_data&from=1495152000000&isin=FR0000060832&mic=XPAR&dateFormat=d/m/Y&locale=null"112#precia 18/05113url4="https://www.euronext.com/sites/www.euronext.com/modules/common/common_listings/custom/nyx_eu_listings/nyx_eu_listings_price_chart/pricechart/pricechart.php?q=intraday_data&from=1000&isin=FR0000060832&mic=XPAR&dateFormat=d/m/Y&locale=null"114crawl = CrawlerEuronext()...isin.py
Source:isin.py  
1"""2The ISIN class provides all the functionality required to work with ISIN3codes at a basic level.4Reference on the format of valid ISINs:5    https://www.isin.org/isin-format/6"""7from pyasx.helpers.luhn import Luhn8class ISIN(object):9    """10    Represents an ISIN code.11    An ISIN code is an International Securities Identification Number.12    It is used to identify a financial Security.13    The structure of an ISIN is made up of three components:14        1. An ISO 3166-1 alpha-2 two character code for the issuing country15        2. A nine-character alphanumeric security identifier16        3. A single check digit.17    Further Information:18        https://en.wikipedia.org/wiki/International_Securities_Identification_Number19    """20    def __init__(self, *, isin: str = None):21        """22        Args:23            isin (str): An ISIN code.24        Raises:25            ValueError: On ISIN inputs that are not 12 characters long.26        """27        self._isin: str = isin28        self._security_identifier: str = self._parse_security_identifier()29        self._country_code: str = self._parse_country()30        self._check_digit: str = self._parse_check_digit()31        isin_length = len(isin)32        if isin_length != 12:33            raise ValueError(f'ISIN codes must always be 12 characters, not {isin_length}')34    def __str__(self):35        return f'ISIN={self._isin}'36    def __repr__(self):37        # automatically get name to minimise refactor touch points38        return f'{self.__class__.__name__}(isin={self._isin})'39    @property40    def country_code(self) -> str:41        return self._country_code42    @property43    def check_digit(self) -> str:44        return self._check_digit45    @property46    def security_identifier(self) -> str:47        return self._security_identifier48    def _parse_country(self) -> str:49        """50        As per the ISIN format documentation listed in the module docstring,51        the 2-letter country code will always be found in the first two chars52        of the ISIN code.53        https://www.isin.org/country-codes/54        Returns:55            str: The 2-letter country code of the ISIN56        """57        country_code: str = self._isin[0:2]58        assert country_code.isalpha()59        return country_code60    def _parse_check_digit(self) -> str:61        """62        The check_digit is used for validation via the Luhn algorithm.63        https://en.wikipedia.org/wiki/Luhn_algorithm64        Returns:65            str: the check_digit66        """67        check_digit: str = self._isin[-1]68        assert check_digit.isnumeric()69        return check_digit70    def _parse_security_identifier(self) -> str:71        security_identifier: str = self._isin[2:11]72        assert security_identifier.isalnum()73        return security_identifier74    def validate(self) -> bool:75        """76        Execute the Luhn algorithm and verify the validity of the ISIN.77        Returns:78            bool: Whether the ISIN is a valid Luhn checksum or not.79        """80        luhn_checksum: str = Luhn.transpose_isin_to_luhn_checksum(isin=self._isin)81        luhn: Luhn = Luhn(checksum=luhn_checksum)...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
