📄 rq_fpml_floating_rate_calculation.c
字号:
/*** rq_fpml_floating_rate_calculation.c**** Written by Brett Hutley - brett@hutley.net**** Copyright (C) 2002 Brett Hutley**** This file is part of the Risk Quantify Library**** Risk Quantify is free software; you can redistribute it and/or** modify it under the terms of the GNU Library General Public** License as published by the Free Software Foundation; either** version 2 of the License, or (at your option) any later version.**** Risk Quantify is distributed in the hope that it will be useful,** but WITHOUT ANY WARRANTY; without even the implied warranty of** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU** Library General Public License for more details.**** You should have received a copy of the GNU Library General Public** License along with Risk Quantify; if not, write to the Free** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA*/#include "fpml/rq_fpml_floating_rate_calculation.h"#include <stdlib.h>voidrq_fpml_floating_rate_calculation_init(struct rq_fpml_floating_rate_calculation *p){ p->floating_rate_index = NULL; rq_fpml_interval_init(&p->index_tenor); rq_fpml_schedule_init(&p->floating_rate_multiplier_schedule); rq_fpml_schedule_init(&p->spread_schedule); p->rate_treatment = NULL; rq_fpml_strike_schedule_init(&p->cap_rate_schedule); rq_fpml_strike_schedule_init(&p->floor_rate_schedule); p->initial_rate = 0; rq_fpml_rounding_init(&p->final_rate_rounding); p->averaging_method = NULL; p->negative_interest_rate_treatment = NULL;}voidrq_fpml_floating_rate_calculation_clear(struct rq_fpml_floating_rate_calculation *p){ if (p->floating_rate_index) { free((char *)p->floating_rate_index); p->floating_rate_index = NULL; } rq_fpml_interval_clear(&p->index_tenor); rq_fpml_schedule_clear(&p->floating_rate_multiplier_schedule); rq_fpml_schedule_clear(&p->spread_schedule); if (p->rate_treatment) { free((char *)p->rate_treatment); p->rate_treatment = NULL; } rq_fpml_strike_schedule_clear(&p->cap_rate_schedule); rq_fpml_strike_schedule_clear(&p->floor_rate_schedule); p->initial_rate = 0; rq_fpml_rounding_clear(&p->final_rate_rounding); if (p->averaging_method) { free((char *)p->averaging_method); p->averaging_method = NULL; } if (p->negative_interest_rate_treatment) { free((char *)p->negative_interest_rate_treatment); p->negative_interest_rate_treatment = NULL; }}intrq_fpml_floating_rate_calculation_write_xml(struct rq_fpml_floating_rate_calculation *p, rq_stream_t output_stream){ rq_stream_write_string(output_stream, "<floatingRateCalculation>"); rq_stream_write_string(output_stream, "<floatingRateIndex>"); rq_stream_write_string(output_stream, p->floating_rate_index); rq_stream_write_string(output_stream, "</floatingRateIndex>"); rq_fpml_interval_write_xml(&p->index_tenor, output_stream); rq_fpml_schedule_write_xml(&p->floating_rate_multiplier_schedule, output_stream); rq_fpml_schedule_write_xml(&p->spread_schedule, output_stream); rq_stream_write_string(output_stream, "<rateTreatment>"); rq_stream_write_string(output_stream, p->rate_treatment); rq_stream_write_string(output_stream, "</rateTreatment>"); rq_fpml_strike_schedule_write_xml(&p->cap_rate_schedule, output_stream); rq_fpml_strike_schedule_write_xml(&p->floor_rate_schedule, output_stream); rq_stream_write_string(output_stream, "<initialRate>"); rq_stream_write_double_as_string(output_stream, p->initial_rate, 0); rq_stream_write_string(output_stream, "</initialRate>"); rq_fpml_rounding_write_xml(&p->final_rate_rounding, output_stream); rq_stream_write_string(output_stream, "<averagingMethod>"); rq_stream_write_string(output_stream, p->averaging_method); rq_stream_write_string(output_stream, "</averagingMethod>"); rq_stream_write_string(output_stream, "<negativeInterestRateTreatment>"); rq_stream_write_string(output_stream, p->negative_interest_rate_treatment); rq_stream_write_string(output_stream, "</negativeInterestRateTreatment>"); rq_stream_write_string(output_stream, "</floatingRateCalculation>"); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -