Skip to content

Commit

Permalink
cleanup IField-derived classes
Browse files Browse the repository at this point in the history
  • Loading branch information
gbirchmeier committed Sep 25, 2024
1 parent a1f294f commit b6ab1b5
Show file tree
Hide file tree
Showing 25 changed files with 937 additions and 1,029 deletions.
36 changes: 18 additions & 18 deletions Examples/Executor/Executor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void OnMessage(QuickFix.FIX40.NewOrderSingle n, SessionID s)
{
case OrdType.LIMIT:
price = n.Price;
if (price.Obj == 0)
if (price.Value == 0)
throw new IncorrectTagValue(price.Tag);
break;
case OrdType.MARKET: break;
Expand Down Expand Up @@ -105,7 +105,7 @@ public void OnMessage(QuickFix.FIX41.NewOrderSingle n, SessionID s)
{
case OrdType.LIMIT:
price = n.Price;
if (price.Obj == 0)
if (price.Value == 0)
throw new IncorrectTagValue(price.Tag);
break;
case OrdType.MARKET: break;
Expand Down Expand Up @@ -160,7 +160,7 @@ public void OnMessage(QuickFix.FIX42.NewOrderSingle n, SessionID s)
{
case OrdType.LIMIT:
price = n.Price;
if (price.Obj == 0)
if (price.Value == 0)
throw new IncorrectTagValue(price.Tag);
break;
case OrdType.MARKET: break;
Expand Down Expand Up @@ -215,7 +215,7 @@ public void OnMessage(QuickFix.FIX43.NewOrderSingle n, SessionID s)
{
case OrdType.LIMIT:
price = n.Price;
if (price.Obj == 0)
if (price.Value == 0)
throw new IncorrectTagValue(price.Tag);
break;
case OrdType.MARKET: break;
Expand Down Expand Up @@ -270,7 +270,7 @@ public void OnMessage(QuickFix.FIX44.NewOrderSingle n, SessionID s)
{
case OrdType.LIMIT:
price = n.Price;
if (price.Obj == 0)
if (price.Value == 0)
throw new IncorrectTagValue(price.Tag);
break;
case OrdType.MARKET: break;
Expand Down Expand Up @@ -325,7 +325,7 @@ public void OnMessage(QuickFix.FIX50.NewOrderSingle n, SessionID s)
{
case OrdType.LIMIT:
price = n.Price;
if (price.Obj == 0)
if (price.Value == 0)
throw new IncorrectTagValue(price.Tag);
break;
case OrdType.MARKET: break;
Expand Down Expand Up @@ -375,7 +375,7 @@ public void OnMessage(QuickFix.FIX50.News n, SessionID s) { }

public void OnMessage(QuickFix.FIX40.OrderCancelRequest msg, SessionID s)
{
string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Obj : "unknown orderID";
string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Value : "unknown orderID";
QuickFix.FIX40.OrderCancelReject ocj = new QuickFix.FIX40.OrderCancelReject(new OrderID(orderid), msg.ClOrdID);
ocj.CxlRejReason = new CxlRejReason(CxlRejReason.UNKNOWN_ORDER);
ocj.Text = new Text("Executor does not support order cancels");
Expand All @@ -392,7 +392,7 @@ public void OnMessage(QuickFix.FIX40.OrderCancelRequest msg, SessionID s)

public void OnMessage(QuickFix.FIX41.OrderCancelRequest msg, SessionID s)
{
string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Obj : "unknown orderID";
string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Value : "unknown orderID";
QuickFix.FIX41.OrderCancelReject ocj = new QuickFix.FIX41.OrderCancelReject(
new OrderID(orderid), msg.ClOrdID, msg.OrigClOrdID, new OrdStatus(OrdStatus.REJECTED));
ocj.CxlRejReason = new CxlRejReason(CxlRejReason.UNKNOWN_ORDER);
Expand All @@ -410,7 +410,7 @@ public void OnMessage(QuickFix.FIX41.OrderCancelRequest msg, SessionID s)

public void OnMessage(QuickFix.FIX42.OrderCancelRequest msg, SessionID s)
{
string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Obj : "unknown orderID";
string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Value : "unknown orderID";
QuickFix.FIX42.OrderCancelReject ocj = new QuickFix.FIX42.OrderCancelReject(
new OrderID(orderid), msg.ClOrdID, msg.OrigClOrdID, new OrdStatus(OrdStatus.REJECTED), new CxlRejResponseTo(CxlRejResponseTo.ORDER_CANCEL_REQUEST));
ocj.CxlRejReason = new CxlRejReason(CxlRejReason.UNKNOWN_ORDER);
Expand All @@ -428,7 +428,7 @@ public void OnMessage(QuickFix.FIX42.OrderCancelRequest msg, SessionID s)

public void OnMessage(QuickFix.FIX43.OrderCancelRequest msg, SessionID s)
{
string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Obj : "unknown orderID";
string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Value : "unknown orderID";
QuickFix.FIX43.OrderCancelReject ocj = new QuickFix.FIX43.OrderCancelReject(
new OrderID(orderid), msg.ClOrdID, msg.OrigClOrdID, new OrdStatus(OrdStatus.REJECTED), new CxlRejResponseTo(CxlRejResponseTo.ORDER_CANCEL_REQUEST));
ocj.CxlRejReason = new CxlRejReason(CxlRejReason.UNKNOWN_ORDER);
Expand All @@ -446,7 +446,7 @@ public void OnMessage(QuickFix.FIX43.OrderCancelRequest msg, SessionID s)

public void OnMessage(QuickFix.FIX44.OrderCancelRequest msg, SessionID s)
{
string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Obj : "unknown orderID";
string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Value : "unknown orderID";
QuickFix.FIX44.OrderCancelReject ocj = new QuickFix.FIX44.OrderCancelReject(
new OrderID(orderid), msg.ClOrdID, msg.OrigClOrdID, new OrdStatus(OrdStatus.REJECTED), new CxlRejResponseTo(CxlRejResponseTo.ORDER_CANCEL_REQUEST));
ocj.CxlRejReason = new CxlRejReason(CxlRejReason.OTHER);
Expand All @@ -464,7 +464,7 @@ public void OnMessage(QuickFix.FIX44.OrderCancelRequest msg, SessionID s)

public void OnMessage(QuickFix.FIX50.OrderCancelRequest msg, SessionID s)
{
string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Obj : "unknown orderID";
string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Value : "unknown orderID";
QuickFix.FIX50.OrderCancelReject ocj = new QuickFix.FIX50.OrderCancelReject(
new OrderID(orderid), msg.ClOrdID, msg.OrigClOrdID, new OrdStatus(OrdStatus.REJECTED), new CxlRejResponseTo(CxlRejResponseTo.ORDER_CANCEL_REQUEST));
ocj.CxlRejReason = new CxlRejReason(CxlRejReason.OTHER);
Expand All @@ -484,7 +484,7 @@ public void OnMessage(QuickFix.FIX50.OrderCancelRequest msg, SessionID s)

public void OnMessage(QuickFix.FIX40.OrderCancelReplaceRequest msg, SessionID s)
{
string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Obj : "unknown orderID";
string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Value : "unknown orderID";
QuickFix.FIX40.OrderCancelReject ocj = new QuickFix.FIX40.OrderCancelReject(new OrderID(orderid), msg.ClOrdID);
ocj.CxlRejReason = new CxlRejReason(CxlRejReason.UNKNOWN_ORDER);
ocj.Text = new Text("Executor does not support order cancel/replaces");
Expand All @@ -501,7 +501,7 @@ public void OnMessage(QuickFix.FIX40.OrderCancelReplaceRequest msg, SessionID s)

public void OnMessage(QuickFix.FIX41.OrderCancelReplaceRequest msg, SessionID s)
{
string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Obj : "unknown orderID";
string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Value : "unknown orderID";
QuickFix.FIX41.OrderCancelReject ocj = new QuickFix.FIX41.OrderCancelReject(
new OrderID(orderid), msg.ClOrdID, msg.OrigClOrdID, new OrdStatus(OrdStatus.REJECTED));
ocj.CxlRejReason = new CxlRejReason(CxlRejReason.UNKNOWN_ORDER);
Expand All @@ -519,7 +519,7 @@ public void OnMessage(QuickFix.FIX41.OrderCancelReplaceRequest msg, SessionID s)

public void OnMessage(QuickFix.FIX42.OrderCancelReplaceRequest msg, SessionID s)
{
string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Obj : "unknown orderID";
string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Value : "unknown orderID";
QuickFix.FIX42.OrderCancelReject ocj = new QuickFix.FIX42.OrderCancelReject(
new OrderID(orderid), msg.ClOrdID, msg.OrigClOrdID, new OrdStatus(OrdStatus.REJECTED), new CxlRejResponseTo(CxlRejResponseTo.ORDER_CANCEL_REPLACE_REQUEST));
ocj.CxlRejReason = new CxlRejReason(CxlRejReason.UNKNOWN_ORDER);
Expand All @@ -537,7 +537,7 @@ public void OnMessage(QuickFix.FIX42.OrderCancelReplaceRequest msg, SessionID s)

public void OnMessage(QuickFix.FIX43.OrderCancelReplaceRequest msg, SessionID s)
{
string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Obj : "unknown orderID";
string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Value : "unknown orderID";
QuickFix.FIX43.OrderCancelReject ocj = new QuickFix.FIX43.OrderCancelReject(
new OrderID(orderid), msg.ClOrdID, msg.OrigClOrdID, new OrdStatus(OrdStatus.REJECTED), new CxlRejResponseTo(CxlRejResponseTo.ORDER_CANCEL_REPLACE_REQUEST));
ocj.CxlRejReason = new CxlRejReason(CxlRejReason.UNKNOWN_ORDER);
Expand All @@ -555,7 +555,7 @@ public void OnMessage(QuickFix.FIX43.OrderCancelReplaceRequest msg, SessionID s)

public void OnMessage(QuickFix.FIX44.OrderCancelReplaceRequest msg, SessionID s)
{
string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Obj : "unknown orderID";
string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Value : "unknown orderID";
QuickFix.FIX44.OrderCancelReject ocj = new QuickFix.FIX44.OrderCancelReject(
new OrderID(orderid), msg.ClOrdID, msg.OrigClOrdID, new OrdStatus(OrdStatus.REJECTED), new CxlRejResponseTo(CxlRejResponseTo.ORDER_CANCEL_REPLACE_REQUEST));
ocj.CxlRejReason = new CxlRejReason(CxlRejReason.OTHER);
Expand All @@ -573,7 +573,7 @@ public void OnMessage(QuickFix.FIX44.OrderCancelReplaceRequest msg, SessionID s)

public void OnMessage(QuickFix.FIX50.OrderCancelReplaceRequest msg, SessionID s)
{
string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Obj : "unknown orderID";
string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Value : "unknown orderID";
QuickFix.FIX50.OrderCancelReject ocj = new QuickFix.FIX50.OrderCancelReject(
new OrderID(orderid), msg.ClOrdID, msg.OrigClOrdID, new OrdStatus(OrdStatus.REJECTED), new CxlRejResponseTo(CxlRejResponseTo.ORDER_CANCEL_REPLACE_REQUEST));
ocj.CxlRejReason = new CxlRejReason(CxlRejReason.OTHER);
Expand Down
4 changes: 2 additions & 2 deletions QuickFIXn/DefaultMessageFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public Message Create(string beginString, QuickFix.Fields.ApplVerID applVerId, s
if (beginString == QuickFix.Values.BeginString_FIXT11 && !Message.IsAdminMsgType(msgType))
{
_factories.TryGetValue(
QuickFix.FixValues.ApplVerID.ToBeginString(applVerId.Obj),
QuickFix.FixValues.ApplVerID.ToBeginString(applVerId.Value),
out messageFactory);
}

Expand All @@ -85,7 +85,7 @@ public Group Create(string beginString, string msgType, int groupCounterTag)
{
string key = beginString;
if(beginString.Equals(FixValues.BeginString.FIXT11))
key = QuickFix.FixValues.ApplVerID.ToBeginString(_defaultApplVerId.getValue());
key = QuickFix.FixValues.ApplVerID.ToBeginString(_defaultApplVerId.Value);

if (_factories.TryGetValue(key, out IMessageFactory? factory))
return factory.Create(beginString, msgType, groupCounterTag);
Expand Down
46 changes: 14 additions & 32 deletions QuickFIXn/Fields/BooleanField.cs
Original file line number Diff line number Diff line change
@@ -1,37 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace QuickFix.Fields;

namespace QuickFix.Fields
{
/// <summary>
/// FIX BooleanField class
/// </summary>
public class BooleanField : FieldBase<Boolean>
{
public BooleanField(int tag)
: base(tag, false) { }

public BooleanField(int tag, Boolean b)
: base(tag, b) { }

/// <summary>
/// quickfix-cpp compat - returns base type
/// </summary>
/// <returns>Boolean object</returns>
public Boolean getValue()
{ return Obj; }
/// <summary>
/// FIX Boolean field
/// </summary>
public class BooleanField : FieldBase<bool> {
public BooleanField(int tag)
: base(tag, false) {
}

/// <summary>
/// quickfix-cpp compat - set object
/// </summary>
public void setValue(Boolean b)
{ Obj = b; }
public BooleanField(int tag, bool b)
: base(tag, b) {
}

protected override string makeString()
{
return Converters.BoolConverter.Convert(Obj);
}
protected override string MakeString() {
return Converters.BoolConverter.Convert(Value);
}
}

38 changes: 13 additions & 25 deletions QuickFIXn/Fields/CharField.cs
Original file line number Diff line number Diff line change
@@ -1,30 +1,18 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace QuickFix.Fields;

namespace QuickFix.Fields
{
/// <summary>
/// A character message field
/// </summary>
public class CharField : FieldBase<Char>
{
public CharField(int tag)
:base(tag, '\0') {}

public CharField(int tag, char c)
: base(tag, c) { }

// quickfix compat
public char getValue()
{ return Obj; }
/// <summary>
/// FIX character field
/// </summary>
public class CharField : FieldBase<char> {
public CharField(int tag)
: base(tag, '\0') {
}

public void setValue(char c)
{ Obj = c; }
public CharField(int tag, char c)
: base(tag, c) {
}

protected override string makeString()
{
return Converters.CharConverter.Convert(Obj);
}
protected override string MakeString() {
return Converters.CharConverter.Convert(Value);
}
}
20 changes: 6 additions & 14 deletions QuickFIXn/Fields/DateTimeField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,9 @@ public DateTimeField(int tag, DateTime dt, TimeStampPrecision timeFormatPrecisio
timePrecision = timeFormatPrecision;
}


// quickfix compat
public DateTime getValue()
{ return Obj; }

public void setValue(DateTime dt)
{ Obj = dt; }

protected override string makeString()
protected override string MakeString()
{
return Converters.DateTimeConverter.ToFIX(Obj, timePrecision);
return Converters.DateTimeConverter.ToFIX(Value, timePrecision);
}
}

Expand All @@ -49,9 +41,9 @@ public DateOnlyField(int tag, DateTime dt, bool showMilliseconds)
public DateOnlyField(int tag, DateTime dt, TimeStampPrecision timeFormatPrecision)
: base(tag, dt, timeFormatPrecision) { }

protected override string makeString()
protected override string MakeString()
{
return Converters.DateTimeConverter.ToFIXDateOnly(Obj);
return Converters.DateTimeConverter.ToFIXDateOnly(Value);
}
}

Expand All @@ -69,9 +61,9 @@ public TimeOnlyField(int tag, DateTime dt, bool showMilliseconds)
public TimeOnlyField(int tag, DateTime dt, TimeStampPrecision timeFormatPrecision)
: base(tag, dt, timeFormatPrecision) { }

protected override string makeString()
protected override string MakeString()
{
return Converters.DateTimeConverter.ToFIXTimeOnly(Obj, base.timePrecision);
return Converters.DateTimeConverter.ToFIXTimeOnly(Value, base.timePrecision);
}
}
}
11 changes: 2 additions & 9 deletions QuickFIXn/Fields/DecimalField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,9 @@ public DecimalField(int tag)
public DecimalField(int tag, Decimal val)
: base(tag, val) { }

// quickfix compat
public Decimal getValue()
{ return Obj; }

public void setValue(Decimal d)
{ Obj = d; }

protected override string makeString()
protected override string MakeString()
{
return Converters.DecimalConverter.Convert(Obj);
return Converters.DecimalConverter.Convert(Value);
}
}
}
Loading

0 comments on commit b6ab1b5

Please sign in to comment.