本文整理汇总了C#中Session.NextEvent方法的典型用法代码示例。如果您正苦于以下问题:C# Session.NextEvent方法的具体用法?C# Session.NextEvent怎么用?C# Session.NextEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Session
的用法示例。
在下文中一共展示了Session.NextEvent方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EventLoop
//TODO write
private void EventLoop(Session session)
{
bool done = false;
while (!done)
{
Event eventObj = session.NextEvent();
if (eventObj.Type == Event.EventType.PARTIAL_RESPONSE)
{
ProcessResponseEvent(eventObj, session);
}
else if (eventObj.Type == Event.EventType.RESPONSE)
{
ProcessResponseEvent(eventObj, session);
done = true;
}
else
{
foreach (Message msg in eventObj)
{
System.Console.WriteLine(msg.AsElement);
if (eventObj.Type == Event.EventType.SESSION_STATUS)
{
if (msg.MessageType.Equals("SessionTerminated"))
{
done = true;
}
}
}
}
}
}
示例2: Test
public void Test()
{
string serverHost = "localhost";
int serverPort = 8194;
SessionOptions sessionOptions = new SessionOptions();
sessionOptions.ServerHost = serverHost;
sessionOptions.ServerPort = serverPort;
Debug.WriteLine("Connecting to " + serverHost + ":" + serverPort);
Session session = new Session(sessionOptions);
bool sessionStarted = session.Start();
if (!sessionStarted)
{
System.Console.Error.WriteLine("Failed to start session.");
return;
}
if (!session.OpenService("//blp/refdata"))
{
System.Console.Error.WriteLine("Failed to open //blp/refdata");
return;
}
Service refDataService = session.GetService("//blp/refdata");
Request request = refDataService.CreateRequest("IntradayBarRequest");
request.Set("security", "IBM US Equity");
request.Set("eventType", "TRADE");
request.Set("interval", 60); // bar interval in minutes
DateTime tradedOn = getPreviousTradingDate();
request.Set("startDateTime", new Datetime(tradedOn.Year,
tradedOn.Month,
tradedOn.Day,
13, 30, 0, 0));
request.Set("endDateTime", new Datetime(tradedOn.Year,
tradedOn.Month,
tradedOn.Day,
21, 30, 0, 0));
Debug.WriteLine("Sending Request: " + request);
session.SendRequest(request, null);
while (true)
{
Event eventObj = session.NextEvent();
foreach (Message msg in eventObj.GetMessages())
{
Debug.WriteLine(msg.ToString());
}
if (eventObj.Type == Event.EventType.RESPONSE)
{
break;
}
}
}
示例3: EventLoop
private void EventLoop(Session session)
{
var done = false;
while (!done)
{
var eventObj = session.NextEvent();
if (eventObj.Type == Event.EventType.PARTIAL_RESPONSE)
{
Logger.Info("Processing Partial Response");
ProcessResponseEvent(eventObj);
}
else if (eventObj.Type == Event.EventType.RESPONSE)
{
Logger.Info("Processing Response");
ProcessResponseEvent(eventObj);
done = true;
}
else
{
foreach (var msg in eventObj)
{
Logger.DebugFormat("[{0}]", msg.AsElement);
if (eventObj.Type == Event.EventType.SESSION_STATUS)
{
if (msg.MessageType.Equals("SessionTerminated"))
{
done = true;
}
}
}
}
}
}
示例4: EventLoop
private void EventLoop(Session session)
{
bool done = false;
while (!done)
{
if (_shouldStop)
{
break;
}
Event eventObj = session.NextEvent();
if (eventObj.Type == Event.EventType.PARTIAL_RESPONSE)
{
Console.WriteLine(@"Processing Partial Response");
ProcessResponseEvent(eventObj);
}
else if (eventObj.Type == Event.EventType.RESPONSE)
{
Console.WriteLine(@"Processing Response");
ProcessResponseEvent(eventObj);
done = true;
}
else
{
foreach (var msg in eventObj)
{
Console.WriteLine(msg.AsElement);
if (eventObj.Type == Event.EventType.SESSION_STATUS)
{
if (msg.MessageType.Equals("SessionTerminated"))
{
done = true;
}
}
}
}
}
_waitEndOfCollection.Release();
}
示例5: ProcessEvents
public void ProcessEvents(Session s, Request req)
{
s.SendRequest(req, new CorrelationID(1));
bool continueToLoop = true;
while (continueToLoop)
{
Event eventObj = s.NextEvent();
switch (eventObj.Type)
{
case Event.EventType.RESPONSE: // final response
continueToLoop = false;
HandleResponseEvent(eventObj);
break;
case Event.EventType.PARTIAL_RESPONSE:
HandleResponseEvent(eventObj);
break;
default:
//if (Debug)
HandleOtherEvent(eventObj);
break;
}
}
}
示例6: Submit
public result Submit(string ISIN)
{
result FOSresult = new result();
//open excel to get two parameter
SessionOptions sessionOptions = new SessionOptions();
sessionOptions.ServerHost = "WSG053";
sessionOptions.ServerPort = 0x2002;
Session session = new Session(sessionOptions);
if (!session.Start())
{
Console.WriteLine("Could not start session.");
Environment.Exit(1);
}
if (!session.OpenService("//blp/refdata"))
{
Console.WriteLine("Could not open service //blp/refdata");
Environment.Exit(1);
}
CorrelationID requestID = new CorrelationID(1L);
Request request = session.GetService("//blp/refdata").CreateRequest("ReferenceDataRequest");
request.GetElement("securities").AppendValue(ISIN + " corp");
Element fields = request.GetElement("fields");
fields.AppendValue("SECURITY_DES");
fields.AppendValue("CRNCY");
fields.AppendValue("ISSUER");
fields.AppendValue("COUNTRY_FULL_NAME");
fields.AppendValue("MARKET_SECTOR_DES");
fields.AppendValue("INDUSTRY_SECTOR");
fields.AppendValue("PX_BID");
fields.AppendValue("COUPON");
fields.AppendValue("YLD_YTM_BID");
fields.AppendValue("DUR_BID");
fields.AppendValue("RTG_SP");
fields.AppendValue("RTG_SP_LT_LC_ISSUER_CREDIT");
fields.AppendValue("RTG_MOODY");
fields.AppendValue("RTG_MOODY_LONG_TERM");
fields.AppendValue("RTG_MDY_LC_CURR_ISSUER_RATING");
fields.AppendValue("RTG_FITCH");
fields.AppendValue("RTG_FITCH_LT_ISSUER_DEFAULT");
fields.AppendValue("COLLAT_TYP");
fields.AppendValue("MTY_YEARS_TDY");
fields.AppendValue("NXT_CALL_DT");
fields.AppendValue("MATURITY");
fields.AppendValue("GUARANTOR");
Console.WriteLine("Sending Request:" + request);
session.SendRequest(request, null);
while (true)
{
Event eventObj = session.NextEvent();
this.processEvent(eventObj, session);
if (eventObj.Type == Event.EventType.RESPONSE)
{
IssueRating = RTG_SP + "/" + this.GetMoody(RTG_MOODY, RTG_MOODY_LONG_TERM) + "/" + RTG_FITCH;
IssuerRating = RTG_SP_LT_LC_ISSUER_CREDIT + "/" + RTG_MDY_LC_CURR_ISSUER_RATING + "/" + RTG_FITCH_LT_ISSUER_DEFAULT;
if (CallDate != "NA")
{
DateTime newdate = DateTime.Parse(CallDate);
DateTime nowdate = DateTime.Now;
decimal dCallDate = (decimal)(((TimeSpan)(newdate - nowdate)).Days) / 365;
CallDate = StandardFormat(Math.Round(dCallDate, 2).ToString(), 2);
}
FOSresult.CallDate = CallDate;
FOSresult.COLLATERAL_TYPE = COLLATERAL_TYPE;
FOSresult.COUNTRY_FULL_NAME = COUNTRY_FULL_NAME;
FOSresult.COUPON = COUPON;
FOSresult.CRNCY = CRNCY;
FOSresult.DUR_BID = DUR_BID;
FOSresult.INDUSTRY_SECTOR = INDUSTRY_SECTOR.ToUpper();
FOSresult.PX_BID = PX_BID;
FOSresult.YLD_YTM_BID = YLD_YTM_BID;
FOSresult.SECURITY_DES = SECURITY_DES;
FOSresult.IssueRating = IssueRating;
FOSresult.IssuerRating = IssuerRating;
FOSresult.MARKET_SECTOR_DES = MARKET_SECTOR_DES;
FOSresult.YearToMaturity = Maturity;
FOSresult.ISSUER = ISSUER;
GetInfoFromExcel(FOSresult);
//undoImpersonation();
return FOSresult;
//return base.Json(new { SECURITY_DES = SECURITY_DES, CRNCY = CRNCY, ISSUER = ISSUER, COUNTRY_FULL_NAME = COUNTRY_FULL_NAME, MARKET_SECTOR_DES = MARKET_SECTOR_DES, INDUSTRY_SECTOR = INDUSTRY_SECTOR.ToUpper(), PX_BID = PX_BID, COUPON = COUPON, YLD_YTM_BID = YLD_YTM_BID, DUR_BID = DUR_BID, IssueRating = IssueRating, IssuerRating = IssuerRating, COLLATERAL_TYPE = COLLATERAL_TYPE, YearToMaturity = Maturity, CallDate = CallDate });
}
}
}