Cash flow and exchange rate management method based on mathematical model
Through the combination of Prophet model and Bayesian optimization algorithm, the volatility and flexibility problems in enterprise cash flow and exchange rate management are solved, dynamic smooth cash flow fluctuations and accurate predictions are achieved, outlier warnings are provided, exchange rate risk management strategies are dynamically adjusted, and the entire process of capital management is realized.
Patent Information
- Application Number
- CN202510188548.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-20
- Publication Date
- 2025-07-04
Smart Images

Figure CN120258979A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of data analysis, and particularly relates to a method for managing cash flow and exchange rate based on a mathematical model. Background Art
[0002] Under the background of global business operations, more and more domestic enterprises are going overseas to expand their businesses. As a result, these enterprises are facing more and more challenges in the management of operating cash flow and exchange rate risk: In the field of cash flow management: Traditional methods rely on cash flow reports with fixed periods, communication with personnel in business departments, and manual scheduling, and it is often difficult to respond promptly to sudden capital requirements or surplus capital allocation problems; In the field of exchange rate risk management: Most enterprises need to listen to the suggestions of financial institutions such as banks and combine the experience judgments of relevant post personnel in exchange rate risk management. Internally, a single fixed hedging ratio strategy is adopted, and it is difficult to balance risks and returns in a dynamic market; In recent years, the rapid development of big data technology and artificial intelligence algorithms has provided a new direction for enterprise fund management; Time series models (such as Prophet) have performed excellently in predicting cash flow and exchange rate fluctuations, and the introduction of technologies such as genetic algorithms and Bayesian optimization has provided a more efficient optimization solution for cash flow and exchange rate risk management.
[0003] However, the current cash flow management has limitations. Its fixed rule management cannot dynamically adapt to the fluctuations of cash flow, and at the same time, it lacks an effective anomaly detection and warning mechanism. Moreover, the operation method based on business estimates or multiplying percentages of historical data is relatively common, lacking an accurate prediction of future cash flow trends; In addition, the exchange rate risk management also has limitations. Its single fixed hedging ratio causes enterprises to be unable to find the best balance between risks and returns, and at the same time, it lacks a dynamic adjustment strategy linked to market trends. Moreover, the hedging operations are concentrated, and it is easy to cause cost increases due to incorrect timing selection, lacking a system-integrated buy-sell signal as an auxiliary reference. Based on this, a method for managing cash flow and exchange rate based on a mathematical model is proposed. Summary of the Invention
[0004] The purpose of the present invention is to provide a method for managing cash flow and exchange rate based on a mathematical model with a simple structure and reasonable design in order to solve the above problems.
[0005] The present invention achieves the above purpose through the following technical solutions:
[0006] A method for managing cash flow and exchange rate based on a mathematical model includes the following steps:
[0007] S1: Obtain the historical overall cash flow data of the enterprise, and process the historical overall cash flow data of the enterprise through a rolling moving average and an extreme value range.
[0008] S2: Set the warning line for the overall cash flow data;
[0009] S3: Dynamically predict and roll - update the overall cash flow data through the Prophet model and Bayesian optimization;
[0010] S4: Split the overall enterprise cash flow data into cash flow data in each currency;
[0011] S5: Predict the exchange rate trends of each currency through the Prophet model and Bayesian optimization;
[0012] S6: Set the foreign exchange hedging operation according to the predicted exchange rate trends of the cash flow data in each currency;
[0013] S7: Generate trading signals as auxiliary references and execute the foreign exchange hedging operation.
[0014] As a further optimization scheme of the present invention, obtain the historical overall cash flow data of the enterprise, and process the historical overall cash flow data of the enterprise through rolling moving averages and extreme value ranges. The specific steps are as follows:
[0015] Conduct window - period analysis on the historical overall cash flow data of the enterprise, convert the monthly fluctuations into rolling moving averages, and process the historical overall cash flow data of the enterprise through a smoothing processing method;
[0016] Calculate the standard deviation based on the difference between the historical overall cash flow data of the enterprise and the rolling moving averages;
[0017] Determine the upper and lower limits of the fluctuations of the historical overall cash flow data with the standard deviation as a multiple of the rolling moving average.
[0018] As a further optimization scheme of the present invention, set the warning line for the overall cash flow data. The setting steps are as follows:
[0019] Set the warning line outside the upper and lower limit ranges;
[0020] Send a signal before the extreme value of the cash flow data approaches the warning line.
[0021] As a further optimization scheme of the present invention, dynamically predict and roll - update the overall cash flow data through the Prophet model and Bayesian optimization. Based on the historical overall cash flow data of the enterprise, use the Prophet model for prediction, and use Bayesian optimization to find the optimal parameters of the Prophet model.
[0022] Among them, the main parameters included in the Prophet model are as follows:
[0023] changepoint_prior_scale: Control the sensitivity of the model to the trend change points;
[0024] seasonality_prior_scale: Controls the weight of the seasonal component;
[0025] holidays_prior_scale: Controls the weight of the holiday effect;
[0026] seasonality_mode: The mode of seasonality;
[0027] n_changepoints: Defines the number of trend change points;
[0028] changepoint_range: Defines the time range in which trend changes occur.
[0029] As a further optimization scheme of the present invention, the search ranges of the main parameters in the Prophet model are as follows:
[0030] changepoint_prior_scale: 0.01 - 10.0;
[0031] seasonality_prior_scale: 0.01 - 20.0;
[0032] holidays_prior_scale: 0.1 - 10.0;
[0033] seasonality_mode: 'additive' or'multiplicative';
[0034] n_changepoints: 5 - 40;
[0035] changepoint_range: 0.7 - 0.9.
[0036] As a further optimization scheme of the present invention, the purpose of Bayesian optimization is: to find the best combination of hyperparameters of the Prophet model through automated search;
[0037] Principle: Bayesian optimization dynamically adjusts the parameter search range according to the objective function and gradually converges to the optimal solution;
[0038] Use the TPE algorithm for parameter sampling;
[0039] Implementation method: Define the objective function objective, which receives a set of parameters and returns the RMSE on the validation set;
[0040] Optuna automatically calls the objective function and adjusts the parameter combination according to the historical trial results to gradually find the best parameters;
[0041] The script calculates the following commonly used prediction evaluation metrics on the test set:
[0042]
[0043] RMSE: Root Mean Square Error;
[0044] n: The number of samples (the number of data points in the test set);
[0045] The predicted value of the i-th sample;
[0046] y i : The actual value of the i-th sample;
[0047] The prediction error of the i-th sample;
[0048] Cross-validate the predicted value with the predicted value of the enterprise's FP&A to obtain a more accurate future cash flow prediction;
[0049] Regularly update the historical data and prediction results monthly, and dynamically adjust the upper limit, lower limit and warning line based on rolling prediction;
[0050] Based on the prediction results, formulate an action plan for the existing funding gap or surplus.
[0051] As a further optimization solution of the present invention, the Prophet model and Bayesian optimization are used to predict the exchange rate trends of various currencies;
[0052] For a single currency, use the Prophet model combined with Bayesian optimization to perform rolling prediction based on historical exchange rate data;
[0053] Optimize the parameters once a month and determine the optimal model parameters for the current month. During the current month, only update the daily exchange rate data and do not change the parameters.
[0054] As a further optimization solution of the present invention, set the foreign exchange hedging operation according to the predicted exchange rate trends of the cash flow data of various currencies;
[0055] Divide the upper and lower limit intervals of the predicted exchange rate fluctuations into multiple segments, which respectively correspond to the hedging ratios of the enterprise.
[0056] As a further optimization solution of the present invention, the method for generating trading signals is as follows:
[0057] Optimize the historical exchange rate market data by genetic algorithm, mine the trading inertia and the rules of buying and selling points, and generate automatic trading signals;
[0058] Update the optimal trading parameters once a month, and combine this parameter to judge whether to trigger a trading signal when updating the foreign exchange market conditions daily.
[0059] As a further optimized solution of the present invention, trading signals are generated as auxiliary references to perform foreign exchange locking operations, and the specific steps are as follows:
[0060] Set the lower and upper limits of the overall foreign exchange locking ratio of the enterprise, and perform foreign exchange locking operations in batches by the method of "breaking up the whole into parts", monitor the predicted values weekly and increase or decrease positions according to the predicted values.
[0061] The beneficial effects of the present invention are as follows:
[0062] 1. By combining the Prophet model and the Bayesian optimization algorithm, the present invention solves the volatility problem in the management of the enterprise's operating cash flow, as well as the flexibility and accuracy problems in foreign exchange risk management, realizes the dynamic smoothing of cash flow fluctuations, provides outlier warnings, can accurately predict the future cash flow and foreign exchange rate trends, and can dynamically adjust foreign exchange risk management strategies to balance risks and returns, thereby realizing the full-process intelligence and automation of fund management.
[0063] 2. In the prediction of cash flow and foreign exchange rate fluctuations, the present invention applies the Prophet model and Bayesian optimization, and the prediction accuracy is significantly improved. By rolling updataing data and model parameters monthly, the automation adjustment of upper and lower limits, warning lines and foreign exchange locking ratios is realized, flexibly coping with market changes, integrating data analysis, prediction optimization and execution functions, and realizing the full-process automation from monitoring and warning to transaction execution; at the same time, genetic algorithms are combined to generate trading signals to further reduce manual intervention, thereby significantly reducing the repetitive workload of fund managers in cash flow and foreign exchange risk management, and improving the overall fund management efficiency of the enterprise, effectively reducing the exposure risk of the enterprise in the foreign exchange market. Brief Description of the Drawings
[0064] Figure 1 is the overall process schematic diagram of the present invention;
[0065] Figure 2 is the schematic diagram of the cash flow fluctuation situation of the present invention;
[0066] Figure 3 is the broken line schematic diagram of the cash flow prediction of the present invention;
[0067] Figure 4 is the broken line schematic diagram of the foreign exchange rate change prediction of the present invention;
[0068] Figure 5 is the broken line schematic diagram of the first currency prediction adjustment of the present invention;
[0069] Figure 6 is the broken line schematic diagram of the second currency prediction adjustment of the present invention;
[0070] Figure 7It is a line graph showing the comparison between the rolling prediction of the first currency of the present invention, the cumulative predicted value and the actual value;
[0071] Figure 8 It is a line graph showing the comparison between the rolling prediction of the second currency of the present invention, the cumulative predicted value and the actual value;
[0072] Figure 9 It is a line graph showing the exchange rate prediction of the Prophet model trained by the present invention. Detailed implementation manners
[0073] The following further describes the present application in detail with reference to the accompanying drawings. It is necessary to point out here that the following specific implementation manners are only used to further illustrate the present application and cannot be understood as limiting the protection scope of the present application. Those skilled in the art can make some non-essential improvements and adjustments to the present application based on the above application content.
[0074] Example 1: As Figure 1 shown, a method for managing cash flow and exchange rate based on a mathematical model includes the following steps:
[0075] S1: Obtain the historical overall cash flow data of the enterprise, and process the historical overall cash flow data of the enterprise through rolling moving average and extreme value range. The specific steps are as follows:
[0076] Conduct a window period analysis on the historical overall cash flow data of the enterprise, convert the monthly fluctuations into a rolling moving average, and process the historical overall cash flow data of the enterprise through a smoothing processing method;
[0077] Calculate the standard deviation based on the difference between the historical overall cash flow data of the enterprise and the rolling moving average;
[0078] Mathematical expression of the standard deviation:
[0079]
[0080] where N is the number of values; x i represents the i-th individual value; μ is the average (mean) of these values;
[0081] where,
[0082] Determine the upper and lower limits of the fluctuation of the historical overall cash flow data with the standard deviation as a multiple of the rolling moving average;
[0083] S2: Set the warning line for the overall cash flow data. The setting steps are as follows:
[0084] Set the warning line outside the upper and lower limit ranges;
[0085] Send a signal before the extreme value of the cash flow data approaches the warning line;
[0086] S3: Dynamically predict and roll-update the overall cash flow data through the Prophet model and Bayesian optimization. Based on the enterprise's historical overall cash flow data, use the Prophet model for prediction, and adopt Bayesian optimization to find the optimal parameters of the Prophet model.
[0087] The Prophet model is mainly composed of four parts: trend, seasonality, holidays and special events, and error term; y(t) = g(t) + s(t) + h(t) + ε;
[0088] Among them, g(t) is the trend term (long-term change direction): Prophet uses a piecewise linear or logistic growth curve to simulate the non-periodic changes in the data;
[0089] s(t) is the seasonality term (periodic fluctuation): Use Fourier series to fit the seasonal changes of different periods, which enables the model to capture the periodic fluctuations in the data;
[0090] h(t) is holidays and special events: Allow users to input a custom list of holidays, thus incorporating the impact of these special dates into the prediction model;
[0091] ε is the error term: An estimate of the uncertainty of the model prediction, especially for future predictions, provides a confidence interval;
[0092] Among them, the main parameters included in the Prophet model are as follows:
[0093] changepoint_prior_scale: Controls the sensitivity of the model to trend change points;
[0094] seasonality_prior_scale: Controls the weight of the seasonal component;
[0095] holidays_prior_scale: Controls the weight of the holiday effect;
[0096] seasonality_mode: The mode of seasonality;
[0097] n_changepoints: Defines the number of trend change points;
[0098] changepoint_range: Defines the time range of trend changes;
[0099] The search ranges of the main parameters in the Prophet model are as follows:
[0100] changepoint_prior_scale: 0.01 - 10.0;
[0101] seasonality_prior_scale: 0.01 - 20.0;
[0102] holidays_prior_scale: 0.1 - 10.0;
[0103] seasonality_mode:'additive (additive)' or'multiplicative (multiplicative)':
[0104] n_changepoints: 5 - 40;
[0105] changepoint_range: 0.7 - 0.9;
[0106] Divide the original sequence data into 70% training set, 15% validation set, and 15% test set:
[0107] Training set: Used to train the Prophet model;
[0108] Validation set: Used for the objective function of Bayesian optimization, with the RMSE of the validation set as the optimization objective (the smallest RMSE value);
[0109] Test set: Use the finally optimized model to make predictions and evaluate the performance (it should be noted that this part describes the method of training the Prophet model and the logic of building the Prophet model. All historical data is blue + orange + red. As Figure 9 shown, according to the changing rules learned from historical data, 70% of the historical data is divided into the training part to learn the data fluctuation rules; 15% is divided into the validation part for the objective function of Bayesian optimization, with the RMSE of the validation set as the optimization objective (the smallest RMSE value); the remaining 15% is divided into the test part, and the finally optimized model is used to make predictions and evaluate the performance. The purpose of Bayesian optimization is: to find the best hyperparameter combination of the Prophet model through automated search. After comparing the actual values and validation values of the orange part, the set of parameters with the smallest RMSE difference is identified as the optimal parameters, which can be considered to capture the characteristics of data fluctuations, and then these optimal parameters are used to predict the test set to evaluate the overall performance of the model);
[0110] The purpose of Bayesian optimization is: to find the best hyperparameter combination of the Prophet model through automated search;
[0111] Principle: Bayesian optimization dynamically adjusts the parameter search range according to the objective function (validation set RMSE) and gradually converges to the optimal solution;
[0112] The TPE (Tree-structured Parzen Estimator) algorithm is used for parameter sampling. The TPE algorithm is a tree-structured algorithm based on Bayesian optimization for hyperparameter optimization. It constructs two Gaussian mixture models (GMMs), one for modeling good-performing parameter configurations (Exploitation) and the other for modeling unknown parameter configurations (Exploration), thereby intelligently narrowing the search range and improving the search efficiency. Specifically, in each trial, the TPE algorithm divides the parameters into an "elite set" and a "non-elite set" based on historical evaluation results and maintains a Gaussian mixture model for each hyperparameter. Then, the next set of search values is selected by maximizing the ratio of l(x) / g(x), where l(x) represents the probability density function of the hyperparameters related to the best objective value, and g(x) represents the probability density function of the remaining hyperparameters;
[0113] Implementation method: Define the objective function objective(trial), which receives a set of parameters and returns the RMSE (root mean square error) on the validation set;
[0114] Optuna automatically calls the objective function and adjusts the parameter combination according to historical trial results to gradually find the best parameters;
[0115] The script calculates the following commonly used prediction evaluation metrics on the test set:
[0116]
[0117] RMSE: Root mean square error;
[0118] n: Number of samples (number of data points in the test set);
[0119] Predicted value of the i-th sample;
[0120] y i : Actual value of the i-th sample;
[0121] Prediction error of the i-th sample;
[0122] The predicted value is cross-validated with the predicted value of the enterprise's FP&A (Financial Planning and Analysis department) to obtain a more accurate future cash flow prediction;
[0123] The historical data and prediction results are updated regularly every month, and the upper limit, lower limit, and warning line are dynamically adjusted based on rolling predictions;
[0124] Based on the prediction results, formulate action plans for the emerging funding gaps or surpluses.
[0125] S4: Split the overall enterprise cash flow data into cash flow data for each currency.
[0126] S5: Forecast the exchange rate trends for each currency through the Prophet model and Bayesian optimization. For a single currency, use the Prophet model combined with Bayesian optimization for rolling forecasts based on historical exchange rate data.
[0127] Optimize the parameters once a month and determine the optimal model (Prophet model) parameters for the current month. During the current month, only update the daily exchange rate data and do not change the parameters.
[0128] S6: Set up hedging operations according to the forecast exchange rate trends of the cash flow data for each currency. Divide the upper and lower limits of the predicted exchange rate fluctuations into multiple segments, which respectively correspond to the hedging ratios of the enterprise.
[0129] For enterprises mainly engaged in purchasing foreign exchange and making overseas payments, when the predicted exchange rate approaches the lower limit of the relatively low range, increase the hedging ratio; when the exchange rate approaches the upper limit of the high level, reduce the hedging ratio.
[0130] For enterprises mainly engaged in receiving foreign exchange and using it for settlement, when the predicted exchange rate approaches the lower limit of the relatively low range, reduce the hedging ratio; when the exchange rate approaches the upper limit of the high level, increase the hedging ratio.
[0131] S7: Generate trading signals as auxiliary references and execute hedging operations.
[0132] The method for generating trading signals is as follows:
[0133] Optimize the historical exchange rate market data through genetic algorithms, mine trading inertia and buying and selling point rules, and form automatic trading signals.
[0134] Update the optimal trading parameters once a month, and combine this parameter to judge whether to trigger trading signals when updating the foreign exchange market conditions daily.
[0135] The specific steps for executing hedging operations are as follows:
[0136] Set the lower and upper limits of the overall hedging ratio of the enterprise, and execute hedging operations in batches through the method of "breaking up the whole into parts". Monitor the predicted values weekly and increase or decrease positions according to the predicted values.
[0137] The basic steps of genetic algorithms include the following key operations:
[0138] 1) Initialize the population: Randomly generate a group of initial solutions. Each solution is an "individual" representing a possible solution.
[0139] 2) Fitness evaluation: Score each individual, and this score is called "fitness"; fitness represents the "goodness" of an individual. In this method, fitness is measured by the strategy return rate during the backtest period, and the goal is to maximize the return;
[0140] 3) Selection: Select individuals according to fitness; individuals with higher fitness have a greater probability of being selected; selection favors better-performing solutions; the tournament selection mode is used in the strategy. Specifically, tournament selection randomly selects a certain number of individuals from the population, and then selects the individual with the highest fitness as the parent for crossover;
[0141] 4) Crossover: The selected individuals will produce "offspring"; that is, combine the genes of two individuals to generate new individuals; the crossover probability is set to 70% in the strategy, that is, there is a 70% probability that each pair of parent individuals will exchange genes to generate new offspring. Specifically, the crossover operation will randomly select some genes in the genes of two individuals for exchange to generate new individuals;
[0142] 5) Mutation: Make small random mutations in the genes of the new individuals; the role of mutation is to increase the diversity of the solution space and avoid falling into local optimal solutions; the mutation probability is set to 20% in the strategy, that is, 20% of the genes in each new individual will undergo small random changes, aiming to increase the diversity of the population and thus avoid the algorithm falling into local optimal solutions; mutation usually involves fine-tuning the parameters of the individual (for example, randomly adjusting the moving average period or coefficient);
[0143] 6) Replacement: Put the newly generated individuals into the population and replace some old individuals; re-evaluate the fitness and enter the next iteration;
[0144] 7) Termination condition: When the set number of iterations (100 times in the strategy) is reached, the genetic algorithm terminates; the optimal solution is the individual with the best performance in all generations, that is, the optimal parameter combination; in each generation, the algorithm will update the current optimal solution.
[0145] Example 2: As Figure 2 、 Figure 3 、 Figure 4 、 Figure 5 、 Figure 6 、 Figure 7 and Figure 8 shown, S1: Obtain the historical overall cash flow data of the enterprise, and process the historical overall cash flow data of the enterprise through the rolling moving average and extreme value range:
[0146] Taking a 3-year observation period as an example, obtain the operating cash flow data of the enterprise in the past 36 months;
[0147] S2: Set the warning line for the overall cash flow data:
[0148] Use the rolling moving average + standard deviation method to determine the upper and lower limits and the warning line; if the enterprise hopes to cover more than 90% of the fluctuations, the standard deviation multiple can be adjusted according to management preferences;
[0149] As Figure 2 shown, on the left side of the figure is the actual monthly operating net cash flow fluctuation, and within the red frame is the predicted cash flow fluctuation;
[0150] S3: Dynamically predict and roll - update the overall cash flow data through the Prophet model and Bayesian optimization:
[0151] Use the Prophet model to predict the cash flow for the next 3 months, and find the best parameter combination through Bayesian optimization;
[0152] After updating the actual data every month, retrain the model and adjust the subsequent predicted values in a timely manner;
[0153] Compare with the prediction of the enterprise's FP&A department. If the difference is large, conduct a cause analysis and parameter fine - tuning, as Figure 3 and Figure 4 shown;
[0154] The following are the optimal parameters found through Bayesian optimization. Taking the minimum RMSE as the standard, the found parameters:
[0155] 'changepoint_prior_scale': 0.01,
[0156] 'seasonality_mode': 'additive',
[0157] 'seasonality_prior_scale': 1.0}
[0158] Best RMSE: 940446.4597478439
[0159] Best MSE (Mean Squared Error): 884439543652.2529
[0160] Best MAE (Mean Absolute Error): 744960.334563048
[0161] Best SMAPE (Symmetric Mean Absolute Percentage Error): 0.28061542435622555
[0162] As Figure 4As shown, the predicted values generated within the validation set of the red line are in good agreement with the actual values, indicating that the characteristics of data fluctuations are captured. These sets of hyperparameters are used as predicted values for the future.
[0163] If the prediction shows that a funding gap may approach the lower limit and has reached the warning line, assuming the enterprise's financing arrival time is 1 month, the enterprise needs to reserve a buffer period of 1 month in advance for financing arrangements.
[0164] If a large surplus of funds or an approach to the upper limit is predicted, corresponding wealth management product investments can be considered to enhance fund returns.
[0165] S4: Split the enterprise's overall cash flow data into cash flow data for each currency:
[0166] Decompose the enterprise's overall cash flow into different currencies, such as GBP, USD, EUR, etc., and conduct predictions and management separately.
[0167] S5: Predict the exchange rate trends of each currency through the Prophet model and Bayesian optimization.
[0168] S6: Set hedging operations according to the predicted exchange rate trends of the cash flow data for each currency:
[0169] Table 1 Exchange Rate Forecast Table for USD / JPY and GBP / USD at the End of Each Month
[0170] Date USDJPY forecast GBPUSD forecast 2024 / 12 / 31 156.18 1.2587 2025 / 1 / 31 154.37 1.2623 2025 / 2 / 28 154.77 1.2542 2025 / 3 / 31 155.73 1.2481 2025 / 4 / 30 157.03 1.2585 2025 / 5 / 31 157.28 1.2515 2025 / 6 / 30 158.31 1.2530
[0171] The rolling exchange rate forecast values are shown in Table 1. The comparison of the cumulative forecast values with the actual values is as Figure 7 and Figure 8 shown. According to the forecast values in Table 1 and the comparison line charts of the forecast values and actual values as shown in Figure 7 and Figure 8 shown, set the corresponding hedging operations as follows:
[0172] 1) Conduct a 6-month rolling forecast for GBP / USD; taking an enterprise with a need to purchase foreign exchange as an example, if the forecast interval shows that the exchange rate continues to decline, quickly increase the hedging ratio to 80%;
[0173] If the forecast interval shows that the exchange rate may rise, lower the hedging ratio to 20% to reserve more room for obtaining exchange rate differences, as shown in Figure 5 and Figure 6 shown;
[0174] 2) Batch and break up into smaller parts + execute weekly:
[0175] Disperse the total foreign exchange exposure that needs to be hedged for locking at a weekly frequency;
[0176] Adhere to the principle of "more in the near term and less in the far term";
[0177] Table 2 Data Table of Monthly Changes in Pound Receipts and Payments
[0178]
[0179]
[0180] Table 2 shows the monthly changes in pound receipts and payments of an enterprise. The meaning of the exposure is the net amount after income - expenditure, that is, the amount increased or decreased after the pound has completed the receipt and payment in this month. According to the data of monthly changes in pound receipts and payments shown in Table 2, corresponding foreign exchange locking operations are set for the enterprise to reduce the risk of market impact or missed market opportunities caused by concentrated single - time foreign exchange locking;
[0181] S7: Generate trading signals as auxiliary references and execute foreign exchange locking operations:
[0182] Use the genetic algorithm to mine the market operation inertia in historical market conditions, find the optimal moving average combination within the observation window period, and use this to assist the execution timing of actual foreign exchange locking operations (update parameters monthly, update market data daily, and automatically generate trading signals);
[0183] Table 3 is the parameter table of each currency pair obtained by using the genetic algorithm based on historical exchange rate data;
[0184] Table 3 Parameter Table of Each Currency Pair
[0185] Curr. 3DMA 5DMA short_ma long_ma entry_coef exit_coef AUDUSD 3 5 14 37 0.48 0.23 EURUSD 3 5 21 35 0.28 0.17 GBPUSD 3 5 9 24 0.17 0.32 USDJPY 3 5 16 29 0.45 0.18
[0186] In the above table, Curr is the currency pair;
[0187] 3DMA is the 3 - day closing price moving average;
[0188] 5DMA is the 5 - day closing price moving average;
[0189] short_ma is the short - term moving average, and the numbers in the same column are different for each currency pair;
[0190] long_ma is the long - term moving average, and the numbers in the same column are different for each currency pair;
[0191] entry_coef is the buying coefficient, and the numbers in the same column are different for each currency pair;
[0192] exit_coef is the selling coefficient, and the numbers in the same column are different for each currency pair;
[0193] Take the strategy of buying USDJPY as an example: When the 5-day moving average is greater than the 16-day moving average and greater than the difference between the 16-day moving average and the 29-day moving average, take a long position to buy; Based on the above position establishment, when the 3-day moving average is less than or equal to the 5-day moving average, sell half of the above position establishment amount; When the 3-day moving average is less than the 5-day moving average minus 0.18 times the difference between the 5-day moving average and the 16-day moving average, sell the remaining half; That is, Table 3 shows the execution timing of the actual foreign exchange locking operation for each currency pair;
[0194] Table 4 Backtest data table of trading signals generated daily for USDJPY
[0195]
[0196]
[0197]
[0198] Table 4 shows the actual backtest data for the US dollar and Japanese yen. The parameters in the actual backtest will be updated on December 31, 2023, March 31, 2024, June 30, 2024, and September 30, 2024; After each update, trading will be conducted based on the signals generated by this set of parameters for the next 3 months, and then the profit and loss of each transaction will be summarized and calculated. The calculation method is as follows:
[0199] When a trading signal appears, use the opening price of the next day as the operating price;
[0200] Take the transaction on February 2, 2024 as an example:
[0201] A buy 100 trading signal appeared on February 2. On February 3, 100 US dollars were bought at the opening price of 148.35, and 14,835 Japanese yen were sold; A first closing signal appeared on February 29. On March 1, 50 US dollars were sold at the opening price of 149.98, and 7,499 Japanese yen were bought. The calculation method is the opening price multiplied by the number of US dollars sold. At this time, a profit of 81.50 = (149.98 - 148.35) * 50 was generated; A second closing signal appeared on March 1. On March 4, 50 US dollars were sold at the opening price of 150.10, and 7,505 Japanese yen were bought. At this time, a profit of 87.50 = (150.10 - 148.35) * 50 was generated; The final profit of this transaction was 169 Japanese yen = 81.50 + 87.50; That is, according to the corresponding trading signals, performing the corresponding foreign exchange locking operations can enable the enterprise to reduce the risks of market impact or missed market opportunities caused by concentrated single foreign exchange locking;
[0202] Table 5 Backtest data table of trading signals generated daily for GBPUSD
[0203]
[0204]
[0205] Table 5 shows the actual backtest data of GBP / USD. The parameters in the actual backtest will be updated on December 31, 2023, March 31, 2024, June 30, 2024, and September 30, 2024. After each update, trading will be conducted based on the signals generated by this set of parameters for the next three months, and then the profit and loss of each trade will be summarized and calculated. The calculation method is as follows:
[0206] When a trading signal appears, the opening price of the next day is used as the operation price;
[0207] Taking the trade on December 11, 2024 as an example:
[0208] On December 11, a buy 100 trading signal appeared. On December 13, 100 GBP were bought at the opening price of 1.2676. On December 13, the first closing signal appeared. On December 16, 50 GBP were sold at the opening price of 1.2629. At this time, the loss was -0.155 = (1.2629 - 1.2676) * 50. On December 16, the second closing signal appeared. On December 17, 50 GBP were sold at the opening price of 1.2965. At this time, the profit was 1.445 = (1.2965 - 1.2676) * 50. Finally, the profit of this trade was 1.29 US dollars = 1.445 - 0.155. That is, according to the corresponding trading signals, performing the corresponding foreign exchange locking operations can enable the enterprise to reduce the risks of market impact or missed market opportunities caused by concentrated single foreign exchange locking;
[0209] Table 6 shows the buy and sell trading signals updated daily, which serves as an auxiliary judgment during trading;
[0210] Table 6 Daily updated buy and sell trading signal table
[0211] Serial number 1 2 3 4 Curr AUDUSD EURUSD GBPUSD USDJPY Year 2025 2025 2025 2025 2025-01-01 2025-01-02 Sell the first closing Buy the first closing 2025-01-03 Sell 100 Buy the first closing 2025-01-04 2025-01-05 2025-01-06 2025-01-07 Sell the first closing 2025-01-08 Sell the second closing Sell the first closing Sell the second closing 2025-01-09 Sell the second closing Sell 100 2025-01-10 Sell 100 2025-01-11 2025-01-12 2025-01-13 Buy the second closing 2025-01-14 Buy the first closing 2025-01-15 2025-01-16 Sell the second closing Sell the first closing Buy the second closing 2025-01-17 Sell 100 Sell the second closing Sell the first closing Sell 100 2025-01-18 2025-01-19 2025-01-20 Sell the first closing Sell 100 Sell 100 2025-01-21 Sell the second closing Sell the second closing Sell the second closing Sell 100 2025-01-22 Buy 100 Sell the second closing Sell the second closing 2025-01-23 Buy 100 2025-01-24 Buy 100 Sell the first closing 2025-01-25 2025-01-26 2025-01-27 Buy 100 Buy 100 Sell the second closing 2025-01-28 Sell 100 2025-01-29 Buy the first closing 2025-01-30 Buy the second closing Buy the first closing 2025-01-31 Buy 100 Buy the first closing Buy the first closing
[0212] Table 6 shows the trading signals generated by each currency pair on different days, providing an auxiliary reference for the enterprise to adopt corresponding foreign exchange locking operations according to the corresponding trading signals, facilitating the enterprise to provide accurate foreign exchange locking operations, thereby enabling the enterprise to reduce the risks of market impact or missed market opportunities caused by concentrated single foreign exchange locking;
[0213] The trading signals generated by the genetic algorithm had an actual yield of 5.23% in spot foreign exchange buying and selling in 2024, as shown in Table 7;
[0214] Table 7 Parameter backtest table for 5 years from 2020 to 2024
[0215]
[0216]
[0217] As can be seen from the data shown in Table 7, when enterprises use the cash flow and exchange rate management method based on a mathematical model to predict exchange rates, set corresponding exchange rate locking operations according to the predicted exchange rates, and then rely on the auxiliary reference of trading signals to execute the corresponding exchange rate locking operations, the benefits obtained by the enterprises are significantly improved. Thus, it can be seen that when enterprises manage cash flow and exchange rates, applying the Prophet model and Bayesian optimization in the prediction of cash flow and exchange rate fluctuations can achieve full-process automation from monitoring and early warning to transaction execution. At the same time, combining with the genetic algorithm to generate trading signals can enhance the overall capital management efficiency of enterprises, effectively reduce the exposure risk of enterprises in the exchange rate market, and improve the benefits of enterprises.
[0218] The above-described embodiments merely represent several implementation manners of the present invention, and the description thereof is relatively specific and detailed, but it should not be construed as a limitation on the scope of the patent for the present invention. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present invention, several modifications and improvements can still be made, and these all belong to the protection scope of the present invention.
Claims
1. A cash flow and exchange rate management method based on a mathematical model, characterized in that, It includes the following steps: S1: Obtain the historical overall cash flow data of the enterprise, and process the historical overall cash flow data of the enterprise through rolling moving averages and extreme value ranges; S2: Set the warning line for the overall cash flow data; S3: Dynamically predict and rolling update the overall cash flow data through the Prophet model and Bayesian optimization; S4: Split the overall cash flow data of the enterprise into cash flow data in each currency; S5: Predict the exchange rate trends of each currency through the Prophet model and Bayesian optimization; S6: Set the foreign exchange hedging operation according to the predicted exchange rate trends of the cash flow data in each currency; S7: Generate trading signals as auxiliary references and execute the foreign exchange hedging operation.
2. The cash flow and exchange rate management method based on a mathematical model according to claim 1, characterized in that: Obtain the historical overall cash flow data of the enterprise, and process the historical overall cash flow data of the enterprise through rolling moving averages and extreme value ranges. The specific steps are as follows: Conduct window period analysis on the historical overall cash flow data of the enterprise, convert the monthly fluctuations into rolling moving averages, and process the historical overall cash flow data of the enterprise through a smoothing processing method; Calculate the standard deviation based on the difference between the historical overall cash flow data of the enterprise and the rolling moving average; Determine the upper and lower limits of the fluctuations of the historical overall cash flow data with the standard deviation as a multiple of the rolling moving average.
3. The cash flow and exchange rate management method based on a mathematical model according to claim 2, wherein: Set the warning line for the overall cash flow data. The setting steps are as follows: Set the warning line outside the upper and lower limit ranges; Send a signal before the extreme value of the cash flow data approaches the warning line.
4. A method for cash flow and exchange rate management based on a mathematical model according to claim 1, characterized in that: Dynamically predict and rolling update the overall cash flow data through the Prophet model and Bayesian optimization. Based on the historical overall cash flow data of the enterprise, use the Prophet model for prediction, and use Bayesian optimization to find the optimal parameters of the Prophet model. Among them, the main parameters included in the Prophet model are as follows: changepoint_prior_scale: Controls the sensitivity of the model to trend change points; seasonality_prior_scale: Controls the weight of the seasonal component; holidays_prior_scale: Controls the weight of the holiday effect; seasonality_mode: The mode of seasonality; n_changepoints: Defines the number of trend change points that occur; changepoint_range: Defines the time range in which trend changes occur.
5. A method for cash flow and exchange rate management based on a mathematical model according to claim 4, characterized in that: The search ranges of the main parameters in the Prophet model are as follows: changepoint_prior_scale: 0.01 - 10.0; seasonality_prior_scale: 0.01 - 20.0; holidays_prior_scale: 0.1 - 10.0; seasonality_mode: 'additive' or'multiplicative'; n_changepoints: 5 - 40; changepoint_range: 0.7 - 0.
9.
6. The cash flow and exchange rate management method based on a mathematical model according to claim 1, characterized in that: The purpose of Bayesian optimization is: To find the best combination of hyperparameters of the Prophet model through automated search; Principle: Bayesian optimization dynamically adjusts the parameter search range according to the objective function and gradually converges to the optimal solution; Use the TPE algorithm for parameter sampling; Implementation method: Define the objective function objective, which receives a set of parameters and returns the RMSE on the validation set; Optuna automatically calls the objective function and adjusts the parameter combination according to the historical trial results to gradually find the best parameters; The script calculates the following common prediction evaluation metrics on the test set: RMSE: Root Mean Square Error; n: Number of samples (number of data points in the test set); The predicted value of the i-th sample; y i : The actual value of the i-th sample; The prediction error of the i-th sample; Cross-validate the predicted values with the predicted values of the enterprise's FP&A to obtain a more accurate future cash flow prediction; Regularly update the historical data and prediction results monthly, and dynamically adjust the upper limit, lower limit, and warning line based on rolling predictions; Based on the prediction results, formulate an action plan for the emerging fund gap or surplus.
7. A method for cash flow and exchange rate management based on a mathematical model according to claim 1, characterized in that: Predict the exchange rate trends of various currencies through the Prophet model and Bayesian optimization; For a single currency, use the Prophet model combined with Bayesian optimization for rolling prediction based on historical exchange rate data; Optimize the parameters once a month and determine the optimal model parameters for the current month. Only update the daily exchange rate data during the current month without changing the parameters.
8. A method for managing cash flow and exchange rate based on a mathematical model according to claim 1, characterized in that: Set the hedging operation according to the predicted exchange rate trends of the cash flow data of various currencies; Divide the upper and lower limit intervals of the predicted exchange rate fluctuations into multiple segments, which respectively correspond to the hedging ratios of the enterprise.
9. A method for cash flow and exchange rate management based on a mathematical model according to claim 1, characterized in that: The method for generating trading signals is as follows: Optimize the historical exchange rate market data with the genetic algorithm, mine the trading inertia and the rules of buying and selling points, and generate automatic trading signals; Update the optimal trading parameters once a month, and combine this parameter to judge whether to trigger a trading signal when updating the foreign exchange market conditions daily.
10. A method for cash flow and exchange rate management based on a mathematical model according to claim 9, characterized in that: Generate trading signals as an auxiliary reference and execute the hedging operation. The specific steps are as follows: Set the lower and upper limits of the overall hedging ratio of the enterprise, and execute the hedging operation in batches by the method of "breaking up the whole into parts", monitor the predicted values weekly and increase or decrease positions according to the predicted values.
Citation Information
Cited By
AI financial intelligent analysis system
CN121458470A