我试图创建一个简单的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);
}
这是我的config 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
这些是&#34; toAdmin&#34;方法:
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
这些是&#34; toAdmin&#34;方法:
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在这里是假的。
答案 0 :(得分:1)
您的接受者配置文件中的SocketAcceptAddress在哪里?而不是使用&#34; localhost&#34;它可能需要是127.0.0.1