Skip to content

Commit

Permalink
fix(options): re-export missing types (#797)
Browse files Browse the repository at this point in the history
  • Loading branch information
gadicc committed Sep 29, 2024
1 parent 762bbc6 commit e96395f
Showing 1 changed file with 34 additions and 21 deletions.
55 changes: 34 additions & 21 deletions src/modules/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { Value } from "@sinclair/typebox/value";
/*
* Guaranteed fields, even we don't ask for them
*/
const QuoteCryptoCurrency = Type.Composite(
const QuoteCryptoCurrencySchema = Type.Composite(
[
QuoteBase,
Type.Object({
Expand All @@ -44,8 +44,11 @@ const QuoteCryptoCurrency = Type.Composite(
],
{ title: "QuoteCryptoCurrency" },
);
export type QuoteCryptoCurrency = StaticDecode<
typeof QuoteCryptoCurrencySchema
>;

const QuoteCurrency = Type.Composite(
const QuoteCurrencySchema = Type.Composite(
[
QuoteBase,
Type.Object({
Expand All @@ -54,15 +57,17 @@ const QuoteCurrency = Type.Composite(
],
{ title: "QuoteCurrency" },
);
export type QuoteCurrency = StaticDecode<typeof QuoteCurrencySchema>;

const QuoteEtf = Type.Composite([
const QuoteEtfSchema = Type.Composite([
QuoteBase,
Type.Object({
quoteType: Type.Literal("ETF"),
}),
]);
export type QuoteEtf = StaticDecode<typeof QuoteEtfSchema>;

const QuoteEquity = Type.Composite(
const QuoteEquitySchema = Type.Composite(
[
QuoteBase,
Type.Object({
Expand All @@ -73,8 +78,9 @@ const QuoteEquity = Type.Composite(
],
{ title: "QuoteEquity" },
);
export type QuoteEquity = StaticDecode<typeof QuoteEquitySchema>;

const QuoteFuture = Type.Composite(
const QuoteFutureSchema = Type.Composite(
[
QuoteBase,
Type.Object({
Expand All @@ -90,8 +96,9 @@ const QuoteFuture = Type.Composite(
title: "QuoteFuture",
},
);
export type QuoteFuture = StaticDecode<typeof QuoteFutureSchema>;

const QuoteIndex = Type.Composite(
const QuoteIndexSchema = Type.Composite(
[
QuoteBase,
Type.Object({
Expand All @@ -102,8 +109,9 @@ const QuoteIndex = Type.Composite(
title: "QuoteIndex",
},
);
export type QuoteIndex = StaticDecode<typeof QuoteIndexSchema>;

const QuoteOption = Type.Composite(
const QuoteOptionSchema = Type.Composite(
[
QuoteBase,
Type.Object({
Expand All @@ -119,8 +127,9 @@ const QuoteOption = Type.Composite(
title: "QuoteOption",
},
);
export type QuoteOption = StaticDecode<typeof QuoteOptionSchema>;

const QuoteMutualfund = Type.Composite(
const QuoteMutualfundSchema = Type.Composite(
[
QuoteBase,
Type.Object({
Expand All @@ -131,24 +140,26 @@ const QuoteMutualfund = Type.Composite(
title: "QuoteMutualFund",
},
);
export type QuoteMutualfund = StaticDecode<typeof QuoteMutualfundSchema>;

const QuoteSchema = Type.Union(
[
QuoteCryptoCurrency,
QuoteCurrency,
QuoteEtf,
QuoteEquity,
QuoteFuture,
QuoteIndex,
QuoteMutualfund,
QuoteOption,
QuoteCryptoCurrencySchema,
QuoteCurrencySchema,
QuoteEtfSchema,
QuoteEquitySchema,
QuoteFutureSchema,
QuoteIndexSchema,
QuoteMutualfundSchema,
QuoteOptionSchema,
],
{
title: "Quote",
},
);
export type Quote = StaticDecode<typeof QuoteSchema>;

const CallOrPut = Type.Object(
const CallOrPutSchema = Type.Object(
{
contractSymbol: Type.String(),
strike: YahooNumber,
Expand All @@ -171,19 +182,21 @@ const CallOrPut = Type.Object(
title: "CallOrPut",
},
);
export type CallOrPut = StaticDecode<typeof CallOrPutSchema>;

const Option = Type.Object(
const OptionSchema = Type.Object(
{
expirationDate: YahooFinanceDate,
hasMiniOptions: Type.Boolean(),
calls: Type.Array(CallOrPut),
puts: Type.Array(CallOrPut),
calls: Type.Array(CallOrPutSchema),
puts: Type.Array(CallOrPutSchema),
},
{
additionalProperties: Type.Any(),
title: "Option",
},
);
export type Option = StaticDecode<typeof OptionSchema>;

const OptionsResultSchema = Type.Object(
{
Expand All @@ -192,7 +205,7 @@ const OptionsResultSchema = Type.Object(
strikes: Type.Array(YahooNumber),
hasMiniOptions: Type.Boolean(),
quote: QuoteSchema,
options: Type.Array(Option),
options: Type.Array(OptionSchema),
},
{
additionalProperties: Type.Any(),
Expand Down

0 comments on commit e96395f

Please sign in to comment.