shared/share_data_item_loader.py
def load_moex_xml(self, date):
        '''
        Loads end-of-day data related to MOEX shares from the xml to database
        '''
        tree = ET.parse(self.path)
        root = tree.getroot()
        rows = root.findall('./data/rows/row')
        stocks_rus = Share.objects.filter(countryCode='RUS')
        ticker_to_stock_map = {}
        for stock in stocks_rus:
            ticker = stock.ticker
            if '.' in ticker:
                symbol, exchange = ticker.split('.')
                ticker_to_stock_map[symbol] = stock
        tqbr_rows = filter(lambda row: row.get('BOARDID') == 'TQBR', rows)
        for row in tqbr_rows:
            security_id = row.get('SECID')
            if security_id not in ticker_to_stock_map:
                continue
            else:
                open_value = row.get('OPEN')
                high_value = row.get('HIGH')
                low_value = row.get('LOW')
                close_value = row.get('CLOSE')
                volume_value = row.get('VOLUME')
                data_share_item = ShareDataItem(
                    share=ticker_to_stock_map[security_id],
                    date=date,
                    open_price=open_value,
                    high_price=high_value,
                    low_price=low_value,
                    close_price=close_value,
                    volume=volume_value
                )
                data_share_item.save()
                print(date, security_id, f'open = {open_value}, close = {close_value}')

        Loads end-of-day data related to MOEX shares from the xml to database
        
Loads end-of-day data related to MOEX shares from the xml to database
Loads end - of - day data related to MOEX shares from the xml to database
def load_moex_xml(self, date):
        tree = ET.parse(self.path)
        root = tree.getroot()
        rows = root.findall('./data/rows/row')
        stocks_rus = Share.objects.filter(countryCode='RUS')
        ticker_to_stock_map = {}
        for stock in stocks_rus:
            ticker = stock.ticker
            if '.' in ticker:
                symbol, exchange = ticker.split('.')
                ticker_to_stock_map[symbol] = stock
        tqbr_rows = filter(lambda row: row.get('BOARDID') == 'TQBR', rows)
        for row in tqbr_rows:
            security_id = row.get('SECID')
            if security_id not in ticker_to_stock_map:
                continue
            else:
                open_value = row.get('OPEN')
                high_value = row.get('HIGH')
                low_value = row.get('LOW')
                close_value = row.get('CLOSE')
                volume_value = row.get('VOLUME')
                data_share_item = ShareDataItem(
                    share=ticker_to_stock_map[security_id],
                    date=date,
                    open_price=open_value,
                    high_price=high_value,
                    low_price=low_value,
                    close_price=close_value,
                    volume=volume_value
                )
                data_share_item.save()
                print(date, security_id, f'open = {open_value}, close = {close_value}')
def load_moex_xml ( self , date ) : tree = ET . parse ( self . path ) root = tree . getroot ( ) rows = root . findall ( './data/rows/row' ) stocks_rus = Share . objects . filter ( countryCode = 'RUS' ) ticker_to_stock_map = { } for stock in stocks_rus : ticker = stock . ticker if '.' in ticker : symbol , exchange = ticker . split ( '.' ) ticker_to_stock_map [ symbol ] = stock tqbr_rows = filter ( lambda row : row . get ( 'BOARDID' ) == 'TQBR' , rows ) for row in tqbr_rows : security_id = row . get ( 'SECID' ) if security_id not in ticker_to_stock_map : continue else : open_value = row . get ( 'OPEN' ) high_value = row . get ( 'HIGH' ) low_value = row . get ( 'LOW' ) close_value = row . get ( 'CLOSE' ) volume_value = row . get ( 'VOLUME' ) data_share_item = ShareDataItem ( share = ticker_to_stock_map [ security_id ] , date = date , open_price = open_value , high_price = high_value , low_price = low_value , close_price = close_value , volume = volume_value ) data_share_item . save ( ) print ( date , security_id , f'open = {open_value}, close = {close_value}' )
Loads end-of-day data related to MOEX shares from the xml to database
Loads end - of - day data related to MOEX shares from the xml to database
'''
        Loads end-of-day data related to MOEX shares from the xml to database
        '''
self
date