Skip to content
Merged
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
12 changes: 3 additions & 9 deletions apps/sim/tools/kalshi/get_balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ export interface KalshiGetBalanceResponse {
success: boolean
output: {
balance: number // In cents
portfolioValue?: number // In cents
balanceDollars: number // Converted to dollars
portfolioValueDollars?: number // Converted to dollars
portfolioValue: number // In cents
}
}

Expand Down Expand Up @@ -51,24 +49,20 @@ export const kalshiGetBalanceTool: ToolConfig<KalshiGetBalanceParams, KalshiGetB
handleKalshiError(data, response.status, 'get_balance')
}

const balance = data.balance || 0
const portfolioValue = data.portfolio_value
const balance = data.balance ?? 0
const portfolioValue = data.portfolio_value ?? 0

return {
success: true,
output: {
balance,
portfolioValue,
balanceDollars: balance / 100,
portfolioValueDollars: portfolioValue ? portfolioValue / 100 : undefined,
},
}
},

outputs: {
balance: { type: 'number', description: 'Account balance in cents' },
portfolioValue: { type: 'number', description: 'Portfolio value in cents' },
balanceDollars: { type: 'number', description: 'Account balance in dollars' },
portfolioValueDollars: { type: 'number', description: 'Portfolio value in dollars' },
},
}
2 changes: 1 addition & 1 deletion apps/sim/tools/kalshi/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export interface KalshiEvent {
// Balance type
export interface KalshiBalance {
balance: number // In cents
portfolio_value?: number // In cents
portfolio_value: number // In cents
}

// Position type
Expand Down