Пример #1
0
 def calib(fileName):
     """Test le calibration Broker Strangle"""
     with open(fileName, "r") as file:
         data = json.load(file)
     surface = constructFXVolSurface(data)
     output = outputFxVolCalibrated(surface, data)
     return output
Пример #2
0
    def post(self):
        """
        interpolation : smile axis
        :return: the interpolated value
        """

        # All the program statements
        start_json = timeit.default_timer()
        content = request.get_json()
        stop_json = timeit.default_timer()
        start_calib = timeit.default_timer()
        surface = constructFXVolSurface(content)
        stop_calib = timeit.default_timer()
        # define model
        start_output = timeit.default_timer()
        output = outputFxVolCalibrated(surface, content)
        stop_output = timeit.default_timer()
        nb_surface = len(content["marketDataDefinitions"]["fxVolatilities"])

        expiry = [
            len(fxvol["expiries"])
            for fxvol in content["marketDataDefinitions"]["fxVolatilities"]
        ]
        return jsonify({
            "nb Surface": nb_surface,
            "nb expiry per curve": json.dumps(expiry),
            "nb total expiry": int(np.sum(expiry)),
            "total": stop_output - start_json,
            "parsing input": stop_json - start_json,
            "calibration : ": stop_calib - start_calib,
            "paring output : ": stop_output - start_output
        })
Пример #3
0
 def post(self):
     """
     interpolation : smile axis
     :return: the interpolated value
     """
     content = request.get_json()
     surface = constructFXVolSurface(content)
     # define model
     output = outputFxVolCalibrated(surface, content)
     return output
Пример #4
0
 def calibMC(fileName):
     with open(fileName, "r") as file:
         data = json.load(file)
     start_json = timeit.default_timer()
     calib1FxVolMC = functools.partial(
         calib1FxVol, parse(data["asOfDate"]), data["marketData"],
         data["marketDataDefinitions"]["yieldCurves"])
     pool = multiprocessing.Pool(multiprocessing.cpu_count() - 1)
     surface = pool.starmap(
         calib1FxVolMC,
         zip(data["marketDataDefinitions"]["fxVolatilities"]))
     pool.close()
     pool.join()
     pool.terminate()
     output = outputFxVolCalibrated(surface, data)
     end_json = timeit.default_timer()
     print("time : " + str(end_json - start_json))
     return output
Пример #5
0
    def post(self):
        """
        interpolation : smile axis
        :return: the interpolated value
        """

        # All the program statements
        start_json = timeit.default_timer()
        content = request.get_json()
        stop_json = timeit.default_timer()
        start_MCBuilding = timeit.default_timer()
        calib1FxVolMC = functools.partial(
            calib1FxVol, parse(content["asOfDate"]), content["marketData"],
            content["marketDataDefinitions"]["yieldCurves"])
        pool = multiprocessing.Pool(multiprocessing.cpu_count() - 1)
        end_MCBuilding = timeit.default_timer()
        start_calib = timeit.default_timer()
        surface = pool.starmap(
            calib1FxVolMC,
            zip(content["marketDataDefinitions"]["fxVolatilities"]))
        pool.close()
        pool.join()
        pool.terminate()
        stop_calib = timeit.default_timer()
        # define model
        start_output = timeit.default_timer()
        output = outputFxVolCalibrated(surface, content)
        stop_output = timeit.default_timer()
        nb_surface = len(content["marketDataDefinitions"]["fxVolatilities"])

        expiry = [
            len(fxvol["expiries"])
            for fxvol in content["marketDataDefinitions"]["fxVolatilities"]
        ]
        return jsonify({
            "nb Surface": nb_surface,
            "nb expiry per curve": json.dumps(expiry),
            "nb total expiry": int(np.sum(expiry)),
            "total": stop_output - start_json,
            "parsing input": stop_json - start_json,
            "multicore setting": end_MCBuilding - start_MCBuilding,
            "calibration : ": stop_calib - start_calib,
            "paring output : ": stop_output - start_output
        })
Пример #6
0
 def post(self):
     """
     interpolation : smile axis
     :return: the interpolated value
     """
     content = request.get_json()
     calib1FxVolMC = functools.partial(
         calib1FxVol, parse(content["asOfDate"]), content["marketData"],
         content["marketDataDefinitions"]["yieldCurves"])
     pool = multiprocessing.Pool(multiprocessing.cpu_count() - 1)
     surface = pool.starmap(
         calib1FxVolMC,
         zip(content["marketDataDefinitions"]["fxVolatilities"]))
     pool.close()
     pool.join()
     pool.terminate()
     #output result
     output = outputFxVolCalibrated(surface, content)
     return output
Пример #7
0
def calibService(fileName="calibration_fqp.json"):
    with open(fileName, "r") as file:
        data = json.load(file)
    surface = constructFXVolSurface(data)
    return outputFxVolCalibrated(surface, data)