fix协议介绍16-查询叮当(quote)

本文介绍FIX协议中报价消息(Quote)的结构与字段含义,包括标准头部、报价标识符、报价类型等,并提供了一个Java实现示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

FIX.5.0SP2 Message

Quote [type 'S']

<Quot>

The Quote message is used as the response to a Quote Request or a Quote Response message in both indicative, tradeable, and restricted tradeable quoting markets.


Added  FIX.4.0

Expand Components | Collapse Components

  Field or Component Field Name FIXML name Req'd Comments Depr.
Component StandardHeader BaseHeader

MsgType = S

 
131 QuoteReqID @ReqID  

Required when quote is in response to a Quote Request message

 
117 QuoteID @QID    
1166 QuoteMsgID @QtMsgID  

Optionally used to supply a message identifier for a quote.

 
693 QuoteRespID @RspID  

Required when responding to the Quote Response message. The counterparty specified ID of the Quote Response message.

 
537 QuoteType @Typ  

Quote Type

If not specified, the default is an indicative quote

 
1171 PrivateQuote @PrvtQt  

Used to indicate whether a private negotiation is requested or if the response should be public. Only relevant in markets supporting both Private and Public quotes. If field is not provided in message, the model used must be bilaterally agreed.

 
Component QuotQualGrp QuotQual      
301 QuoteResponseLevel @RspLvl  

Level of Response requested from receiver of quote messages.

 
Component Parties Pty  

Insert here the set of "Parties" (firm identification) fields defined in "Common Components of Application Messages"

 
336 TradingSessionID @SesID      
625 TradingSessionSubID @SesSub      
Component Instrument Instrmt

Insert here the set of "Instrument" (symbology) fields defined in "Common Components of Application Messages"

 
Component FinancingDetails FinDetls  

Insert here the set of "FinancingDetails" (symbology) fields defined in "Common Components of Application Messages"

 
Component UndInstrmtGrp Undly  

Number of underlyings

 
54 Side @Side  

Required for Tradeable or Counter quotes of single instruments

 
Component OrderQtyData OrdQty  

Required for Tradeable quotes or Counter quotes of single instruments

 
63 SettlType @SettlTyp      
64 SettlDate @SettlDt  

Can be used with forex quotes to specify a specific "value date".

For NDFs this is required.

 
193 SettlDate2 @SettlDt2  

Can be used with OrdType = "Forex - Swap" to specify the "value date" for the future portion of a F/X swap.

FIX.5.0
192 OrderQty2 @Qty2  

Can be used with OrdType = "Forex - Swap" to specify the order quantity for the future portion of a F/X swap.

FIX.5.0
15 Currency @Ccy  

Can be used to specify the currency of the quoted prices. May differ from the 'normal' trading currency of the instrument being quoted

 
120 SettlCurrency @SettlCcy  

Required for NDFs to specify the settlement currency (fixing currency).

 
Component RateSource RtSrc      
Component Stipulations Stip  

Insert here the set of "Stipulations" (repeating group of Fixed Income stipulations) fields defined in "Common Components of Application Messages"

 
1 Account @Acct      
660 AcctIDSource @AcctIDSrc      
581 AccountType @AcctTyp  

Type of account associated with the order (Origin)

 
Component LegQuotGrp Quot  

Required for multileg quotes

 
132 BidPx @BidPx  

If F/X quote, should be the "all-in" rate (spot rate adjusted for forward points). Note that either BidPx, OfferPx or both must be specified.

 
133 OfferPx @OfrPx  

If F/X quote, should be the "all-in" rate (spot rate adjusted for forward points). Note that either BidPx, OfferPx or both must be specified.

 
645 MktBidPx @MktBidPx  

Can be used by markets that require showing the current best bid and offer

 
646 MktOfferPx @MktOfrPx  

Can be used by markets that require showing the current best bid and offer

 
647 MinBidSize @MinBidSz  

Specifies the minimum bid size. Used for markets that use a minimum and maximum bid size.

 
134 BidSize @BidSz  

Specifies the bid size. If MinBidSize is specified, BidSize is interpreted to contain the maximum bid size.

 
648 MinOfferSize @MinOfrSz  

