⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rq_fpml_product_fxsimpleoption.c

📁 风险财务控制库 Risk Quantify is an open source financial library, with a focus on managing the risk of fi
💻 C
字号:
/*** rq_fpml_product_fxsimpleoption.c**** Written by Brett Hutley - brett@hutley.net**** Copyright (C) 2001 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_product_fxsimpleoption.h"#include <stdlib.h>#include <string.h>/* -- structures --------------------------------------------------- */struct rq_fpml_product_fxsimpleoption {    const char *buyer_party_id;    const char *seller_party_id;    struct rq_fpml_expiry_date_time expiry_date_time;    enum rq_exercise_style exercise_style;    rq_date value_date;    struct rq_fpml_money put_currency_amount;    struct rq_fpml_money call_currency_amount;    struct rq_fpml_fx_strike_price strike_price;};/* -- globals ------------------------------------------------------ */const char *rq_fpml_product_fxsimpleoption_product_type = "fxsimpleoption";/* -- code --------------------------------------------------------- */static void rq_fpml_product_fxsimpleoption_free(void *product_data){    struct rq_fpml_product_fxsimpleoption *p =         (struct rq_fpml_product_fxsimpleoption *)product_data;    /* -- fill me out -- */    free(p);}intrq_fpml_product_fxsimpleoption_write_xml(void *product_data, rq_stream_t output_stream){    struct rq_fpml_product_fxsimpleoption *p =         (struct rq_fpml_product_fxsimpleoption *)product_data;    int status = 0;    rq_stream_write_string(output_stream, "<fxSimpleOption>");    /* <productType productTypeScheme = "http://www.markets.Reuters.com/rss/spec/2001/product-type-1-0">Delta-Put-FX-Option</productType> */    rq_stream_write_string(output_stream, "<buyerPartyReference href=\"");    rq_stream_write_string(output_stream, "\"/>");    rq_stream_write_string(output_stream, "<sellerPartyReference href=\"");    rq_stream_write_string(output_stream, "\"/>");    rq_stream_write_string(output_stream, "<expiryDateTime>");    rq_stream_write_string(output_stream, "<expiryDate>2002-06-04</expiryDate>");    rq_stream_write_string(output_stream, "<hourMinuteTime>1400</hourMinuteTime>");    rq_stream_write_string(output_stream, "<businessCenter id=\"\" businessCenterScheme=\"http://www.markets.Reuters.com/rss/spec/2001/business-center-1-0\"></businessCenter>");    rq_stream_write_string(output_stream, "<cutName>New York</cutName>");    rq_stream_write_string(output_stream, "</expiryDateTime>");    rq_stream_write_string(output_stream, "<exerciseStyle>European</exerciseStyle>");    rq_stream_write_string(output_stream, "<fxOptionPremium>");    rq_stream_write_string(output_stream, "<payerPartyReference href=\"\"/>");    rq_stream_write_string(output_stream, "<receiverPartyReference href=\"\"/>");    rq_stream_write_string(output_stream, "<premiumAmount type=\"Money\">");    rq_stream_write_string(output_stream, "<currency>USD</currency>");    rq_stream_write_string(output_stream, "<amount>36900</amount>");    rq_stream_write_string(output_stream, "</premiumAmount>");    rq_stream_write_string(output_stream, "<premiumSettlementDate>2001-12-06</premiumSettlementDate>");    rq_stream_write_string(output_stream, "</fxOptionPremium>");    rq_stream_write_string(output_stream, "<valueDate>2002-06-06</valueDate>");    rq_stream_write_string(output_stream, "<putCurrencyAmount>");    rq_stream_write_string(output_stream, "<currency>AUD</currency>");    rq_stream_write_string(output_stream, "<amount>75000000</amount>");    rq_stream_write_string(output_stream, "</putCurrencyAmount>");    rq_stream_write_string(output_stream, "<callCurrencyAmount>");    rq_stream_write_string(output_stream, "<currency>USD</currency>");    rq_stream_write_string(output_stream, "<amount>36900000</amount>");    rq_stream_write_string(output_stream, "</callCurrencyAmount>");    rq_stream_write_string(output_stream, "<fxStrikePrice>");    rq_stream_write_string(output_stream, "<rate>0.4920</rate>");    rq_stream_write_string(output_stream, "<strikeQuoteBasis>CALLCURRENCYPERPUTCURRENCY</strikeQuoteBasis>");    rq_stream_write_string(output_stream, "</fxStrikePrice>");    rq_stream_write_string(output_stream, "<quotedAs>");    rq_stream_write_string(output_stream, "<optionOnCurrency>AUD</optionOnCurrency>");    rq_stream_write_string(output_stream, "<faceOnCurrency>USD</faceOnCurrency>");    rq_stream_write_string(output_stream, "<quotedTenor>");    rq_stream_write_string(output_stream, "<periodMultiplier>6</periodMultiplier>");    rq_stream_write_string(output_stream, "<period>M</period>");    rq_stream_write_string(output_stream, "</quotedTenor>");    rq_stream_write_string(output_stream, "</quotedAs>");    rq_stream_write_string(output_stream, "</fxSimpleOption>");    return status;}rq_fpml_product_t rq_fpml_product_fxsimpleoption_alloc(){    struct rq_fpml_product_fxsimpleoption *p =         (struct rq_fpml_product_fxsimpleoption *)calloc(1, sizeof(struct rq_fpml_product_fxsimpleoption));    rq_fpml_product_t product = _rq_fpml_product_alloc(        rq_fpml_product_fxsimpleoption_product_type,        p,        rq_fpml_product_fxsimpleoption_write_xml,        rq_fpml_product_fxsimpleoption_free        );    return product;}const char *rq_fpml_product_fxsimpleoption_get_buyer_party_id(rq_fpml_product_t product){    struct rq_fpml_product_fxsimpleoption *p =         (struct rq_fpml_product_fxsimpleoption *)_rq_fpml_product_get_product_data(product);    return p->buyer_party_id;}void rq_fpml_product_fxsimpleoption_set_buyer_party_id(rq_fpml_product_t product, const char *buyer_party_id){    struct rq_fpml_product_fxsimpleoption *p =         (struct rq_fpml_product_fxsimpleoption *)_rq_fpml_product_get_product_data(product);    if (p->buyer_party_id)        free((char *)p->buyer_party_id);    p->buyer_party_id = (const char *)strdup(buyer_party_id);}const char *rq_fpml_product_fxsimpleoption_get_seller_party_id(rq_fpml_product_t product){    struct rq_fpml_product_fxsimpleoption *p =         (struct rq_fpml_product_fxsimpleoption *)_rq_fpml_product_get_product_data(product);    return p->seller_party_id;}void rq_fpml_product_fxsimpleoption_set_seller_party_id(rq_fpml_product_t product, const char *seller_party_id){    struct rq_fpml_product_fxsimpleoption *p =         (struct rq_fpml_product_fxsimpleoption *)_rq_fpml_product_get_product_data(product);    if (p->seller_party_id)        free((char *)p->seller_party_id);    p->seller_party_id = (const char *)strdup(p->seller_party_id);}struct rq_fpml_expiry_date_time *rq_fpml_product_fxsimpleoption_get_expiry_date_time(rq_fpml_product_t product){    struct rq_fpml_product_fxsimpleoption *p =         (struct rq_fpml_product_fxsimpleoption *)_rq_fpml_product_get_product_data(product);    return &p->expiry_date_time;}void rq_fpml_product_fxsimpleoption_set_expiry_date_time(rq_fpml_product_t product, rq_date expiry_date, short hour_minute, const char *business_center_id, const char *cut_name){    struct rq_fpml_product_fxsimpleoption *p =         (struct rq_fpml_product_fxsimpleoption *)_rq_fpml_product_get_product_data(product);    rq_fpml_expiry_date_time_fill(&p->expiry_date_time, expiry_date, hour_minute, business_center_id, cut_name);}enum rq_exercise_style rq_fpml_product_fxsimpleoption_get_exercise_style(rq_fpml_product_t product){    struct rq_fpml_product_fxsimpleoption *p =         (struct rq_fpml_product_fxsimpleoption *)_rq_fpml_product_get_product_data(product);    return p->exercise_style;}void rq_fpml_product_fxsimpleoption_set_exercise_style(rq_fpml_product_t product, enum rq_exercise_style exercise_style){    struct rq_fpml_product_fxsimpleoption *p =         (struct rq_fpml_product_fxsimpleoption *)_rq_fpml_product_get_product_data(product);    p->exercise_style = exercise_style;}rq_date rq_fpml_product_fxsimpleoption_get_value_date(rq_fpml_product_t product){    struct rq_fpml_product_fxsimpleoption *p =         (struct rq_fpml_product_fxsimpleoption *)_rq_fpml_product_get_product_data(product);    return p->value_date;}void rq_fpml_product_fxsimpleoption_set_value_date(rq_fpml_product_t product, rq_date value_date){    struct rq_fpml_product_fxsimpleoption *p =         (struct rq_fpml_product_fxsimpleoption *)_rq_fpml_product_get_product_data(product);    p->value_date = value_date;}struct rq_fpml_money *rq_fpml_product_fxsimpleoption_get_put_currency_amount(rq_fpml_product_t product){    struct rq_fpml_product_fxsimpleoption *p =         (struct rq_fpml_product_fxsimpleoption *)_rq_fpml_product_get_product_data(product);    return &p->put_currency_amount;}void rq_fpml_product_fxsimpleoption_set_put_currency_amount(rq_fpml_product_t product, const char *currency, double amount){    struct rq_fpml_product_fxsimpleoption *p =         (struct rq_fpml_product_fxsimpleoption *)_rq_fpml_product_get_product_data(product);    rq_fpml_money_fill(&p->put_currency_amount, currency, amount);}struct rq_fpml_money *rq_fpml_product_fxsimpleoption_get_call_currency_amount(rq_fpml_product_t product){    struct rq_fpml_product_fxsimpleoption *p =         (struct rq_fpml_product_fxsimpleoption *)_rq_fpml_product_get_product_data(product);    return &p->call_currency_amount;}void rq_fpml_product_fxsimpleoption_set_call_currency_amount(rq_fpml_product_t product, const char *currency, double amount){    struct rq_fpml_product_fxsimpleoption *p =         (struct rq_fpml_product_fxsimpleoption *)_rq_fpml_product_get_product_data(product);    rq_fpml_money_fill(&p->call_currency_amount, currency, amount);}struct rq_fpml_fx_strike_price *rq_fpml_product_fxsimpleoption_get_strike_price(rq_fpml_product_t product){    struct rq_fpml_product_fxsimpleoption *p =         (struct rq_fpml_product_fxsimpleoption *)_rq_fpml_product_get_product_data(product);    return &p->strike_price;}void rq_fpml_product_fxsimpleoption_set_strike_price(rq_fpml_product_t product, double rate, enum rq_strike_quote_basis strike_quote_basis){    struct rq_fpml_product_fxsimpleoption *p =         (struct rq_fpml_product_fxsimpleoption *)_rq_fpml_product_get_product_data(product);    rq_fpml_fx_strike_price_fill(&p->strike_price, rate, strike_quote_basis);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -