示例#1
0
 def __init__(self, target_sec, cor_sec_list, end_date,
              data_period, correlation_period, shape_period,
              ic_pvalue = 0.05, adf_pvalue=0.05):
     self.shape_period = shape_period
     self.data_period = data_period
     self.correlation_period = correlation_period
     self.ic_pvalue = ic_pvalue
     self.adf_pvalue = adf_pvalue
     begin_date = end_date - datetime.timedelta(days=data_period)
     self.target_sec = security.Security(target_sec, begin_date, end_date)
     self.cor_sec_list = []
     for sec in cor_sec_list:
         self.cor_sec_list.append(security.Security(sec, begin_date, end_date))
示例#2
0
 def __init__(self, concern_sec_list, end_date, data_period, shape_period):
     self.shape_period = shape_period
     self.data_period = data_period
     begin_date = end_date - datetime.timedelta(days=data_period)
     self.concern_sec_list = []
     for code in concern_sec_list:
         self.concern_sec_list.append(security.Security(code[0], code[1], begin_date, end_date))
    def read_results_file_s3(self, filename):
        """
        Read in contents from a results file. Create a security for each record.
        add to a list, sort it and then return it.
        """
        secList = []
        if self.bucketExists:
            try:
                client = boto3.client('s3')
                for line in client.get_object(Bucket=self.bucketName,
                                              Key=filename)["Body"].iter_lines():
                    strLine = str(line)
                    thisSec = security.Security()
                    thisSec.read(strLine)
                    secList.append(thisSec)

                secList.sort(key=lambda x: x.get_sort_string())

            except (FileNotFoundError, PermissionError) as E:
                print("Exception when trying to read file: ", filename)
                print(E)
            except NoCredentialsError:
                print("Credentials not available.")
        else:
            print("Unable to find file: ", filename)

        return secList
def retrieve_prices(symbolList, priceProvider, mysettings, myResultsFile):
    """
    Retrieve price for each symbol in list, using given function, save in a file.
    Returns name of file created.
    """

    if priceProvider == PriceProvider.alphavest:
        retrieveFn = _get_price_alphavest
    elif priceProvider == PriceProvider.yahoo:
        retrieveFn = _get_price_yahoo
    else:
        print("Unrecognized price provider: ", priceProvider,
              ", using AlphaVest.")
        retrieveFn = _get_price_alphavest

    # Loop through all securities in list, getting and checking current price.
    securities = []
    for symbol in symbolList:
        print(symbol.Stock)
        priceInfo = retrieveFn(symbol.Symbol, mysettings)
        mySecurity = security.Security()
        mySecurity.pop_from_row(symbol, priceInfo)
        if priceInfo.currentPrice > 0:
            actionMsg = _get_action_msg(symbol, priceInfo.currentPrice)
            _display_msg(symbol, priceInfo.currentPrice, actionMsg)
            # Don't write to file if no price, as resulting bar makes it look like should buy.
            securities.append(mySecurity)

    # Save list to file/s3.
    # resFile = myResultsFile.write_results_file(securities, datetime.datetime.now())
    resFile = myResultsFile.write_results_s3(securities,
                                             datetime.datetime.now())

    return resFile
示例#5
0
    def reset(self):
        # Reset everything except:
        #
        #	- The mouse
        #	- The install language
        #	- The keyboard

        self.langSupport = language.Language()
        self.instClass = None
        self.network = network.Network()
        self.firewall = firewall.Firewall()
        self.security = security.Security()
        self.timezone = timezone.Timezone()
        self.accounts = users.Accounts()
        self.rootPassword = users.RootPassword()
        self.auth = users.Authentication()
        self.desktop = desktop.Desktop()
        self.grpset = None
        self.upgrade = Boolean()
        # XXX move fsset and/or diskset into Partitions object?
        self.fsset.reset()
        self.diskset = partedUtils.DiskSet()
        self.partitions = partitions.Partitions()
        self.bootloader = bootloader.getBootloader()
        self.dependencies = []
        self.handleDeps = CHECK_DEPS
        self.dbpath = None
        self.upgradeRoot = None
        self.rootParts = None
        self.upgradeSwapInfo = None
        self.upgradeDeps = ""
        self.upgradeRemove = []
        self.upgradeInfoFound = None
        self.configFileData = self.tmpData
        self.firstboot = FIRSTBOOT_DEFAULT
