def __init__(self, bidPrice=60, offerPrice=None, businessDate=None, partitions=None, gwHost=None, gwPort=None, ofiHost=None, ofiPort=None): refdata = ReferenceData(dbhost=options.dbhost, dbport=options.dbport) self.refdata = refdata self.units = refdata.fetchUnitsUsers() self.products = refdata.fetchProductsInstruments(partitions=partitions, closingPositionOnly=False) self.securities = refdata.fetchSecurities() self.pmmunits = refdata.fetchPMMUnitsProducts() self.pmmusers = refdata.fetchPMMUserNameProducts() self.houseunits = refdata.fetchHouseUnitsUsers() self.mopsuser = refdata.fetchMOPSUserName() self.priceSteps = refdata.fetchPriceSteps() self.businessDate = businessDate self.cachedPrices = {} for key, value in refdata.fetchPriceStepTables().iteritems(): if offerPrice == None: self.cachedPrices[key] = Product.generateRandomUpAndDownPrices(60, 60, 100, 1, 0, 0, value, size=1) else: self.cachedPrices[key] = [(bidPrice, offerPrice)*2] self.attempted = 0 self.successful = 0 self.unsuccessful = [] self.gwHost = gwHost self.gwPort = gwPort self.ofiHost = ofiHost self.ofiPort = ofiPort self.passwords = {} if options.passwords: f = open(options.passwords, "r") for line in f.readlines(): line = line.rstrip("\r\n") loginName, password = line.split(",") self.passwords[loginName] = password f.close()
def __init__(self, bidPrice=60, offerPrice=None, businessDate=None, partitions=None, gwHost=None, gwPort=None, ofiHost=None, ofiPort=None): refdata = ReferenceData(dbhost=options.dbhost, dbport=options.dbport) self.refdata = refdata self.units = refdata.fetchUnitsUsers() self.products = refdata.fetchProductsInstruments( partitions=partitions, closingPositionOnly=False) self.securities = refdata.fetchSecurities() self.pmmunits = refdata.fetchPMMUnitsProducts() self.pmmusers = refdata.fetchPMMUserNameProducts() self.houseunits = refdata.fetchHouseUnitsUsers() self.mopsuser = refdata.fetchMOPSUserName() self.priceSteps = refdata.fetchPriceSteps() self.businessDate = businessDate self.cachedPrices = {} for key, value in refdata.fetchPriceStepTables().iteritems(): if offerPrice == None: self.cachedPrices[key] = Product.generateRandomUpAndDownPrices( 60, 60, 100, 1, 0, 0, value, size=1) else: self.cachedPrices[key] = [(bidPrice, offerPrice) * 2] self.attempted = 0 self.successful = 0 self.unsuccessful = [] self.gwHost = gwHost self.gwPort = gwPort self.ofiHost = ofiHost self.ofiPort = ofiPort self.passwords = {} if options.passwords: f = open(options.passwords, "r") for line in f.readlines(): line = line.rstrip("\r\n") loginName, password = line.split(",") self.passwords[loginName] = password f.close()
parser.add_option("--dbhost", dest="dbhost", default="127.0.0.1", help="Reference data database host") parser.add_option("--dbport", dest="dbport", type="int", default=basePort, help="Reference data database port") parser.add_option("--gwhost", dest="gwhost", default="127.0.0.1", help="Gateway host") parser.add_option("--gwport", dest="gwport", type="int", default=basePort + 6, help="Gateway port") parser.add_option("--ofihost", dest="ofihost", default="127.0.0.1", help="OutboundFeedInterface host") parser.add_option("--ofiport", dest="ofiport", type="int", default=basePort + 5, help="OutboundFeedInterface port") parser.add_option("--bbo-offer-price", dest="offerPrice", type="int", default=None, help="Best offer price") parser.add_option("--bbo-bid-price", dest="bidPrice", type="int", default=60, help="Best bid price") parser.add_option("--business-date", dest="businessDate", type="str", default=None, help="Set current business date (dd-mm-yyyy)") parser.add_option("--show-business-dates", dest="showBusinessDates", action="store_true", default=False, help="Show business dates in the database") parser.add_option("--passwords", dest="passwords", help="Passwords file for GW and OFI", default = None) parser.add_option("--conngateway", dest="conngateway", action="store_true", help="Use this flag when using a connection gateway", default = False) (options, args) = parser.parse_args() if options.showBusinessDates: refdata = ReferenceData(dbhost=options.dbhost, dbport=options.dbport) refdata.showBusinessDates() sys.exit(0) if options.partition: options.partition = [options.partition] startOfDay = StartOfDay(bidPrice=options.bidPrice, offerPrice=options.offerPrice, businessDate=options.businessDate, partitions=options.partition, gwHost=options.gwhost, gwPort=options.gwport, ofiHost=options.ofihost, ofiPort=options.ofiport) startOfDay.run() startOfDay.printResults() if startOfDay.successful > 0: sys.exit(0) else: sys.exit(1)
default=False, help="Show business dates in the database") parser.add_option("--passwords", dest="passwords", help="Passwords file for GW and OFI", default=None) parser.add_option("--conngateway", dest="conngateway", action="store_true", help="Use this flag when using a connection gateway", default=False) (options, args) = parser.parse_args() if options.showBusinessDates: refdata = ReferenceData(dbhost=options.dbhost, dbport=options.dbport) refdata.showBusinessDates() sys.exit(0) if options.partition: options.partition = [options.partition] startOfDay = StartOfDay(bidPrice=options.bidPrice, offerPrice=options.offerPrice, businessDate=options.businessDate, partitions=options.partition, gwHost=options.gwhost, gwPort=options.gwport, ofiHost=options.ofihost, ofiPort=options.ofiport) startOfDay.run()