本文整理汇总了C#中Session.OpenService方法的典型用法代码示例。如果您正苦于以下问题:C# Session.OpenService方法的具体用法?C# Session.OpenService怎么用?C# Session.OpenService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Session
的用法示例。
在下文中一共展示了Session.OpenService方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitialiseSessionAndService
/// <summary>
/// Initialise the Session and the Service
/// </summary>
internal void InitialiseSessionAndService()
{
if (_session == null)
{
var sessionOptions = new SessionOptions
{
ServerHost = _serverHost,
ServerPort = _serverPort
};
//Console.WriteLine("Connecting to {0}:{1}", sessionOptions.ServerHost, sessionOptions.ServerPort);
_session = new Session(sessionOptions);
if (!_session.Start())
throw new Exception("Failed to connect!");
if (!_session.OpenService("//blp/refdata"))
{
_session.Stop();
_session = null;
throw new Exception("Failed to open //blp/refdata");
}
_refDataService = _session.GetService("//blp/refdata");
}
}
示例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: SendIntradayBarRequest
private void SendIntradayBarRequest(Session session, RealTimeDataRequest req)
{
session.OpenService("//blp/refdata");
Service refDataService = session.GetService("//blp/refdata");
Request request = refDataService.CreateRequest("IntradayBarRequest");
// only one security/eventType per request
request.Set("security", req.Instrument.DatasourceSymbol);
request.Set("eventType", "TRADE");
request.Set("interval", req.Frequency.ToTimeSpan().TotalSeconds);
DateTime prevTradedDate = DateTime.Now.AddDays(-1); //todo fix
var startDateTime = string.Format("{0}-{1}-{2}T13:30:00", prevTradedDate.Year, prevTradedDate.Month, prevTradedDate.Day);
prevTradedDate = prevTradedDate.AddDays(1); // next day for end date
var endDateTime = string.Format("{0}-{1}-{2}T13:30:00", prevTradedDate.Year, prevTradedDate.Month, prevTradedDate.Day);
request.Set("startDateTime", startDateTime);
request.Set("endDateTime", endDateTime);
request.Set("gapFillInitialBar", true);
session.SendRequest(request, null);
}
示例4: Run
private void Run(string[] args)
{
var commandLineOptions = new CommandLineOptions();
if (!CommandLine.Parser.Default.ParseArguments(args, commandLineOptions))
{
return;
}
Initialize(commandLineOptions);
var sessionOptions = GetSessionOptions();
Logger.InfoFormat("Connecting to [{0}]:[{1}]", _host, _port);
var session = new Session(sessionOptions);
bool sessionStarted = session.Start();
if (!sessionStarted)
{
Logger.Error("Failed to start session.");
return;
}
if (!session.OpenService("//blp/refdata"))
{
Logger.Error("Failed to open //blp/refdata");
return;
}
try
{
SendRefDataRequest(session);
}
catch (InvalidRequestException e)
{
Logger.WarnFormat("Exception occurred: [{0}]", e);
}
// wait for events from session.
EventLoop(session);
session.Stop();
}
示例5: Run
private void Run()
{
var sessionOptions = new SessionOptions {ServerHost = _dHost, ServerPort = _dPort};
Console.WriteLine(@"Connecting to " + _dHost + @":" + _dPort);
var session = new Session(sessionOptions);
bool sessionStarted = session.Start();
if (!sessionStarted)
{
Console.Error.WriteLine("Failed to start session.");
_waitEndOfCollection.Release();
return;
}
if (!session.OpenService("//blp/refdata"))
{
Console.Error.WriteLine("Failed to open //blp/refdata");
_waitEndOfCollection.Release();
return;
}
DataManager.CreateTableForContract(_dSecurity);
DataManager.DeleteTicks(_dSecurity, _startDate, _endDate);
SendIntradayTickRequest(session);
EventLoop(session);
session.Stop();
}
示例6: setup
private void setup()
{
Logger.Info("About to startup bbg engines...", typeof(Core));
m_processEventHandler = processEvent;
try
{
// start a synchronous session
SessionOptions opts = new SessionOptions();
opts.ServerHost = ConfigHelper.BbgHost;
opts.ServerPort = ConfigHelper.BbgPort;
Logger.Info(string.Format("Bbg Session options: Host={0}; Port={1}", opts.ServerHost, opts.ServerPort.ToString()), typeof(Core));
SyncSession = new Session(opts);
if (!SyncSession.Start())
{
Logger.Fatal("Failed to start SyncSession instance of bloomberg session", typeof(Core));
IsStarted = false;
return;
}
else
{
Logger.Info("Bloomberg 'SyncSession' started successfully", typeof(Core));
}
if (!SyncSession.OpenService("//blp/refdata"))
{
Logger.Fatal("Failed to open service //blp/refdata on 'SyncSession' bbg session", typeof(Core));
System.Console.Error.WriteLine("Failed to start RefData service");
return;
}
else
{
Logger.Info("Successfully opened service //blp/refdata on 'SyncSession' bbg session", typeof(Core));
}
SyncRefService = SyncSession.GetService("//blp/refdata");
ASyncSession = new Session(opts, m_processEventHandler);
ASyncSession.Start();
ASyncSession.OpenService("//blp/refdata");
ASyncSession.OpenService("//blp/pagedata");
ASyncRefService = ASyncSession.GetService("//blp/refdata");
IsStarted = true;
}
catch (Exception ex_)
{
Logger.Error(string.Format("Error starting up Bloomberg Sessions: {0} {1}", ex_.Message, ex_.StackTrace), typeof(Core));
IsStarted = false;
}
}
示例7: OpenSession
/// <summary>
/// Etablie la connection avec Bloomberg
/// </summary>
private void OpenSession()
{
sessionOptions = new SessionOptions();
sessionOptions.ServerHost = "localhost";
sessionOptions.ServerPort = 8194;
session = new Session(sessionOptions);
l_title = new List<Title>();
if (!session.Start())
{
System.Console.WriteLine("Could not start session.");
Console.WriteLine(session.ToString());
Remplissage_Non_connection();
return;
}
if (!session.OpenService("//blp/refdata"))
{
System.Console.WriteLine("Could not open service " +
"//blp/refdata");
return;
}
refDataSvc = session.GetService("//blp/refdata");
if (refDataSvc == null)
{
Console.WriteLine("Cannot get service");
return;
}
else
{
request = refDataSvc.CreateRequest("ReferenceDataRequest");
}
}
示例8: 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 });
}
}
}