示例#6
0
    def reset(self):
        # Reset everything except:
        #
        # - The install language
        # - The keyboard

        self.instClass = None
        self.network = network.Network()
        self.firewall = firewall.Firewall()
        self.security = security.Security()
        self.timezone = timezone.Timezone()
        self.timezone.setTimezoneInfo(
            self.instLanguage.getDefaultTimeZone(self.anaconda.rootPath))
        self.users = None
        self.rootPassword = {"isCrypted": False, "password": "", "lock": False}
        self.auth = "--enableshadow --passalgo=sha512"
        self.desktop = desktop.Desktop()
        self.upgrade = None
        if flags.cmdline.has_key("preupgrade"):
            self.upgrade = True
        self.storage = storage.Storage(self.anaconda)
        self.bootloader = booty.getBootloader(self)
        self.upgradeRoot = None
        self.rootParts = None
        self.upgradeSwapInfo = None
        self.escrowCertificates = {}

        if self.anaconda.isKickstart:
            self.firstboot = FIRSTBOOT_SKIP
        else:
            self.firstboot = FIRSTBOOT_DEFAULT

        # XXX I still expect this to die when kickstart is the data store.
        self.ksdata = None
示例#7
0
def main_function(dealer_tag, delivery_add_tag, order_part_number,
                  order_quantity):

    sec = security.Security(dealer_tag[0], dealer_tag[1])
    part_manage = part_manager.Part_Manager(order_part_number, order_quantity)

    delivery_details = part_manager.DeliveryAddress(delivery_add_tag[0],
                                                    delivery_add_tag[1],
                                                    delivery_add_tag[2],
                                                    delivery_add_tag[3],
                                                    delivery_add_tag[4])
    dealer_validate = sec.validate_dealer()

    # validating dealer id and access key field
    if len(dealer_validate) < 25:
        parts_validation = part_manage.validate_parts()

        # validating part number and quantity field
        if len(parts_validation) < 40:
            delivery_details_validation = delivery_details.validate_delivery()

            # validating delivery details fields such as name, address, city, province, postal code
            if len(delivery_details_validation) < 30:
                dealer_auth = sec.isDealerAuthorized()

                # Dealer authentication with provided dealer id and access key
                if len(dealer_auth) < 21:
                    part_check = part_manage.SubmitPartForManufactureAndDelivery(
                    )

                    if len(part_check) < 8:
                        # writing successful XML response
                        authorized_response_XML(part_check)
                        msg = "Dealer is authorized, check the response in output.xml"
                        print msg

                else:
                    # writing Fault XML Response: Dealer is not authorized
                    not_authorized_XML()
                    msg = "Dealer is not authorized"

            else:
                # writing Fault XML response: Delivery details
                invalid_response_XML(delivery_details_validation)
                msg = delivery_details_validation

        else:
            # writing Fault XML response: Part number and quantity
            invalid_response_XML(parts_validation)
            msg = parts_validation

    else:
        # writing Fault XML Response: Dealer ID or Access key
        invalid_response_XML(dealer_validate)
        msg = dealer_validate

    return msg
示例#8
0
 def createSecurity(self, name, symbol, buyPrice, sellPrice, currentPrice,
                    lastClosePrice, high52Week):
     mySec = security.Security()
     priceInfo = security.PriceInfo()
     priceInfo.currentPrice = currentPrice
     priceInfo.lastClosePrice = lastClosePrice
     priceInfo.high52Week = high52Week
     mySec.pop_with_priceInfo(name, symbol, buyPrice, sellPrice, priceInfo)
     return mySec
 def __init__(self,
              target_sec,
              end_date,
              period_list=[10, 30, 360],
              show=True):
     self.show = show
     self.period_list = period_list
     begin_date = end_date - datetime.timedelta(days=max(self.period_list))
     self.target_sec = security.Security(target_sec[0], target_sec[1],
                                         begin_date, end_date)
