def input_without_N(lst):
    x = lst
    v = Validation()
    y = LinkedList()
    first_iter = True
    while x.length() != y.length():
        if not first_iter:
            print("Both length must be equal!")
        print("Input Y(double ENTER to stop): ")
        while True:  # while user will not input "ENTER", he enters a list
            i = input()
            if i == "":
                break
            if not v.positive_check(i):
                print(i, "was skipped because it's not a number!")
            else:
                dot = False
                for z in i:
                    if z == ".":
                        dot = True
                        break
                if dot:
                    y.append(float(i))
                else:
                    y.append(int(i))
        first_iter = False
    result = create_z(
        x, y,
        x.length())  #call a function to create list "z" according to task
    return result
Exemple #2
0
 def init(self):
     self.__linkDict = dict()
     self.__sentenceDict = dict()
     self.__keywordDict = dict()
     self.__distanceDict = dict()
     self.__validation = Validation.Validation()
     self.__validation.init_dic()
     self.__validation.init_base_normalized()
     self.__sentenceTokenizer = TextRank.SentenceTokenizer()
Exemple #3
0
 def insert(lst, filename, index):
     file = open(filename)
     temp = file.read().split("\n")
     file.close()
     if temp[0] == "":
         print("FILE is empty!")
         return
     correct = []
     for i in temp:
         if not Validation().positive_check(i):
             print(i, "was skipped because it's not a number!")
         else:
             dot = False
             for z in i:
                 if z == ".":
                     dot = True
                     break
             if dot: correct.append(float(i))
             else: correct.append(int(i))
     for i in correct:
         lst.insert(index, i)
         index += 1
def input_with_N(lst):
    x = lst
    v = Validation()
    y = LinkedList()
    N = x.length()
    start = input("START:")
    while not v.positive_check(start):
        start = input("Start must be a number: ")
    invalid = True
    while invalid:
        for z in start:
            invalid = False
            if z == ".":
                invalid = True
                start = input("Start must be an integer:")
                while not v.positive_check(start):
                    start = input("Start must be a number: ")
                break
    start = int(start)
    end = input("END:")
    while not v.positive_check(end):
        end = input("End must be a number: ")
    invalid = True
    while invalid:
        for z in end:
            invalid = False
            if z == ".":
                invalid = True
                end = input("End must be an integer:")
                while not v.positive_check(end):
                    end = input("End must be a number: ")
                break
    end = int(end)
    for j in range(N):  #generate nums for "y"
        y.append(random.randint(start, end))
    result = create_z(x, y, N)
    return result
Exemple #5
0
 def __init__(self, dockarea):
     self.obj_validation = Validation.Validation()
     self.obj_appconfig = Appconfig()
     self.obj_dockarea = dockarea
Exemple #6
0
def menu():
    contex = Contex()
    List = LinkedList()
    v = Validation()
    while True:
        choice = input(
            "1 - Use strategy 1 to insert into the list\n2 - Use strategy 2 to insert into the list\n3 - Generate data\n4 - Delete the item at the specified position\n5 - Delete multiple items within the start and end positions\n6 - Method for working with the list\n7 - Display a list\n8 - Exit\nYour choice is: "
        )
        while not v.digit_check(choice):
            choice = input("Choise must be a positive number: ")
        choice = int(choice)
        while not (choice == 1 or choice == 2 or choice == 3 or choice == 4 or
                   choice == 5 or choice == 6 or choice == 7 or choice == 8):
            choice = input("Choise must be in range[1-8]: ")
            while not v.digit_check(choice):
                choice = input("Choise must be a number: ")
            choice = int(choice)
        if choice == 1:
            contex.setStrategy(ConcreteStrategyIterator())
        if choice == 2:
            contex.setStrategy(ConcreteStrategyFile())
        if choice == 3:
            if contex.getStrategy() is None:
                print("Choose a strategy first!")
                continue
            contex.execudeStrategy(List)
            List.display()
        if choice == 4:
            if List.length() == 0:
                print("Your list is empty!")
                continue
            index = input("Index: ")
            while not v.digit_check(index):
                index = input("Index must be a positive number: ")
            index = int(index)
            while index > List.length() or index < 0:
                index = input("Index must be in list range: ")
                while not v.digit_check(index):
                    index = input("Index must be a positive number: ")
                index = int(index)
            List.erase(index)
        if choice == 5:
            if List.length() == 0:
                print("Your list is empty!")
                continue
            start = 1
            end = 0
            first_iter = True
            while start > end or first_iter:
                if not first_iter:
                    print("MAKE SURE, START <= END")
                start = input("START:")
                while not v.digit_check(start):
                    start = input("Start must be a positive number: ")
                start = int(start)
                while start > List.length() or start < 0:
                    index = input("Start must be in list range: ")
                    while not v.digit_check(index):
                        index = input("Start must be a positive number: ")
                    start = int(start)
                end = input("END:")
                while not v.digit_check(end):
                    end = input("End must be a positive number: ")
                end = int(end)
                while end > List.length() or end < 0:
                    end = input("End must be in list range: ")
                    while not v.digit_check(end):
                        end = input("End must be a positive number: ")
                    end = int(end)
                first_iter = False
            List.cut(start, end)
        if choice == 6:
            if List.length() == 0:
                print("Your list is empty!")
                continue
            user_choice(List)
        if choice == 7:
            List.display()
        if choice == 8:
            break
