#!/usr/bin/env python # ------------------------------------------------------------------------------ # # Disclaimer: # # DTN grants you an nonexclusive copyright license to use this code and you can # use it to prepare similar functions tailored to your own needs. # # The code is provided for illustrative purposes only and has not been tested under # all conditions. For that reason, DTN provides this code to you "AS IS" without # any warranties of any kind. # # ------------------------------------------------------------------------------ # # Retrieve a daily history report and present result in HTML table format. # # Imports import PXWeb # ------------------------------------------------------------------------------ # PXWeb access credentials USER = 'YOUR_USER' PSWD = 'YOUR_PASSWORD' # List of search patterns to send to PXWeb PATTERNS = ( '@C`##', '@W`##', 'QCL`##', 'QNG`##' ) # Max number of history entries to return for each symbol LIMIT = 10 # GetDailyHistory request string and CSV fields for response FIELDS = ( 'Date', 'Open', 'Close', 'High', 'Low', 'OI', 'Volume' ) # Name of output file OUT_FILE = 'result.html' # ------------------------------------------------------------------------------ # Start of HTML file HTML_HEAD = '''
Symbol | ' + ' | '.join( FIELDS ) + ' |
---|---|---|
{symbol} | ' ) for field in FIELDS: ofile.write( f'{dNode.attrib[ field ]} | ' ) ofile.write( '