示例#10
0
def start_httpd(broker, client):
    securityObject = security.Security()
    cherrypy.tools.CORS = cherrypy.Tool('before_handler', CORS)
    cherrypy.tree.mount(CommandsApi(broker, securityObject), '/commands', conf)
    server = Server()
    server.socket_port = config.HTTPD_PUBLIC_PORT
    server.socket_host = '0.0.0.0'
    server.subscribe()
    cherrypy.config.update({'server.socket_host': '0.0.0.0'})
    cherrypy.tree.mount(ClientsApi(securityObject), '/clients', conf)
    cherrypy.engine.start()
    cherrypy.engine.block()
示例#11
0
    def __init__(self,
                 target_sec,
                 cor_sec_list,
                 end_date,
                 data_period,
                 correlation_period,
                 shape_period,
                 adf_pvalue=0.05):
        self.ic_pvalue = 0.05
        self.ic_value = 0.4  #0.8强相关,0.5-0.8显著相关, 0.3-0.5弱相关, 0.3不相关
        self.adf_pvalue = adf_pvalue

        self.shape_period = shape_period
        self.data_period = data_period
        self.correlation_period = correlation_period
        begin_date = end_date - datetime.timedelta(days=data_period)
        self.target_sec = security.Security(target_sec, 'gold', begin_date,
                                            end_date)
        self.cor_sec_list = []
        for sec in cor_sec_list:
            sec_ins = security.Security(sec, '', begin_date, end_date)
            self.cor_sec_list.append(sec_ins)
示例#12
0
    def __init__(self):
        import desktop, dispatch, firewall, security
        import system_config_keyboard.keyboard as keyboard
        from flags import flags

        self._backend = None
        self._bootloader = None
        self.canReIPL = False
        self.desktop = desktop.Desktop()
        self.dir = None
        self.dispatch = dispatch.Dispatcher(self)
        self.displayMode = None
        self.extraModules = []
        self.firewall = firewall.Firewall()
        self.id = None
        self._instClass = None
        self._instLanguage = None
        self._intf = None
        self.isHeadless = False
        self.keyboard = keyboard.Keyboard()
        self.ksdata = None
        self.mediaDevice = None
        self.methodstr = None
        self._network = None
        self.opts = None
        self._platform = None
        self.proxy = None
        self.proxyUsername = None
        self.proxyPassword = None
        self.reIPLMessage = None
        self.rescue = False
        self.rescue_mount = True
        self.rootParts = None
        self.rootPath = "/mnt/sysimage"
        self.security = security.Security()
        self.simpleFilter = not iutil.isS390()
        self.stage2 = None
        self._storage = None
        self._timezone = None
        self.updateSrc = None
        self.upgrade = flags.cmdline.has_key("preupgrade")
        self.upgradeRoot = None
        self.upgradeSwapInfo = None
        self._users = None
        self.mehConfig = None
        self.clearPartTypeSelection = None      # User's GUI selection
        self.clearPartTypeSystem = None         # System's selection

        # *sigh* we still need to be able to write this out
        self.xdriver = None
示例#13
0
def display():
    url = bottle.request.forms.get('wesbiteURL')
    print(url, "thanku !")

    responseTimeObject = response_time.ResponseTime()
    responses = responseTimeObject.return_response_time_list(url)

    contentObject = content.Distribution(url)
    distribution_array = contentObject.give_content_distribution()

    securityObject = security.Security()
    security_params = securityObject.hasSecurityFeatures(url)

    return bottle.template('display', responseTime = responses, \
      content = distribution_array, security = security_params)
