mya-cli
Version:
MYA - AI-Powered Stock & Options Analysis CLI Tool
207 lines (206 loc) • 4.76 kB
TypeScript
/**
* Common TypeScript interfaces and types for the application
*/
/**
* AI service interface without dependency on specific implementation
*/
export interface Ai {
run: (_options: Record<string, unknown>) => Promise<Record<string, unknown>>;
}
/**
* Interface for Cloudflare KV namespace
*/
export interface KVNamespace {
get: (key: string, options?: {
type?: string;
}) => Promise<string | null>;
put: (key: string, value: string, options?: {
expirationTtl?: number;
}) => Promise<void>;
delete: (key: string) => Promise<void>;
}
/**
* Interface for Auth Environment
*/
export interface AuthEnvironment {
CACHE?: KVNamespace;
STYTCH_SECRET?: string;
STYTCH_PROJECT_ID?: string;
STYTCH_ENV?: string;
MYA_API_URL?: string;
POLYGON_API_KEY?: string;
ALPHAVANTAGE_API_KEY?: string;
JWT_SECRET?: string;
}
/**
* Stock data interface for volatility analysis
*/
export interface StockData {
ticker: string;
price?: number;
volume?: number;
volatility?: number;
beta?: number;
volumeSpikeRatio?: number;
stdDevReturns?: number;
name?: string;
sector?: string;
marketCap?: number;
newsSentiment?: number;
technicalIndicators?: {
rsi: number;
macd: number;
bollingerBands: {
upper: number;
middle: number;
lower: number;
};
};
fundamentals?: {
marketCap: number;
peRatio: number;
dividendYield: number;
};
sentiment?: {
score: number;
articles: Array<{
title: string;
summary: string;
sentiment: string;
}>;
};
[key: string]: unknown;
}
/**
* Strategy context data
*/
export interface StrategyContext {
contextType: string;
data: Record<string, unknown>;
}
/**
* Recommendation interface with doubling assessment
*/
export interface StockRecommendation {
symbol: string;
action: string;
targetPrice: string;
sentiment: string;
doublingProbability: string;
canDoubleInvestment: boolean;
timeFrameForDoubling: string;
recommendedOptionStrategy: string;
[key: string]: unknown;
}
/**
* Strategy result interface
*/
export interface StrategyResult {
strategy: string;
reasoning: string;
riskLevel: string;
potentialReturn: string;
timeframe: string;
recommendations: StockRecommendation[];
[key: string]: unknown;
}
/**
* Extended Request interface with environment and AI properties
*/
export interface ExtendedRequest extends Request {
env?: {
MYA_API_URL?: string;
POLYGON_API_KEY?: string;
ALPHAVANTAGE_API_KEY?: string;
STYTCH_SECRET?: string;
STYTCH_PROJECT_ID?: string;
CACHE?: KVNamespace;
ai?: Ai;
};
ai?: Ai;
}
/**
* Common interface for earnings data
*/
export interface EarningsData {
ticker: string;
company_name: string;
current_price: number;
market_cap: string | number;
historicalMoves: string[];
expectedMove?: string;
impliedMove?: string;
earningsDate?: string;
successProbability?: number;
profitPotential?: number;
[key: string]: unknown;
}
/**
* Interface for Aggregate Bar data returned by Polygon API
*/
export interface AggregateBar {
c: number;
h: number;
l: number;
o: number;
v: number;
t: number;
vw?: number;
[key: string]: unknown;
}
/**
* Interface for Aggregate results
*/
export interface AggregatesResponse {
ticker?: string;
status?: string;
adjusted?: boolean;
queryCount?: number;
resultsCount?: number;
request_id?: string;
results?: AggregateBar[];
count?: number;
[key: string]: unknown;
}
/**
* Interface for option contracts
*/
export interface OptionContract {
strike_price: number;
expiration_date: string;
contract_type: string;
contract_name: string;
underlying_price?: number;
ticker?: string;
underlying_ticker?: string;
exercise_style?: string;
shares_per_contract?: number;
[key: string]: unknown;
}
/**
* Interface for option contracts response
*/
export interface OptionContractsResponse {
status?: string;
request_id?: string;
results?: OptionContract[];
count?: number;
next_url?: string;
[key: string]: unknown;
}
/**
* Interface for company details
*/
export interface CompanyDetails {
ticker: string;
name?: string;
market_cap?: number;
description?: string;
sic_description?: string;
homepage_url?: string;
total_employees?: number;
list_date?: string;
locale?: string;
primary_exchange?: string;
[key: string]: unknown;
}