[This message was posted by Jan Jonsson of E. Ohman J:or Fondkommission AB
<[email protected]> to the "FAST Protocol" discussion forum at
http://fixprotocol.org/discuss/46. You can reply to it on-line at
http://fixprotocol.org/discuss/read/311ee7b3 - PLEASE DO NOT REPLY BY MAIL.]
One small question about slots in fast-fix, how come I have to set NO_SLOTS to
14, not 11 to make this code work (just modified encoder sample). I must have
missed some major idea behind this. If I set it to 13 i get index out of bounds
when EndodeEngMsg,
I am just trying to se how efficient fast is.
using System;
using System.IO;
using System.Collections;
using System.Text;
using FAST;
namespace Encoder
{
class Program
{
private const int NO_TEMPLATES = 1;
private const int NO_SLOTS = 14;
/// <summary>
/// Test template identifiers
/// </summary>
enum tids
{
Base = 0,
};
/// <summary>
/// Test field definitions
/// </summary>
enum fields
{
TID = 0,
SeqNum = 1,
SecurityExchange = 2,
ExecutionVenue = 3,
Currency = 4,
Symbol = 5,
Bid = 6,
Ask = 7,
Time = 8
};
static void Main(string[] args)
{
try
{
FileStream FS = new FileStream("example.txt", FileMode.Create);
BinaryWriter BW = new BinaryWriter(FS);
CTransferEncoder TransferEncoder = new CTransferEncoder(BW,
NO_SLOTS);
CCODEC Codec = new CCODEC(TransferEncoder, NO_TEMPLATES,
NO_SLOTS);
Codec.AddFieldDef((int)fields.TID, CFieldDef.type.U32,
CFieldDef.op.Copy, (int) tids.Base, 0);
Codec.AddFieldDef((int)fields.SeqNum, CFieldDef.type.U32,
CFieldDef.op.Incr, (int) tids.Base, 1);
Codec.AddFieldDef((int)fields.SecurityExchange,
CFieldDef.type.String, CFieldDef.op.Copy, (int)tids.Base, 2);
Codec.AddFieldDef((int)fields.ExecutionVenue,
CFieldDef.type.String, CFieldDef.op.Copy, (int)tids.Base, 3);
Codec.AddFieldDef((int)fields.Currency, CFieldDef.type.String,
CFieldDef.op.Copy, (int)tids.Base, 4);
Codec.AddFieldDef((int)fields.Symbol, CFieldDef.type.String,
CFieldDef.op.Copy, (int)tids.Base, 5);
Codec.AddFieldDef((int)fields.Bid, CFieldDef.type.U32,
CFieldDef.op.Copy, (int)tids.Base, 6);
Codec.AddFieldDef((int)fields.Ask, CFieldDef.type.U32,
CFieldDef.op.Copy, (int)tids.Base, 7);
Codec.AddFieldDef((int)fields.Time, CFieldDef.type.U32,
CFieldDef.op.Copy, (int)tids.Base, 8);
// encode one message
// Encode the data, we always start off with a template
ID
Codec.EncodeNewMsg((uint)fields.TID);
// Always start off with a template ID
Codec.EncodeU32((int)fields.TID, (uint) 1);
Codec.EncodeU32((int)fields.SeqNum, 1);
Codec.EncodeString((int)fields.SecurityExchange,"XSTO");
Codec.EncodeString((int)fields.ExecutionVenue, "CHIX");
Codec.EncodeString((int)fields.Currency, "SEK");
Codec.EncodeString((int)fields.Symbol, "ERIC B");
Codec.EncodeU32((int)fields.Bid, 1);
Codec.EncodeU32((int)fields.Ask, 10010);
Codec.EncodeU32((int)fields.Time, 101010);
// we are done with this message
Codec.EncodeEndMsg();
BW.Close();
}
catch (Exception E)
{
System.Console.WriteLine(E.Message);
System.Threading.Thread.Sleep(10000);
}
}
}
}
[You can unsubscribe from this discussion group by sending a message to
mailto:[email protected]]
--
You received this message because you are subscribed to the Google Groups
"Financial Information eXchange" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/fix-protocol?hl=en.