示例#14
0
 def __init__(self,
              target_sec,
              end_date,
              period,
              change_percent=0.01,
              regime_percent=0.05,
              regime_tp_num=4,
              show=True):
     self.show = show
     self.period = period
     self.change_percent = change_percent
     self.regime_percent = regime_percent
     self.regime_tp_num = regime_tp_num
     begin_date = end_date - datetime.timedelta(days=self.period)
     self.target_sec = security.Security(target_sec[0], target_sec[1],
                                         begin_date, end_date)
示例#15
0
    def reset(self):
        # Reset everything except:
        #
        #	- The mouse
        #	- The install language
        #	- The keyboard

        self.instClass = None
        self.network = network.Network()
        self.iscsi = iscsi.iscsi()
        self.zfcp = zfcp.ZFCP()
        self.firewall = firewall.Firewall()
        self.security = security.Security()
        self.timezone = timezone.Timezone()
        self.users = None
        self.rootPassword = {"isCrypted": False, "password": ""}
        self.auth = "--enableshadow --enablemd5"
        self.desktop = desktop.Desktop()
        self.upgrade = None
        # XXX move fsset and/or diskset into Partitions object?
        self.fsset.reset()
        self.diskset = partedUtils.DiskSet(self.anaconda)
        self.partitions = partitions.Partitions()
        self.bootloader = bootloader.getBootloader()
        self.dependencies = []
        self.dbpath = None
        self.upgradeRoot = None
        self.rootParts = None
        self.upgradeSwapInfo = None
        self.upgradeDeps = ""
        self.upgradeRemove = []
        self.upgradeInfoFound = None

        if rhpl.getArch() == "s390":
            self.firstboot = FIRSTBOOT_SKIP
        else:
            self.firstboot = FIRSTBOOT_DEFAULT

    # XXX I expect this to die in the future when we have a single data
    # class and translate ksdata into that instead.
        self.ksdata = None
示例#16
0
    def read_results_file(self, filename):
        """
        Read in contents from a results file. Create a security for each record.
        add to a list, sort it and then return it.
        """
        secList = []
        if os.path.isfile(filename):
            try:
                with open(filename, 'r') as f:
                    for line in f:
                        thisSec = security.Security()
                        thisSec.read(line)
                        secList.append(thisSec)

                    secList.sort(key=lambda x: x.get_sort_string())

            except (FileNotFoundError, PermissionError) as E:
                print("Exception when trying to read file: ", filename)
                print(E)
        else:
            print("Unable to find file: ", filename)

        return secList
示例#17
0
    def setUp(self):
        self.security1 = security.Security("XXX-1234-ABCD-1234", None)
        self.security2 = security.Security(None, "kkklas8882kk23nllfjj88290")
        self.security3 = security.Security("XXX-1234-ABCD-1234",
                                           "kkklas8882kk23nllfjj88290")

        self.part_check1 = part_manager.Part_Manager("1233", "2")
        self.part_check2 = part_manager.Part_Manager(None, "5")
        self.part_check3 = part_manager.Part_Manager("2222", None)

        self.delivery1 = part_manager.DeliveryAddress("Mr. Jadeja",
                                                      "South Park St",
                                                      "Halifax", "NS",
                                                      "B3J2K9")
        self.delivery2 = part_manager.DeliveryAddress(None, "South Park St",
                                                      "Halifax", "NS",
                                                      "B3J2K9")
        self.delivery3 = part_manager.DeliveryAddress("Mr. Jadeja", None,
                                                      "Halifax", "NS",
                                                      "B3J2K9")
        self.delivery4 = part_manager.DeliveryAddress("Mr. Jadeja",
                                                      "South Park St", None,
                                                      "NS", "B3J2K9")
        self.delivery5 = part_manager.DeliveryAddress("Mr. Jadeja",
                                                      "South Park St",
                                                      "Halifax", None,
                                                      "B3J2K9")
        self.delivery6 = part_manager.DeliveryAddress("Mr. Jadeja",
                                                      "South Park St",
                                                      "Halifax", "NS", None)

        self.auth1 = security.Security("FAKEDEALER", "FAKEACCEESKEY")
        self.auth2 = security.Security("XXX-1111-ABCD-1111",
                                       "abcd123wxyz456qwerty78901")
        self.auth3 = security.Security("XXX-2222-ABCD-2222",
                                       "kkklas8882kk23nllfjj88292")

        self.part_status1 = part_manager.Part_Manager(
            ["1234", "1111", "2222", "3333", "4444", "fake_part_number"],
            ["1", "2", "3", "4", "5", "6"])
 def createSecurity(self, name, symbol, buyPrice, sellPrice, currentPrice):
     mySec = security.Security()
     mySec.pop(name, symbol, buyPrice, sellPrice, currentPrice)
     return mySec
 def toRecord(self):
     date = dt.combine(dt.strptime(self.date,self.__class__._datefmt).date(),
             dt.strptime(self.time,self.__class__._timefmt).time())
     BS = self.__class__._bs_state.get(self.BS, self.BS)
     code = security.Security(self.code, self.get_market(), self.name)
     return TradeRecord(code, date, BS, float(self.price), int(self.volume))
