#!/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 via SOAP and save result in XML format. # # Imports import suds # ------------------------------------------------------------------------------ # PXWeb URL URL = 'https://pxweb.dtn.com/PXWebSvc/PXServiceDto.svc?wsdl' # PXWeb access credentials USER = 'YOUR_USER' PSWD = 'YOUR_PASSWORD' # List of search patterns to send to PXWeb PATTERNS = '@C`## 5,@W`## 5,QCL`## 5,QNG`## 5' # Max number of history entries to return for each symbol LIMIT = 10 # Name of output file OUT_FILE = 'result.xml' # ------------------------------------------------------------------------------ # Send a SOAP based request to PXWeb def send( operation, **kwds ): return operation( kwds ) # ------------------------------------------------------------------------------ # Get access to PXWeb pxweb = suds.client.Client( URL ) # Send the request to PXWeb service = pxweb.service result = send( service.GetDailyHistory, Password=PSWD, UserID=USER, Symbol=PATTERNS, Limit=LIMIT ) # Save result ofile = open( OUT_FILE, 'w' ) ofile.write( result ) ofile.close()