Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions TradierClient.Test/Tests/MarketDataTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,34 @@ public void Setup()
}

[Test]
[TestCase("CKH", false)]
[TestCase("TSLA", false)]
public async Task PostGetQuotesForSingleSymbol(string symbols, bool greeks)
{
var result = await _client.MarketData.PostGetQuotes(symbols, greeks);
Assert.IsNotNull(result.Quote.First());
Assert.AreEqual(1, result.Quote.Count);
}
Assert.IsNull(result.Quote.First().Greeks);
}

[Test]
[TestCase("TSLA230120C00900000", true)]
public async Task PostGetQuotesAndGreeksForOptionSymbol(string symbols, bool greeks)
{
var result = await _client.MarketData.PostGetQuotes(symbols, greeks);
Assert.IsNotNull(result.Quote.First());
Assert.AreEqual(1, result.Quote.Count);
Assert.IsNotNull(result.Quote.First().Greeks);
}

[Test]
[TestCase("TSLA230120C00900000", false)]
public async Task PostGetQuotesForOptionSymbol(string symbols, bool greeks)
{
var result = await _client.MarketData.PostGetQuotes(symbols, greeks);
Assert.IsNotNull(result.Quote.First());
Assert.AreEqual(1, result.Quote.Count);
Assert.IsNull(result.Quote.First().Greeks);
}

[Test]
[TestCase("GME", "daily")]
Expand Down
29 changes: 23 additions & 6 deletions TradierClient/Models/MarketData/Quote.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using Tradier.Client.Helpers;

namespace Tradier.Client.Models.MarketData
{

public class QuoteRootobject
{
[JsonProperty("quotes")]
Expand All @@ -19,8 +19,10 @@ public class Quotes
}

public class Quote
{
[JsonProperty("symbol")]
{
public static readonly DateTime UnixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);

[JsonProperty("symbol")]
public string Symbol { get; set; }

[JsonProperty("description")]
Expand Down Expand Up @@ -71,6 +73,9 @@ public class Quote
[JsonProperty("trade_date")]
public long TradeDate { get; set; }

[JsonIgnore]
public DateTime TradeDateTime => UnixEpoch.AddMilliseconds(TradeDate);

[JsonProperty("prevclose")]
public float? Prevclose { get; set; }

Expand All @@ -89,7 +94,10 @@ public class Quote
[JsonProperty("bid_date")]
public long BidDate { get; set; }

[JsonProperty("asksize")]
[JsonIgnore]
public DateTime BidDateTime => UnixEpoch.AddMilliseconds(BidDate);

[JsonProperty("asksize")]
public int Asksize { get; set; }

[JsonProperty("askexch")]
Expand All @@ -98,7 +106,10 @@ public class Quote
[JsonProperty("ask_date")]
public long AskDate { get; set; }

[JsonProperty("root_symbols")]
[JsonIgnore]
public DateTime AskDateTime => UnixEpoch.AddMilliseconds(AskDate);

[JsonProperty("root_symbols")]
public string RootSymbols { get; set; }

[JsonProperty("underlying")]
Expand All @@ -116,13 +127,19 @@ public class Quote
[JsonProperty("expiration_date")]
public string ExpirationDate { get; set; }

[JsonProperty("expiration_type")]
[JsonIgnore]
public DateTime ExpirationDateTime => DateTime.Parse(ExpirationDate);

[JsonProperty("expiration_type")]
public string ExpirationType { get; set; }

[JsonProperty("option_type")]
public string OptionType { get; set; }

[JsonProperty("root_symbol")]
public string RootSymbol { get; set; }

[JsonProperty("greeks")]
public Greeks Greeks { get; set; }
}
}
6 changes: 3 additions & 3 deletions TradierClient/TradierClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<RepositoryType>Git</RepositoryType>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>1.0.11</Version>
<AssemblyVersion>1.0.11.0</AssemblyVersion>
<FileVersion>1.0.11.0</FileVersion>
<Version>1.0.13</Version>
<AssemblyVersion>1.0.13.0</AssemblyVersion>
<FileVersion>1.0.13.0</FileVersion>
<PackageTags>Trading StockMarket Investing Brokerage API .NET C#</PackageTags>
</PropertyGroup>

Expand Down