/// <summary> /// Retrieve market hours for specified single market /// </summary> public async Task <string> GetMarketHoursJson(MarketTypes type, DateTime day) { if (!IsSignedIn) { throw (new Exception("ConsumerKey is null")); } var key = HttpUtility.UrlEncode(AuthResult.consumer_key); var dayString = day.ToString("yyyy-MM-dd").Replace("/", "-"); string path = IsSignedIn ? $"https://api.tdameritrade.com/v1/marketdata/{type}/hours?date={dayString}" : $"https://api.tdameritrade.com/v1/marketdata/{type}/hours?apikey={key}&date={dayString}"; using (var client = new HttpClient()) { if (IsSignedIn) { client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AuthResult.access_token); } var res = await client.GetAsync(path); switch (res.StatusCode) { case HttpStatusCode.OK: return(await res.Content.ReadAsStringAsync()); default: throw (new Exception($"{res.StatusCode} {res.ReasonPhrase}")); } } }
private void executeValidateOrderType(GridCellValidationEventArgs eventArgs) { if (eventArgs.Value == null) { eventArgs.IsValid = false; eventArgs.SetError("Invalid item."); return; } string value = eventArgs.Value.ToString(); InvType item = MarketTypes.SingleOrDefault(f => f.TypeName == value); if (item == null) { eventArgs.IsValid = false; eventArgs.SetError("Invalid item."); } else { if (Orders.SingleOrDefault(order => order.Order.TypeId == item.TypeId) != null) { eventArgs.IsValid = false; eventArgs.SetError("An order for this item already exists."); } else { ((OrderVm)eventArgs.Row).Order.TypeId = item.TypeId; ((OrderVm)eventArgs.Row).Order.InvType = item; } } }
public Market(string id, string marketIdentifierCode, string name, MarketTypes type) { this.Id = id ?? string.Empty; this.MarketIdentifierCode = marketIdentifierCode ?? string.Empty; this.Name = name ?? string.Empty; this.Type = type; }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { // credit: http://stackoverflow.com/a/263416/677735 unchecked // Overflow is fine, just wrap { var hash = 41; // Suitable nullity checks etc, of course :) if (CountryCodes != null) { hash = hash * 59 + CountryCodes.GetHashCode(); } if (BettingTypes != null) { hash = hash * 59 + BettingTypes.GetHashCode(); } if (TurnInPlayEnabled != null) { hash = hash * 59 + TurnInPlayEnabled.GetHashCode(); } if (MarketTypes != null) { hash = hash * 59 + MarketTypes.GetHashCode(); } if (Venues != null) { hash = hash * 59 + Venues.GetHashCode(); } if (MarketIds != null) { hash = hash * 59 + MarketIds.GetHashCode(); } if (EventTypeIds != null) { hash = hash * 59 + EventTypeIds.GetHashCode(); } if (EventIds != null) { hash = hash * 59 + EventIds.GetHashCode(); } if (BspMarket != null) { hash = hash * 59 + BspMarket.GetHashCode(); } return(hash); } }
/// <summary> /// Retrieve market hours for specified single market /// </summary> public async Task <TDMarketHour> GetMarketHours(MarketTypes type, DateTime day) { var json = await GetMarketHoursJson(type, day); if (!IsNullOrEmpty(json)) { var doc = JObject.Parse(json); return(doc.First.First.First.First.ToObject <TDMarketHour>()); } return(null); }
/// <summary> /// Returns true if MarketFilter instances are equal /// </summary> /// <param name="other">Instance of MarketFilter to be compared</param> /// <returns>Boolean</returns> public bool Equals(MarketFilter other) { // credit: http://stackoverflow.com/a/10454552/677735 if (other == null) { return(false); } return((CountryCodes == other.CountryCodes || CountryCodes != null && CountryCodes.SequenceEqual(other.CountryCodes)) && (BettingTypes == other.BettingTypes || BettingTypes != null && BettingTypes.SequenceEqual(other.BettingTypes)) && (TurnInPlayEnabled == other.TurnInPlayEnabled || TurnInPlayEnabled != null && TurnInPlayEnabled.Equals(other.TurnInPlayEnabled)) && (MarketTypes == other.MarketTypes || MarketTypes != null && MarketTypes.SequenceEqual(other.MarketTypes)) && (Venues == other.Venues || Venues != null && Venues.SequenceEqual(other.Venues)) && (MarketIds == other.MarketIds || MarketIds != null && MarketIds.SequenceEqual(other.MarketIds)) && (EventTypeIds == other.EventTypeIds || EventTypeIds != null && EventTypeIds.SequenceEqual(other.EventTypeIds)) && (EventIds == other.EventIds || EventIds != null && EventIds.SequenceEqual(other.EventIds)) && (BspMarket == other.BspMarket || BspMarket != null && BspMarket.Equals(other.BspMarket))); }
public MarketFilter WithMarketType(string marketType) { MarketTypes ??= new HashSet <string>(); MarketTypes.Add(marketType); return(this); }