#[macro_export]
macro_rules! fix_enum {
(
$enum_name:ident ( $tag_num:literal ) {
$($variant:ident = $str_val:literal),* $(,)?
}
) => {
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum $enum_name {
$($variant),*
}
impl std::str::FromStr for $enum_name {
type Err = $crate::FixError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
$( $str_val => Ok($enum_name::$variant), )*
_ => Err($crate::FixError::invalid_enum_value($tag_num, stringify!($enum_name))),
}
}
}
impl $enum_name {
pub fn as_str(&self) -> &str {
match self {
$( $enum_name::$variant => $str_val, )*
}
}
}
impl $crate::AsFixStr for $enum_name {
fn as_fix_str(&self) -> &'static str {
match self {
$( $enum_name::$variant => $str_val, )*
}
}
}
impl $crate::FixTaggedValue for $enum_name {
const TAG: u32 = $tag_num;
}
impl $crate::FixTaggedValue for &$enum_name {
const TAG: u32 = $tag_num;
}
impl $crate::FixTaggedValue for &mut $enum_name {
const TAG: u32 = $tag_num;
}
impl $crate::FixValue for &$enum_name {
#[inline]
fn encode(&self, out: &mut Vec<u8>) {
out.extend_from_slice((*self).as_str().as_bytes());
}
}
impl $crate::FixValue for &mut $enum_name {
#[inline]
fn encode(&self, out: &mut Vec<u8>) {
out.extend_from_slice((*self).as_str().as_bytes());
}
}
impl From<$enum_name> for String {
fn from(e: $enum_name) -> String {
e.as_str().to_string()
}
}
impl std::fmt::Display for $enum_name {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(self.as_str())
}
}
};
}
pub use crate::fix_enum;
fix_enum! {
ExecTransType(20) {
New = "0",
Cancel = "1",
Correct = "2",
Status = "3",
}}
fix_enum! {
HandlInst(21) {
Automated = "1",
AutomatedPublicBrokerInterventionOk = "2",
Manual = "3",
}}
fix_enum! {
SecurityIDSource(22) {
CUSIP = "1",
SEDOL = "2",
QUIK = "3",
ISIN = "4",
RIC = "5",
ISOCurrencyCode = "6",
ISOCountryCode = "7",
ExchangeSymbol = "8",
CTASymbol = "9",
BloombergSymbol = "A",
Wertpapier = "B",
Dutch = "C",
Valoren = "D",
Sicovam = "E",
Belgian = "F",
Common = "G",
ClearingHouse = "H",
ISDAFpMLProductSpecification = "I",
OPRA = "J",
}}
fix_enum! {
MsgType(35){
Heartbeat = "0",
TestRequest = "1",
ResendRequest = "2",
Reject = "3",
SequenceReset = "4",
Logout = "5",
IndicationOfInterest = "6",
Advertisement = "7",
ExecutionReport = "8",
OrderCancelReject = "9",
Logon = "A",
News = "B",
Email = "C",
NewOrderSingle = "D",
NewOrderList = "E",
OrderCancelRequest = "F",
OrderCancelReplaceRequest = "G",
OrderStatusRequest = "H",
AllocationInstruction = "J",
ListCancelRequest = "K",
ListExecute = "L",
ListStatusRequest = "M",
ListStatus = "N",
AllocationInstructionAcknowledgement = "P",
DontKnowTrade = "Q",
QuoteRequest = "R",
Quote = "S",
SettlementInstructions = "T",
MarketDataRequest = "V",
MarketDataSnapshotFullRefresh = "W",
MarketDataIncrementalRefresh = "X",
MarketDataRequestReject = "Y",
QuoteCancel = "Z",
QuoteStatusRequest = "a",
MassQuoteAcknowledgement = "b",
SecurityDefinitionRequest = "c",
SecurityDefinition = "d",
SecurityStatusRequest = "e",
SecurityStatus = "f",
TradingSessionStatusRequest = "g",
TradingSessionStatus = "h",
MassQuote = "i",
BusinessMessageReject = "j",
BidRequest = "k",
BidResponse = "l",
ListStrikePrice = "m",
XMLMessage = "n",
RegistrationInstructions = "o",
RegistrationInstructionsResponse = "p",
OrderMassCancelRequest = "q",
OrderMassCancelReport = "r",
NewOrderCross = "s",
CrossOrderCancelReplaceRequest = "t",
CrossOrderCancelRequest = "u",
SecurityTypeRequest = "v",
SecurityTypes = "w",
SecurityListRequest = "x",
SecurityList = "y",
DerivativeSecurityListRequest = "z",
}}
fix_enum! {
OrdStatus(39) {
New = "0",
PartiallyFilled = "1",
Filled = "2",
DoneForDay = "3",
Canceled = "4",
Replaced = "5",
PendingCancel = "6",
Stopped = "7",
Rejected = "8",
Suspended = "9",
PendingNew = "A",
Calculated = "B",
Expired = "C",
}}
fix_enum! {
OrdType(40) {
Market = "1",
Limit = "2",
Stop = "3",
StopLimit = "4",
WithOrWithout = "6",
LimitOrBetter = "7",
LimitWithOrWithout = "8",
OnBasis = "9",
PreviouslyQuoted = "D",
PreviouslyIndicated = "E",
ForexSwap = "G",
Funari = "I",
MarketIfTouched = "J",
MarketWithLeftoverAsLimit = "K",
}}
fix_enum! {
Side(54){
Buy = "1",
Sell = "2",
}}
fix_enum! {
TimeInForce(59) {
Day = "0",
GoodTillCancel = "1",
AtTheOpening = "2",
ImmediateOrCancel = "3",
FillOrKill = "4",
GoodTillCrossing = "5",
GoodTillDate = "6",
AtTheClose = "7",
}}
fix_enum! {
GapFillFlag(123){
Yes = "Y",
No = "N",
}}
fix_enum! {
ResetSeqNumFlag(141){
Yes = "Y",
No = "N",
}}
fix_enum! {
ExecType(150) {
New = "0",
PartialFill = "1",
Fill = "2",
DoneForDay = "3",
Canceled = "4",
Replaced = "5",
PendingCancel = "6",
Stopped = "7",
Rejected = "8",
Suspended = "9",
PendingNew = "A",
Calculated = "B",
Expired = "C",
Restated = "D",
PendingReplace = "E",
Trade = "F",
TradeCorrect = "G",
TradeCancel = "H",
OrderStatus = "I",
}}
fix_enum! {
SecurityType(167) {
Agency = "AGENCY",
EuroSupranationalCoupons = "EUSUPRA",
FederalAgencyCoupon = "FAC",
FederalAgencyDiscountNote = "FADN",
PrivateExportFunding = "PEF",
UsdSupranationalCoupons = "SUPRA",
Future = "FUT",
Option = "OPT",
CorporateBond = "CORP",
CorporatePrivatePlacement = "CPP",
ConvertibleBond = "CB",
DualCurrency = "DUAL",
EuroCorporateBond = "EUCORP",
IndexedLinked = "XLINKD",
StructuredNotes = "STRUCT",
YankeeCorporateBond = "YANK",
ForeignExchangeContract = "FOR",
CommonStock = "CS",
PreferredStock = "PS",
BradyBond = "BRADY",
EuroSovereigns = "EUSOV",
UsTreasuryBond = "TBOND",
InterestStrip = "TINT",
TreasuryInflationProtectedSecurities= "TIPS",
PrincipalStripCallable = "TCAL",
PrincipalStripNonCallable = "TPRN",
UsTreasuryNoteDeprecated = "UST",
UsTreasuryBillDeprecated = "USTB",
UsTreasuryNote = "TNOTE",
UsTreasuryBill = "TBILL",
Repurchase = "REPO",
Forward = "FORWARD",
BuySellback = "BUYSELL",
SecuritiesLoan = "SECLOAN",
SecuritiesPledge = "SECPLEDGE",
TermLoan = "TERM",
RevolverLoan = "RVLV",
RevolverTermLoan = "RVLVTRM",
BridgeLoan = "BRIDGE",
LetterOfCredit = "LOFC",
SwingLineFacility = "SWING",
DebtorInPossession = "DINP",
Defaulted = "DEFLTED",
Withdrawn = "WITHDRN",
Replaced = "REPLACD",
Matured = "MATURED",
AmendedAndRestated = "AMENDED",
Retired = "RETIRED",
BankersAcceptance = "BA",
BankNotes = "BN",
BillOfExchanges = "BOX",
CertificateOfDeposit = "CD",
CallLoans = "CL",
CommercialPaper = "CP",
DepositNotes = "DN",
EuroCertificateOfDeposit = "EUCD",
EuroCommercialPaper = "EUCP",
LiquidityNote = "LQN",
MediumTermNotes = "MTN",
Overnight = "ONITE",
PromissoryNote = "PN",
PlazosFijos = "PZFJ",
ShortTermLoanNote = "STN",
TimeDeposit = "TD",
ExtendedCommNote = "XCN",
YankeeCertificateOfDeposit = "YCD",
AssetBackedSecurities = "ABS",
CorporateMortgageBackedSecurities = "CMBS",
CollateralizedMortgageObligation = "CMO",
IOETTEMortgage = "IET",
MortgageBackedSecurities = "MBS",
MortgageInterestOnly = "MIO",
MortgagePrincipalOnly = "MPO",
MortgagePrivatePlacement = "MPP",
MiscellaneousPassThrough = "MPT",
Pfandbriefe = "PFAND",
ToBeAnnounced = "TBA",
OtherAnticipationNotes = "AN",
CertificateOfObligation = "COFO",
CertificateOfParticipation = "COFP",
GeneralObligationBonds = "GO",
MandatoryTender = "MT",
RevenueAnticipationNote = "RAN",
RevenueBonds = "REV",
SpecialAssessment = "SPCLA",
SpecialObligation = "SPCLO",
SpecialTax = "SPCLT",
TaxAnticipationNote = "TAN",
TaxAllocation = "TAXA",
TaxExemptCommercialPaper = "TECP",
TaxRevenueAnticipationNote = "TRAN",
VariableRateDemandNote = "VRDN",
Warrant = "WAR",
MutualFund = "MF",
MultiLegInstrument = "MLEG",
NoSecurityType = "NONE",
Wildcard = "?",
}}
fix_enum! {
SubscriptionRequestType(263){
Snapshot = "0",
Subscribe = "1",
Unsubscribe = "2"
}}
fix_enum! {
MDUpdateType (265){
FullRefresh = "0",
IncrementalRefresh = "1",
}}
fix_enum! {
MDEntryType(269) {
Bid = "0",
Offer = "1",
Trade = "2",
IndexValue = "3",
OpeningPrice = "4",
ClosingPrice = "5",
SettlementPrice = "6",
TradingSessionHighPrice = "7",
TradingSessionLowPrice = "8",
TradingSessionVWAPPrice = "9",
Imbalance = "A",
TradeVolume = "B",
OpenInterest = "C",
}}
fix_enum! {
MDUpdateAction(279){
New = "0",
Change = "1",
Delete = "2",
}}
fix_enum! {
MDReqRejReason(281){
UnknownSymbol = "0",
DuplicateMDReqID = "1",
InsufficientBandwidth = "2",
InsufficientPermissions = "3",
UnsupportedSubscriptionRequestType = "4",
UnsupportedMarketDepth = "5",
UnsupportedMDUpdateType = "6",
UnsupportedAggregatedBook = "7",
UnsupportedMDEntryType = "8",
UnsupportedTradingSessionID = "9",
UnsupportedScope = "A",
UnsupportedOpenCloseSettlFlag = "B",
UnsupportedMDImplicitDelete = "C",
Insufficientcredit = "D",
}}
fix_enum! {
SecurityRequestType(321) {
RequestSecurityIdentityAndSpecifications = "0",
RequestSecurityIdentityForProvidedSpecifications = "1",
RequestListSecurityTypes = "2",
RequestListSecurities = "3",
}}
fix_enum! {
SecurityResponseType(323) {
AcceptSecurityProposalAsIs = "1",
AcceptSecurityProposalWithRevisions = "2",
ListOfSecurityTypesReturned = "3", ListOfSecuritiesReturned = "4", RejectSecurityProposal = "5",
CannotMatchSelectionCriteria = "6",
}}
fix_enum! {
SessionRejectReason(373) {
InvalidTagNumber = "0",
RequiredTagMissing = "1",
TagNotDefinedForThisMessageType = "2",
UndefinedTag = "3",
TagSpecifiedWithoutValue = "4",
ValueIsIncorrectForThisTag = "5",
IncorrectDataFormatForValue = "6",
DecryptionProblem = "7",
SignatureProblem = "8",
CompIDProblem = "9",
SendingTimeAccuracyProblem = "10",
InvalidMsgType = "11",
XMLValidationError = "12",
TagAppearsMoreThanOnce = "13",
TagSpecifiedOutOfRequiredOrder = "14",
RepeatingGroupFieldsOutOfOrder = "15",
IncorrectNumInGroupCount = "16",
NonDataValueIncludesFieldDelimiter = "17",
Other = "99",
}}
fix_enum! {
CxlRejResponseTo (434) {
CancelRequest = "1",
ReplaceRequest = "2",
}}