Skip to content

Commit

Permalink
Added SymbolOptionResponse and the functionality to return data based…
Browse files Browse the repository at this point in the history
… on the REST API (#126)
  • Loading branch information
chuckbeasley authored Jul 28, 2022
1 parent 8762126 commit e3b4ac7
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;

namespace IEXSharp.Model.CoreData.ReferenceData.Response
{
public class SymbolOptionResponse
{
public string symbol { get; set; }
public DateTime date { get; set; }
public string name { get; set; }
public string description { get; set; }
public DateTime expirationDate { get; set; }
public string type { get; set; }
public string side { get; set; }
public string exercise { get; set; }
public decimal strike { get; set; }
public string underlying { get; set; }
public string region { get; set; }
public string currency { get; set; }
public string figi { get; set; }
public int contractSize { get; set; }
public string cfiCode { get; set; }
public string exchange { get; set; }
public string exchangeName { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ public interface IReferenceDataService
/// </summary>
/// <returns></returns>
Task<IEXResponse<Dictionary<string, string[]>>> SymbolsOptionsAsync();

Task<IEXResponse<IEnumerable<SymbolOptionResponse>>> SymbolsOptionsAsync(string optionName);
Task<IEXResponse<IEnumerable<SymbolOptionResponse>>> SymbolsOptionsAsync(string optionName, string expiration);
/// <summary>
/// <see cref="https://iexcloud.io/docs/api/#otc-symbols"/>
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,32 @@ public async Task<IEXResponse<IEnumerable<HolidaysAndTradingDatesUSResponse>>> H

return await executor.ExecuteAsync<IEnumerable<HolidaysAndTradingDatesUSResponse>>(urlPattern, pathNvc, qsb);
}

public async Task<IEXResponse<IEnumerable<SymbolOptionResponse>>> SymbolsOptionsAsync(string optionName)
{
const string urlPattern = "ref-data/options/symbols/[optionName]";
var qsb = new QueryStringBuilder();

var pathNvc = new NameValueCollection
{
{"optionName", optionName}
};

return await executor.ExecuteAsync<IEnumerable<SymbolOptionResponse>>(urlPattern, pathNvc, qsb);
}

public async Task<IEXResponse<IEnumerable<SymbolOptionResponse>>> SymbolsOptionsAsync(string optionName, string expiration)
{
const string urlPattern = "ref-data/options/symbols/[optionName]/[expiration]";
var qsb = new QueryStringBuilder();

var pathNvc = new NameValueCollection
{
{"optionName", optionName},
{"expiration", expiration }
};

return await executor.ExecuteAsync<IEnumerable<SymbolOptionResponse>>(urlPattern, pathNvc, qsb);
}
}
}
32 changes: 32 additions & 0 deletions IEXSharpTest/Cloud/CoreData/ReferenceDataTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,38 @@ public async Task SymbolsOptionsAsyncTest()
Assert.GreaterOrEqual(response.Data.Count(), 1);
}

[Test]
public async Task SymbolsOptionsAsyncTest2()
{
var response = await sandBoxClient.ReferenceData.SymbolsOptionsAsync("vixm");

Assert.IsNull(response.ErrorMessage);
Assert.IsNotNull(response.Data);
Assert.GreaterOrEqual(response.Data.Count(), 1);

Assert.IsNotNull(response.Data.First().expirationDate);
Assert.IsNotNull(response.Data.First().cfiCode);
Assert.IsNotNull(response.Data.First().exercise);
Assert.IsNotNull(response.Data.First().contractSize);
Assert.IsNotNull(response.Data.First().currency);
}

[Test]
public async Task SymbolsOptionsAsyncTest3()
{
var response = await sandBoxClient.ReferenceData.SymbolsOptionsAsync("vixm", "20230317");

Assert.IsNull(response.ErrorMessage);
Assert.IsNotNull(response.Data);
Assert.GreaterOrEqual(response.Data.Count(), 1);

Assert.IsNotNull(response.Data.First().expirationDate);
Assert.IsNotNull(response.Data.First().cfiCode);
Assert.IsNotNull(response.Data.First().exercise);
Assert.IsNotNull(response.Data.First().contractSize);
Assert.IsNotNull(response.Data.First().currency);
}

[Test]
public async Task SymbolsOTCAsyncTest()
{
Expand Down

0 comments on commit e3b4ac7

Please sign in to comment.