/// <summary> /// Initializes a new real-time client instance. /// </summary> /// <param name="api_key">Your Intrinio API Key</param> /// <param name="username">Your Intrinio API Username</param> /// <param name="password">Your Intrinio API Password</param> /// <param name="provider">A QuoteProvider</param> public RealTimeClient(QuoteProvider provider, string username = null, string password = null, string api_key = null) { this.api_key = api_key; this.username = username; this.password = password; this.provider = provider; if (String.IsNullOrEmpty(this.api_key)) { if (String.IsNullOrEmpty(this.username) && String.IsNullOrEmpty(this.password)) { throw new ArgumentException("Must provide an API key or username and password"); } if (String.IsNullOrEmpty(this.username)) { throw new ArgumentException("Must provide a valid username"); } if (String.IsNullOrEmpty(this.password)) { throw new ArgumentException("Must provide a valid password"); } } this.Logger = LogManager.GetLogger(this.GetType().FullName); Thread heartbeat = new Thread(new ThreadStart(this.SendHeartbeat)); heartbeat.Start(); this.runningThreads.Add(heartbeat); }
protected override async Task <RFQCancelledEvent> Handle(CancelRFQCommand command) { var rfq = AggregateWriter.GetById(command.RFQIdentitier); if (rfq == null) { // invlid request what to do here? } QuoteProvider.CancelRFQ(command.RFQIdentitier); var rFQCancelledEvent = new RFQCancelledEvent(command.RFQIdentitier); return(rFQCancelledEvent); }
public IQuoteProvider ObtainQuoteProvider(ComponentId source, Symbol symbol) { if (source.IsEmpty || symbol.IsEmpty) { SystemMonitor.Warning("Source or symbol empty."); return(null); } lock (this) { if (_quoteProviders.ContainsKey(source) && _quoteProviders[source].ContainsKey(symbol)) { return(_quoteProviders[source][symbol]); } } ISourceDataDelivery delivery = ObtainDataDelivery(source); if (delivery == null) { SystemMonitor.OperationError("Failed to establish data delivery for quote provider."); return(null); } RuntimeDataSessionInformation session = delivery.GetSymbolRuntimeSessionInformation(symbol); if (session == null) { SystemMonitor.OperationError("Failed to establish runtime session information for symbol [" + symbol.Name + "]"); return(null); } QuoteProvider provider = new QuoteProvider(session.Info); // Make sure to *add before setting up* the initial paramters, // since a call from them can get back to this method, and cause a stack overflow. AddElement(source, symbol, provider); provider.SetInitialParameters(delivery); return(provider); }
protected override async Task <RFQRaisedEvent> Handle(RaiseRFQCommand command) { var rfq = AggregateWriter.GetById(command.RFQIdentitier); if (rfq != null) { // already processing, what to do here? } var rFQRaisedEvent = new RFQRaisedEvent(command.Instrument, command.RFQIdentitier, command.CounterParties, command.Requested); // Save the creation await base.SaveEvent(rFQRaisedEvent); // and then SubmitRequest QuoteProvider.SubmitRFQ(command.RFQIdentitier, command.OrderId, command.CounterParties, command.Instrument, 110.25M); return(rFQRaisedEvent); }
private static void Main(string[] args) { if (args.Length == 2) { try { var marketFilePath = args[0]; var loanAmount = args[1]; ISourceProvider sourceProvider = new CsvFileSourceProvider(); IQuoteProvider quoteProvider = new QuoteProvider(sourceProvider); var quote = quoteProvider.CreateQuote(marketFilePath, loanAmount); Console.WriteLine(quote); } catch (LoanAmountException ex) { OutputErrorMessage(ex.Message); } catch (SourceFileFormatException ex) { OutputErrorMessage("Please check the CSV source file format! " + ex.Message); } catch (SourceFileIOException ex) { OutputErrorMessage(ex.Message); } catch (Exception ex) { OutputErrorMessage("Someting went wrong! " + ex.Message); } } else { OutputErrorMessage("The application should take arguments in the form: \n" + " cmd> [application] [market_file] [loan_amount] \n" + "Example: \n" + " cmd> quote.exe market.csv 1500"); } }
/// <summary> /// Initializes a new real-time client instance. /// </summary> /// <param name="username">Your Intrinio API Username</param> /// <param name="password">Your Intrinio API password</param> /// <param name="provider">A QuoteProvider</param> public RealTimeClient(string username, string password, QuoteProvider provider) { this.username = username; this.password = password; this.provider = provider; if (this.username.Length == 0) { throw new ArgumentException("Must provide a valid username"); } if (this.password.Length == 0) { throw new ArgumentException("Must provide a valid password"); } this.Logger = LogManager.GetLogger(this.GetType().FullName); Thread heartbeat = new Thread(new ThreadStart(this.SendHeartbeat)); heartbeat.Start(); this.runningThreads.Add(heartbeat); }
public QuoteRefreshService(QuoteProvider quoteProvider) { QuoteProvider = quoteProvider; }
public void Test() { var quoteProvider = new QuoteProvider(new Server()); quoteProvider.Run(); }
public QuoteController(QuoteProvider QuoteProvider) { quoteProvider = QuoteProvider; }