Specifies the minimum offer size. If MinOfferSize is specified, OfferSize is interpreted to contain the maximum offer size.

 
135 OfferSize @OfrSz  

Specified the offer size. If MinOfferSize is specified, OfferSize is interpreted to contain the maximum offer size.

 
110 MinQty @MinQty  

For use in private/directed quote negotiations.

 
62 ValidUntilTime @ValidUntilTm  

The time when the quote will expire

 
188 BidSpotRate @BidSpotRt  

May be applicable for F/X quotes

 
190 OfferSpotRate @OfrSpotRt  

May be applicable for F/X quotes

 
189 BidForwardPoints @BidFwdPnts  

May be applicable for F/X quotes

 
191 OfferForwardPoints @OfrFwdPnts  

May be applicable for F/X quotes

 
1065 BidSwapPoints @BidSwapPnts  

Bid swap points of an FX Swap quote.

 
1066 OfferSwapPoints @OfrSwapPnts      
631 MidPx @MidPx      
632 BidYield @BidYld      
633 MidYield @MidYld      
634 OfferYield @OfrYld      
60 TransactTime @TxnTm      
40 OrdType @OrdTyp  

Can be used to specify the type of order the quote is for

 
642 BidForwardPoints2 @BidFwdPnts2  

Bid F/X forward points of the future portion of a F/X swap quote added to spot rate. May be a negative value

FIX.5.0
643 OfferForwardPoints2 @OfrFwdPnts2  

Offer F/X forward points of the future portion of a F/X swap quote added to spot rate. May be a negative value

FIX.5.0
656 SettlCurrBidFxRate @SettlCurrBidFxRt  

Can be used when the quote is provided in a currency other than the instrument's 'normal' trading currency. Applies to all bid prices contained in this quote message

 
657 SettlCurrOfferFxRate @SettlCurrOfrFxRt  

Can be used when the quote is provided in a currency other than the instrument's 'normal' trading currency. Applies to all offer prices contained in this quote message

 
156 SettlCurrFxRateCalc @SettlCurrFxRtCalc  

Can be used when the quote is provided in a currency other than the instruments trading currency.

 
13 CommType @CommTyp  

Can be used to show the counterparty the commission associated with the transaction.

 
12 Commission @Comm  

Can be used to show the counterparty the commission associated with the transaction.

 
582 CustOrderCapacity @CustCpcty  

For Futures Exchanges

 
100 ExDestination @ExDest  

Used when routing quotes to multiple markets

 
1133 ExDestinationIDSource @ExDestIDSrc      
775 BookingType @BkngTyp      
528 OrderCapacity @Cpcty      
529 OrderRestrictions @Rstctions      
423 PriceType @PxTyp      
Component SpreadOrBenchmarkCurveData SprdBnchmkCurve      
Component YieldData Yield      
58 Text @Txt      
354 EncodedTextLen @EncTxtLen  

Must be set if EncodedText field is specified and must immediately precede it.

 
355 EncodedText @EncTxt  

Encoded (non-ASCII characters) representation of the Text field in the encoded format specified via the MessageEncoding field.

 
Component StandardTrailer      



消息实现:

package cs.mina.codec.msg;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

import cs.mina.exception.InValidDataException;

/*
 *@author(huangxiaoping)
 *@date 2013-11-30
 */
public class QuoteMsg extends BaseMsg {
	private Tag parties = new PartiesTag(false);
	private Tag instrument = new InstrumentTag(true);
	private Tag bidID = new Tag("390", "String", false);
	private Tag offerID = new Tag("1867", "String", false);
	private Tag quoteType = new Tag("537", "int", false);
	private Tag side = new Tag("54", "char", false);
	private Tag bidSize = new Tag("134", "Qty", false);
	private Tag offerSize = new Tag("135", "Qty", false);
	private Tag bidPx = new Tag("132", "Price", false);
	private Tag offerPx = new Tag("133", "Price", false);
	private Tag transactTime = new Tag("60", "UTCTimestamp", true);
	private Tag positionEffect = new Tag("77", "char", false);
	private Tag orderRestrictions = new Tag("529", "MultipleCharValue", false);
	private Tag text = new Tag("58", "String", false);
	private Tag valueChecksGrp = new ValueChecksGrpTag(false);