示例#20
0
import pytest
import security
from io import StringIO
s = security.Security()

#Caesar Encryptor Tests
@pytest.mark.set1
def test1_caesarEncryptor(monkeypatch):
    userInput = StringIO('3\n')
    monkeypatch.setattr('sys.stdin', userInput)
    assert isinstance(s.CaesarEncryptor("abc"), str) 

@pytest.mark.set1
def test2_caesarEncryptor(monkeypatch):
    userInput = StringIO('3\n')
    monkeypatch.setattr('sys.stdin', userInput)
    assert s.CaesarEncryptor("abc") != "abc"

#Caesar Decryptor Tests
@pytest.mark.set2
def test1_caesarDecryptor(monkeypatch):
    userInput = StringIO('3\n')
    monkeypatch.setattr('sys.stdin', userInput)
    assert isinstance(s.CaesarDecryptor("abc"), str) 

@pytest.mark.set2
def test2_caesarDecryptor(monkeypatch):
    userInput = StringIO('3\n')
    monkeypatch.setattr('sys.stdin', userInput)
    assert s.CaesarDecryptor("abc") != "abc"
示例#21
0
Log = com.LOG

import asyncio, discord

CLIENT = discord.Client()


def echo(*arg):
    print(*arg)
    sys.stdout.flush()


import security

Security = security.Security(CLIENT)

import DiscordCommandLineGenerator

CommandLine = DiscordCommandLineGenerator.CommandLine(CLIENT, Security)

CONFIGURATION = {
    "LogChannelID": 694996836536025249,
    "ConsoleChannelID": 694996263241777233
}

CONFIGURATION['LogChannel'] = CLIENT.get_channel(694996836536025249)
CONFIGURATION['ConsoleChannel'] = CLIENT.get_channel(694996263241777233)


# /----------------------
示例#22
0
def create_db():
	with con:
		cur.execute("INSERT INTO USERS VALUES (?, ?, ?, ?, ?, ?);", (Id, name, 0, 0, 0, 0))
		con.commit()
		nameID = name+str(Id)
		cur.execute("INSERT INTO USERSPASS VALUES (?, ?, ?);", (nameID, passHash, Id))
		con.commit()

Id=raw_input('Enter your id: ')
name=raw_input('Enter your name: ')
passwordCreation = False
while passwordCreation == False:
	password=raw_input("Enter password: "******"Confirm password: "******"Try again")
		
sampleNum=0
while True:
	ret, img = cam.read()
	gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
	faces = detector.detectMultiScale(gray, 1.3, 5)
	for (x,y,w,h) in faces:
		cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2)
		#incrementing sample number 
		sampleNum=sampleNum+1
		#saving the captured face in the dataset folder