Exemple #7
0
     '\n',
 )
 oper = input('Enter from 0 to 9: ')
 menu = ''
 if oper == '0':
     menu = oper
 while (menu != 'menu') & (menu != '0'):
     if oper == '1':
         idd = ForeignID()
         for i in range(len(dictio)):
             pre = dictio[i] + ': '
             idd.set(dictio[i], input(pre))
         cl.add_to_collec(idd)
         print(cl)
     elif oper == '2':
         file = Validation().file_existing("Text.txt", "r")
         cl.add_from_file(file)
         file.close()
         print(cl)
     elif oper == '3':
         file = Validation().file_existing("Text.txt", "w")
         cl.add_to_file(file)
         file.close()
     elif oper == '4':
         iDn = input('Введіть ідентифікатор по якому треба видалити: ')
         cl.delete_from_collec(iDn)
         print(cl)
     elif oper == '5':
         iDn = input(
             'Введіть ідентифікатор по якому треба видалити з файлу: ')
         file = Validation().file_existing("Text.txt", "w")
Exemple #8
0
#THE PURPOSE OF THIS SCRIPT IS TO CALL THE OTHER METHODS AND PRINT RESULTS
#run main to run the other scripts.
# modules are run for 10,000 simulations as a compromise between run-time
# and acheiving good results for the monte-carlo optimisation
# in the project 50,000 simulations was used.

swaption_vol_cva_dataset_path = 'Data/SwaptionVolMatrix_5Y.csv'
swap_curve_cva_dataset_path = 'Data/SpotCurve_5Y.csv'
swaption_vol_extended_dataset_path = 'Data/SwaptionVolMatrix.csv'
swap_curve_extended_dataset_path = 'Data/SpotCurve.csv'

# run cva calculation
cva_object = cva.CVASwap()

# Martingale testing and zero mean diffusion methods in here
validate = val.Validation()

# Carry out analytical calibration for extended dataset
libor_fit_parameters_extended = lmm.LMM(swaption_vol_extended_dataset_path,
                                        swap_curve_extended_dataset_path)
libor_fit_parameters_extended.volatility.mc_adjustment_factor = 1
libor_fit_parameters_extended.volatility.a = 0.5
libor_fit_parameters_extended.volatility.b = 0.5
libor_fit_parameters_extended.volatility.c = 0.5
libor_fit_parameters_extended.volatility.d = 0.5
libor_fit_parameters_extended.volatility.fit_parameters()
s = 'Extended dataset analytical calibration  - a = ' + str(libor_fit_parameters_extended.volatility.a)  \
    + '\n Extended dataset analytical calibration  - b = ' + str(libor_fit_parameters_extended.volatility.b) \
+ '\n Extended dataset analytical calibration  - c = ' + str(libor_fit_parameters_extended.volatility.c) \
+ '\n Extended dataset analytical calibration  - d = ' + str(libor_fit_parameters_extended.volatility.d)
print(s)
 def __init__(self):
     self.obj_validation = Validation.Validation()
     self.obj_appconfig = Appconfig()