我正在尝试创建一个简单的QuickFix,但我在发送消息时遇到了问题。
下面是我的服务器代码:
static void Main(string[] args)
{
try
{
SessionSettings settings = new SessionSettings(@"C:\Users\anhtv\Desktop\QuickFix\QuickFix\server.cfg");
FixServerApplication application = new FixServerApplication();
FileStoreFactory storeFactory = new FileStoreFactory(settings);
ScreenLogFactory logFactory = new ScreenLogFactory(settings);
MessageFactory messageFactory = new DefaultMessageFactory();
SocketAcceptor acceptor = new SocketAcceptor(application, storeFactory, settings, logFactory, messageFactory);
acceptor.start();
Console.WriteLine("press <enter> to quit");
Console.Read();
acceptor.stop();
}
catch (Exception e)
{
Console.WriteLine(e);
}这是我的配置server.cfg:
# default settings for sessions
[DEFAULT]
FileStorePath=c:\fixfiles
FileLogPath=log
ConnectionType=acceptor
ReconnectInterval=60
SenderCompID=ARCA
SocketAcceptPort=9823
SocketReuseAddress=Y
# session definition
[SESSION]
BeginString=FIX.4.2
TargetCompID=TW
StartTime=12:30:00
EndTime=23:30:00
HeartBtInt=20
DataDictionary=C:\Users\anhtv\Desktop\QuickFix\QuickFix\fix\FIX42.xml下面是"toAdmin“方法的结果:
message: {8=FIX.4.19=4535=534=149=ARCA52=20150915-07:02:3756=TW10=213}
sessionId: {FIX.4.1:ARCA->TW}下面是我的客户端代码:
static void Main()
{
SessionSettings settings = new SessionSettings(@"C:\Users\anhtv\Desktop\QuickFix\QuickFix\client.cfg");
QuickFix.Application application = new ClientInitiator();
FileStoreFactory storeFactory = new FileStoreFactory(settings);
ScreenLogFactory logFactory = new ScreenLogFactory(settings);
MessageFactory messageFactory = new DefaultMessageFactory();
SocketInitiator initiator = new SocketInitiator(application, storeFactory, settings, logFactory, messageFactory);
initiator.start();
System.Collections.ArrayList list = initiator.getSessions();
SessionID sessionID = (SessionID)list[0];
QuickFix42.NewOrderSingle order = new QuickFix42.NewOrderSingle(new ClOrdID("DLF"), new HandlInst(HandlInst.MANUAL_ORDER), new Symbol("DLF"), new Side(Side.BUY), new TransactTime(DateTime.Now), new OrdType(OrdType.LIMIT));
order.set(new OrderQty(45));
order.set(new Price(25.4d));
Console.WriteLine("Sending Order to Server");
bool x = Session.sendToTarget(order, sessionID);// x is false
Console.ReadLine();
initiator.stop();
}这是我的配置client.cfg
# default settings for sessions
[DEFAULT]
FileStorePath=c:\fixfiles
FileLogPath=log
ConnectionType=initiator
ReconnectInterval=60
SenderCompID=TW
SocketConnectHost=localhost
# session definition
[SESSION]
BeginString=FIX.4.2
TargetCompID=ARCA
StartTime=12:30:00
EndTime=23:30:00
HeartBtInt=20
SocketConnectPort=9823
DataDictionary=C:\Users\anhtv\Desktop\QuickFix\QuickFix\fix\FIX42.xml下面是"toAdmin“方法的结果:
message: {8=FIX.4.19=4535=534=249=TW52=20150915-07:04:4356=ARCA10=213}
sessionId: {FIX.4.1:TW->ARCA}我通过调用以下命令来发送消息:
bool x = Session.sendToTarget(order, sessionID); //x is false有人能帮上忙吗?我不知道为什么x在这里是假的。
发布于 2015-09-17 19:00:07
您的SocketAcceptAddress在您的接受器配置文件中的什么位置?而不是使用"localhost“,它可能需要是127.0.0.1
https://stackoverflow.com/questions/32580236
复制相似问题