	private Set<String> tagIdsSet = new HashSet<String>();

	public QuoteMsg() {
		this.getHeadEntity().getMsgType().setTagValue("S");
		tagIdsSet.add("390");
		tagIdsSet.add("1867");
		tagIdsSet.add("537");
		tagIdsSet.add("54");
		tagIdsSet.add("134");
		tagIdsSet.add("135");
		tagIdsSet.add("132");
		tagIdsSet.add("133");
		tagIdsSet.add("60");
		tagIdsSet.add("77");
		tagIdsSet.add("529");
		tagIdsSet.add("58");
		this.bodyEntity.getBodyTagList().add(parties);
		this.bodyEntity.getBodyTagList().add(instrument);
		this.bodyEntity.getBodyTagList().add(bidID);
		this.bodyEntity.getBodyTagList().add(offerID);
		this.bodyEntity.getBodyTagList().add(quoteType);
		this.bodyEntity.getBodyTagList().add(side);
		this.bodyEntity.getBodyTagList().add(bidSize);
		this.bodyEntity.getBodyTagList().add(offerSize);
		this.bodyEntity.getBodyTagList().add(bidPx);
		this.bodyEntity.getBodyTagList().add(offerPx);
		this.bodyEntity.getBodyTagList().add(transactTime);
		this.bodyEntity.getBodyTagList().add(positionEffect);
		this.bodyEntity.getBodyTagList().add(orderRestrictions);
		this.bodyEntity.getBodyTagList().add(text);
		this.bodyEntity.getBodyTagList().add(valueChecksGrp);
	}

	@Override
	public void decodeBody() {

	}

	@Override
	public void validate() {
		this.headEntity.validate();
		List<Tag> bodyTagList = this.bodyEntity.getBodyTagList();
		for (int i = 0; i < bodyTagList.size(); i++) {
			bodyTagList.get(i).validate();
		}
		this.tailerEntity.validate();
		if (quoteType.getTagValue() != null) {
			if (!(Integer.parseInt(quoteType.getTagValue()) >= 0 && Integer
					.parseInt(quoteType.getTagValue()) <= 3)) {
				throw new InValidDataException("quoteType错误["
						+ quoteType.getTagId() + "=" + quoteType.getTagValue()
						+ "]");
			}
		}
		if (side.getTagValue() != null) {
			if (!MsgUtil.side.contains(side.getTagValue())) {
				throw new InValidDataException("side错误[" + side.getTagId()
						+ "=" + side.getTagValue() + "]");
			}
		}
		if (positionEffect.getTagValue() != null) {
			if (!MsgUtil.positionEffect.contains(positionEffect.getTagValue())) {
				throw new InValidDataException("positionEffect错误["
						+ positionEffect.getTagId() + "="
						+ positionEffect.getTagValue() + "]");
			}
		}
	}

	public Tag getParties() {
		return parties;
	}

	public void setParties(Tag parties) {
		this.parties = parties;
	}

	public Tag getInstrument() {
		return instrument;
	}

	public void setInstrument(Tag instrument) {
		this.instrument = instrument;
	}

	public Tag getBidID() {
		return bidID;
	}

	public void setBidID(Tag bidID) {
		this.bidID = bidID;
	}

	public Tag getOfferID() {
		return offerID;
	}

	public void setOfferID(Tag offerID) {
		this.offerID = offerID;
	}

	public Tag getQuoteType() {
		return quoteType;
	}

	public void setQuoteType(Tag quoteType) {
		this.quoteType = quoteType;
	}

	public Tag getSide() {
		return side;
	}

	public void setSide(Tag side) {
		this.side = side;
	}

	public Tag getBidSize() {
		return bidSize;
	}

	public void setBidSize(Tag bidSize) {
		this.bidSize = bidSize;
	}

	public Tag getOfferSize() {
		return offerSize;
	}

	public void setOfferSize(Tag offerSize) {
		this.offerSize = offerSize;
	}

	public Tag getBidPx() {
		return bidPx;
	}

	public void setBidPx(Tag bidPx) {
		this.bidPx = bidPx;
	}

	public Tag getOfferPx() {
		return offerPx;
	}

