public void CorrectlyCalculatesUltraTBondFuturesExpirationDates() { //Seventh business day preceding the last business day of the delivery month. //Trading in expiring contracts closes at 12:01 p.m. on the last trading day. var ub = new UnderlyingSymbol(); ub.Rule = new ExpirationRule { DaysBefore = 7, DayType = DayType.Business, ReferenceRelativeMonth = RelativeMonth.CurrentMonth, ReferenceUsesDays = false, ReferenceDayIsLastBusinessDayOfMonth = true }; DateTime dec13Expiration = ub.ExpirationDate(2013, 12); Assert.AreEqual(new DateTime(2013, 12, 19), dec13Expiration); DateTime mar14Expiration = ub.ExpirationDate(2014, 3); Assert.AreEqual(new DateTime(2014, 3, 20), mar14Expiration); DateTime jun14Expiration = ub.ExpirationDate(2014, 6); Assert.AreEqual(new DateTime(2014, 6, 19), jun14Expiration); DateTime sep14Expiration = ub.ExpirationDate(2014, 9); Assert.AreEqual(new DateTime(2014, 9, 19), sep14Expiration); }
public void CorrectlyCalculatesESFuturesExpirationDates() { //Trading can occur up to 8:30 a.m. on the 3rd Friday of the contract month var es = new UnderlyingSymbol(); es.Rule = new ExpirationRule { DaysBefore = 0, DayType = DayType.Calendar, ReferenceRelativeMonth = RelativeMonth.CurrentMonth, ReferenceUsesDays = false, ReferenceWeekDay = DayOfTheWeek.Friday, ReferenceWeekDayCount = WeekDayCount.Third }; DateTime dec13Expiration = es.ExpirationDate(2013, 12); Assert.AreEqual(new DateTime(2013, 12, 20), dec13Expiration); DateTime mar14Expiration = es.ExpirationDate(2014, 3); Assert.AreEqual(new DateTime(2014, 3, 21), mar14Expiration); DateTime jun14Expiration = es.ExpirationDate(2014, 6); Assert.AreEqual(new DateTime(2014, 6, 20), jun14Expiration); DateTime sep14Expiration = es.ExpirationDate(2014, 9); Assert.AreEqual(new DateTime(2014, 9, 19), sep14Expiration); DateTime dec14Expiration = es.ExpirationDate(2014, 12); Assert.AreEqual(new DateTime(2014, 12, 19), dec14Expiration); }
public void CorrectlyCalculatesGCFuturesExpirationDates() { //Trading terminates on the third last business day of the delivery month. var ub = new UnderlyingSymbol(); ub.Rule = new ExpirationRule { DaysBefore = 2, DayType = DayType.Business, ReferenceRelativeMonth = RelativeMonth.CurrentMonth, ReferenceUsesDays = false, ReferenceDayIsLastBusinessDayOfMonth = true }; DateTime dec13Expiration = ub.ExpirationDate(2013, 12); Assert.AreEqual(new DateTime(2013, 12, 27), dec13Expiration); DateTime jan14Expiration = ub.ExpirationDate(2014, 1); Assert.AreEqual(new DateTime(2014, 1, 29), jan14Expiration); DateTime feb14Expiration = ub.ExpirationDate(2014, 2); Assert.AreEqual(new DateTime(2014, 2, 26), feb14Expiration); DateTime mar14Expiration = ub.ExpirationDate(2014, 3); Assert.AreEqual(new DateTime(2014, 3, 27), mar14Expiration); DateTime apr14Expiration = ub.ExpirationDate(2014, 4); Assert.AreEqual(new DateTime(2014, 4, 28), apr14Expiration); }
public EditRootSymbolWindow(UnderlyingSymbol symbol) { InitializeComponent(); DataContext = this; if (symbol == null) { TheSymbol = new UnderlyingSymbol { Rule = new ExpirationRule(), ID = -1 }; ModifyBtn.Content = "Add"; } else { _originalSymbol = symbol; TheSymbol = (UnderlyingSymbol)symbol.Clone(); ModifyBtn.Content = "Modify"; } //set the corrent radio box check if (TheSymbol.Rule.ReferenceDayIsLastBusinessDayOfMonth) { LastBusinessDayRadioBtn.IsChecked = true; } else if (TheSymbol.Rule.ReferenceUsesDays) { DaysBasedRefCheckBox.IsChecked = true; } else { WeeksBasedRefCheckBox.IsChecked = true; } }
public ITypeInfo?GetType(string fullName) { INamedTypeSymbol?type = UnderlyingSymbol.GetTypeByMetadataName(fullName); return(type is not null ? SymbolTypeInfo.CreateFrom(type, Compilation) : null); }
string ISymbol.GetDocumentationCommentXml( CultureInfo preferredCulture, bool expandIncludes, CancellationToken cancellationToken ) { return(UnderlyingSymbol.GetDocumentationCommentXml( preferredCulture, expandIncludes, cancellationToken )); }
public IGeneric Close(params ITypeInfo[] genericArgs) { if (UnderlyingSymbol.ContainingType is not null) { throw new NotSupportedException(); // TODO: implementalni ha hasznalni kell majd } return((IGeneric)CreateFrom ( UnderlyingSymbol.Construct ( genericArgs.Select(ga => ga.ToSymbol(Compilation)).ToArray() ), Compilation )); }
public void CorrectlyCalculatesVIXFuturesExpirationDates() { //The Wednesday that is thirty days prior to the third Friday of the calendar month //immediately following the month in which the contract expires ("Final Settlement Date"). //If the third Friday of the month subsequent to expiration of the applicable VIX futures //contract is a CBOE holiday, the Final Settlement Date for the contract shall be thirty days //prior to the CBOE business day immediately preceding that Friday. var vix = new UnderlyingSymbol(); vix.Rule = new ExpirationRule { DaysBefore = 30, DayType = DayType.Calendar, ReferenceRelativeMonth = RelativeMonth.NextMonth, ReferenceUsesDays = false, ReferenceWeekDay = DayOfTheWeek.Friday, ReferenceWeekDayCount = WeekDayCount.Third, ReferenceDayMustBeBusinessDay = true }; DateTime dec13Expiration = vix.ExpirationDate(2013, 12); Assert.AreEqual(new DateTime(2013, 12, 18), dec13Expiration); DateTime jan14Expiration = vix.ExpirationDate(2014, 1); Assert.AreEqual(new DateTime(2014, 1, 22), jan14Expiration); DateTime feb14Expiration = vix.ExpirationDate(2014, 2); Assert.AreEqual(new DateTime(2014, 2, 19), feb14Expiration); DateTime mar14Expiration = vix.ExpirationDate(2014, 3); Assert.AreEqual(new DateTime(2014, 3, 18), mar14Expiration); DateTime apr14Expiration = vix.ExpirationDate(2014, 4); Assert.AreEqual(new DateTime(2014, 4, 16), apr14Expiration); DateTime may14Expiration = vix.ExpirationDate(2014, 5); Assert.AreEqual(new DateTime(2014, 5, 21), may14Expiration); }
public IGenericTypeInfo Close(params ITypeInfo[] genericArgs) { if (UnderlyingSymbol.ContainingType is not null) { throw new NotSupportedException(); // TODO: implementalni ha hasznalni kell majd } ITypeSymbol[] gas = new ITypeSymbol[genericArgs.Length]; for (int i = 0; i < genericArgs.Length; i++) { gas[i] = genericArgs[i].ToSymbol(Compilation); } return((IGenericTypeInfo)CreateFrom ( UnderlyingSymbol.Construct(gas), Compilation )); }
public void CorrectlyCalculatesCMEWheatFuturesExpirationDates() { //The business day prior to the 15th calendar day of the contract month. var zw = new UnderlyingSymbol(); zw.Rule = new ExpirationRule { DaysBefore = 1, DayType = DayType.Business, ReferenceRelativeMonth = RelativeMonth.CurrentMonth, ReferenceUsesDays = true, ReferenceDays = 15 }; DateTime dec13Expiration = zw.ExpirationDate(2013, 12); Assert.AreEqual(new DateTime(2013, 12, 13), dec13Expiration); DateTime mar14Expiration = zw.ExpirationDate(2014, 3); Assert.AreEqual(new DateTime(2014, 3, 14), mar14Expiration); DateTime may14Expiration = zw.ExpirationDate(2014, 5); Assert.AreEqual(new DateTime(2014, 5, 14), may14Expiration); DateTime jul14Expiration = zw.ExpirationDate(2014, 7); Assert.AreEqual(new DateTime(2014, 7, 14), jul14Expiration); DateTime sep14Expiration = zw.ExpirationDate(2014, 9); Assert.AreEqual(new DateTime(2014, 9, 12), sep14Expiration); DateTime dec14Expiration = zw.ExpirationDate(2014, 12); Assert.AreEqual(new DateTime(2014, 12, 12), dec14Expiration); }
public void CorrectlyCalculatesCLFuturesExpirationDates() { //Trading in the current delivery month shall cease on the third business day prior to the //twenty-fifth calendar day of the month preceding the delivery month. If the twenty-fifth //calendar day of the month is a non-business day, trading shall cease on the third business //day prior to the last business day preceding the twenty-fifth calendar day. var cl = new UnderlyingSymbol(); cl.Rule = new ExpirationRule { DaysBefore = 3, DayType = DayType.Business, ReferenceRelativeMonth = RelativeMonth.PreviousMonth, ReferenceUsesDays = true, ReferenceDays = 25, ReferenceDayMustBeBusinessDay = true }; DateTime jan14Expiration = cl.ExpirationDate(2014, 1); Assert.AreEqual(new DateTime(2013, 12, 19), jan14Expiration); DateTime feb14Expiration = cl.ExpirationDate(2014, 2); Assert.AreEqual(new DateTime(2014, 1, 21), feb14Expiration); DateTime mar14Expiration = cl.ExpirationDate(2014, 3); Assert.AreEqual(new DateTime(2014, 2, 20), mar14Expiration); DateTime apr14Expiration = cl.ExpirationDate(2014, 4); Assert.AreEqual(new DateTime(2014, 3, 20), apr14Expiration); DateTime may14Expiration = cl.ExpirationDate(2014, 5); Assert.AreEqual(new DateTime(2014, 4, 22), may14Expiration); }
public void CorrectlyCalculates6EFuturesExpirationDates() { //9:16 a.m. Central Time (CT) on the second business day immediately preceding //the third Wednesday of the contract month (usually Monday). var eur = new UnderlyingSymbol(); eur.Rule = new ExpirationRule { DaysBefore = 2, DayType = DayType.Business, ReferenceRelativeMonth = RelativeMonth.CurrentMonth, ReferenceUsesDays = false, ReferenceWeekDay = DayOfTheWeek.Wednesday, ReferenceWeekDayCount = WeekDayCount.Third }; DateTime dec13Expiration = eur.ExpirationDate(2013, 12); Assert.AreEqual(new DateTime(2013, 12, 16), dec13Expiration); DateTime mar14Expiration = eur.ExpirationDate(2014, 3); Assert.AreEqual(new DateTime(2014, 3, 17), mar14Expiration); DateTime jun14Expiration = eur.ExpirationDate(2014, 6); Assert.AreEqual(new DateTime(2014, 6, 16), jun14Expiration); DateTime sep14Expiration = eur.ExpirationDate(2014, 9); Assert.AreEqual(new DateTime(2014, 9, 15), sep14Expiration); DateTime dec14Expiration = eur.ExpirationDate(2014, 12); Assert.AreEqual(new DateTime(2014, 12, 15), dec14Expiration); }
public bool IsFriend(string asmName) => StringComparer.OrdinalIgnoreCase.Equals(UnderlyingSymbol.Name, asmName) || UnderlyingSymbol.GivesAccessTo // TODO: strong name support ( CSharpCompilation.Create(asmName).Assembly );
public sealed override int GetHashCode() { return(UnderlyingSymbol.GetHashCode()); }
string ISymbol.GetDocumentationCommentId() { return(UnderlyingSymbol.GetDocumentationCommentId()); }
ImmutableArray <AttributeData> ISymbol.GetAttributes() { return(StaticCast <AttributeData> .From(UnderlyingSymbol.GetAttributes())); }
protected bool Equals(Symbol other, CodeAnalysis.SymbolEqualityComparer equalityComparer) { return(other is object && UnderlyingSymbol.Equals(other.UnderlyingSymbol, equalityComparer.CompareKind)); }
public UnderlyingSymbolsViewModel(IDataClient client, IDialogCoordinator dialogCoordinator) { UnderlyingSymbols = new ObservableCollection <UnderlyingSymbolViewModel>(); //Load the symbols Load = ReactiveCommand.CreateFromTask(async _ => { var result = await client.GetUnderlyingSymbols(); if (await result.DisplayErrors(this, dialogCoordinator)) { return(null); } return(result.Result); }); Load.Subscribe(symbols => { if (symbols == null) { return; } foreach (var vm in symbols.Select(x => new UnderlyingSymbolViewModel(x))) { UnderlyingSymbols.Add(vm); } }); //Add Add = ReactiveCommand.CreateFromTask(async _ => { var symbolName = await dialogCoordinator.ShowInputAsync(this, "Symbol Name", "Enter new symbol name"); if (string.IsNullOrEmpty(symbolName)) { return(null); } var newSymbol = new UnderlyingSymbol { Symbol = symbolName, Rule = new ExpirationRule() }; var response = await client.AddUnderlyingSymbol(newSymbol); if (await response.DisplayErrors(this, dialogCoordinator)) { return(null); } return(response.Result); }); Add.Where(x => x != null) .Subscribe(underlyingSymbol => { var vm = new UnderlyingSymbolViewModel(underlyingSymbol); UnderlyingSymbols.Add(vm); SelectedSymbol = vm; }); //Delete var deleteCanExecute = this .WhenAnyValue(x => x.SelectedSymbol) .Select(x => x != null); Delete = ReactiveCommand.CreateFromTask(async _ => { var sureDelete = await dialogCoordinator.ShowMessageAsync(this, "Delete", $"Are you sure you want to delete {SelectedSymbol.Symbol}?", MessageDialogStyle.AffirmativeAndNegative); if (sureDelete == MessageDialogResult.Negative) { return; } var response = await client.DeleteUnderlyingSymbol(SelectedSymbol.Model); if (await response.DisplayErrors(this, dialogCoordinator)) { return; } UnderlyingSymbols.Remove(SelectedSymbol); SelectedSymbol = null; }, deleteCanExecute); //Save var saveCanExecute = this .WhenAnyValue(x => x.SelectedSymbol, x => x.SelectedSymbolHasErrors, (symbol, hasError) => new { symbol, hasError }) .Select(x => x.symbol != null && x.hasError == false); Save = ReactiveCommand.CreateFromTask(async _ => { var response = await client.UpdateUnderlyingSymbol(SelectedSymbol.Model); await response.DisplayErrors(this, dialogCoordinator); }, saveCanExecute); }
/// <summary> /// Delete an underlying symbol /// </summary> public async Task <ApiResponse <UnderlyingSymbol> > DeleteUnderlyingSymbol(UnderlyingSymbol symbol) => await _apiClient.DeleteAsync <UnderlyingSymbol>($"/underlyingsymbols/{symbol?.ID}").ConfigureAwait(false);
/// <summary> /// Update an existing underlying symbol /// </summary> public async Task <ApiResponse <UnderlyingSymbol> > UpdateUnderlyingSymbol(UnderlyingSymbol symbol) => await _apiClient.PutAsync <UnderlyingSymbol>("/underlyingsymbols", symbol).ConfigureAwait(false);
/// <remarks> /// Used only for testing. /// </remarks> public override string ToString() { return(UnderlyingSymbol.ToDisplayString(SymbolDisplayFormat.ILVisualizationFormat)); }
public UnderlyingSymbolModule(IMyDbContext context) : base("/underlyingsymbols") { this.RequiresAuthentication(); var dbSet = context.Set <UnderlyingSymbol>(); Get("/", _ => dbSet.ToList()); Get("/{Id:int}", parameters => { var id = (int)parameters.Id; var exchange = dbSet.FirstOrDefault(x => x.ID == id); if (exchange == null) { return(HttpStatusCode.NotFound); } return(exchange); }); Put("/", _ => { UnderlyingSymbol newValues = this.BindAndValidate <UnderlyingSymbol>(); if (ModelValidationResult.IsValid == false) { return(this.ValidationFailure()); } //make sure the exchange we want to update exists var symbol = dbSet.FirstOrDefault(x => x.ID == newValues.ID); if (symbol == null) { return(HttpStatusCode.NotFound); } //update values on the exchange context.UpdateEntryValues(symbol, newValues); context.SaveChanges(); return(symbol); }); Post("/", _ => { UnderlyingSymbol symbol = this.BindAndValidate <UnderlyingSymbol>(); if (ModelValidationResult.IsValid == false) { return(this.ValidationFailure()); } dbSet.Add(symbol); context.SaveChanges(); //return the object with the id after inserting return(symbol); }); Delete("/{Id:int}", parameters => { int id = parameters.Id; var symbol = dbSet.FirstOrDefault(x => x.ID == id); if (symbol == null) { return(HttpStatusCode.NotFound); } var symbolReferenced = context.Set <ContinuousFuture>().Any(x => x.UnderlyingSymbolID == id); if (symbolReferenced) { return(Negotiate .WithModel(new ErrorResponse( HttpStatusCode.Conflict, "Can't delete this underlying symbol because it has continuous futures assigned to it.", "")) .WithStatusCode(HttpStatusCode.Conflict)); } dbSet.Remove(symbol); context.SaveChanges(); return(symbol); }); }
public bool IsFriend(string asmName) => UnderlyingSymbol.Name == asmName || UnderlyingSymbol.GivesAccessTo // TODO: strong name support ( CSharpCompilation.Create(asmName).Assembly );