	public void setOfferPx(Tag offerPx) {
		this.offerPx = offerPx;
	}

	public Tag getTransactTime() {
		return transactTime;
	}

	public void setTransactTime(Tag transactTime) {
		this.transactTime = transactTime;
	}

	public Tag getPositionEffect() {
		return positionEffect;
	}

	public void setPositionEffect(Tag positionEffect) {
		this.positionEffect = positionEffect;
	}

	public Tag getOrderRestrictions() {
		return orderRestrictions;
	}

	public void setOrderRestrictions(Tag orderRestrictions) {
		this.orderRestrictions = orderRestrictions;
	}

	public Tag getText() {
		return text;
	}

	public void setText(Tag text) {
		this.text = text;
	}

	public Tag getValueChecksGrp() {
		return valueChecksGrp;
	}

	public void setValueChecksGrp(Tag valueChecksGrp) {
		this.valueChecksGrp = valueChecksGrp;
	}

	public Set<String> getTagIdsSet() {
		return tagIdsSet;
	}

	public void setTagIdsSet(Set<String> tagIdsSet) {
		this.tagIdsSet = tagIdsSet;
	}

}

消息处理:略




### FIX协议中的资金查询实现 FIX(Financial Information eXchange)协议是一种广泛应用于金融行业的消息传递标准,主要用于支持电子化证券交易和其他金融市场活动。以下是关于FIX协议中资金查询的实现方式及其解决方案。 #### 1. 资金查询的消息类型 在FIX协议中,通常使用 `Request For Positions (U3)` 或 `Position Maintenance Request (AF)` 消息来发起资金或头寸查询请求[^1]。这些消息允许交易方请求特定账户的资金状态或其他相关信息。具体来说: - **`PosReqID` 字段**:用于唯一标识资金查询请求。 - **`Account` 字段**:指定需要查询资金的账户编号。 - **`Currency` 字段**:定义查询所涉及的货币种类。 ```plaintext 8=FIX.4.4|9=XXX|35=U3|34=X|49=SenderCompID|56=TargetCompID|52=SendingTime| 70=PosReqID|553=Username|554=Password|58=Text|537=SubscriptionRequestType| 555=NoRelatedSym|460=ClearingBusinessDate|581=SettlSessID|75=TradeDate| 589=TransactTime|530=PosMaintRptRefID|70=PosReqTyp|55=CUSIP|167=SecurityType| 207=Exchange|54=B/SIndicator|58=FreeText|10=CheckSum| ``` 以上是一个典型的FIX消息结构示例,其中包含了必要的字段以满足资金查询需求。 #### 2. 响应机制 当接收方收到资金查询请求后,会通过 `Positions Report (U4)` 消息返回响应。此消息包含以下关键字段: - **`PosMaintStatus` 字段**:指示位置维护的状态(成功、失败等)。 - **`CashBalance` 字段**:提供账户当前现金余额的具体数值。 - **`NetGrossInd` 字段**:表明显示的是净额还是总额。 #### 3. 示例代码 下面是一段基于Python的简单代码片段,展示如何构建并发送一个FIX资金查询请求: ```python import quickfix as fix class Application(fix.Application): def create_position_request(self, account_id, currency_code): message = fix.Message() header = message.getHeader() # 设置基本头部信息 header.setField(fix.BeginString("FIX.4.4")) header.setField(fix.MsgType("U3")) # Position Request Message Type # 添加主体部分 message.setField(fix.PosReqID("UniqueRequestId123")) message.setField(fix.Account(account_id)) message.setField(fix.Currency(currency_code)) return message app = Application() request_message = app.create_position_request("ClientAccount1", "USD") print(request_message.toString()) ``` 这段代码展示了如何利用QuickFIX库创建一个符合FIX协议规范的资金查询请求消息。 #### 4. 性能与安全注意事项 根据之前提到的服务设计原则,在实施FIX协议的资金查询功能时需特别关注以下几个方面: - 数据源选择:避免直接访问主数据库,推荐采用读取从属数据库的方式减少压力[^1]。 - 批量处理策略:考虑分时间段批量执行操作以优化性能表现。 - 测试覆盖范围:进行全面的压力测试和技术验证确保系统的稳定性和可靠性。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

hxpjava1

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值