adding data-services
This commit is contained in:
parent
e3bfd05b90
commit
405b818c86
139 changed files with 55943 additions and 416 deletions
68
libs/api-client/README.md
Normal file
68
libs/api-client/README.md
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
# API Client Library
|
||||
|
||||
Type-safe HTTP clients for inter-service communication in the stock-bot project.
|
||||
|
||||
## Available Clients
|
||||
|
||||
### BacktestClient
|
||||
|
||||
Client for interacting with the Backtest Engine service:
|
||||
|
||||
```typescript
|
||||
import { createBacktestClient } from '@stock-bot/api-client';
|
||||
|
||||
// Create a client instance
|
||||
const backtestClient = createBacktestClient('http://localhost:4002');
|
||||
|
||||
// Run a backtest
|
||||
const result = await backtestClient.runBacktest({
|
||||
strategyId: '123',
|
||||
startDate: new Date('2023-01-01'),
|
||||
endDate: new Date('2023-12-31'),
|
||||
symbols: ['AAPL', 'MSFT', 'GOOG'],
|
||||
initialCapital: 100000,
|
||||
parameters: {
|
||||
riskFactor: 0.5,
|
||||
positionSizeLimit: 0.1
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
### StrategyClient
|
||||
|
||||
Client for interacting with the Strategy Orchestrator service:
|
||||
|
||||
```typescript
|
||||
import { createStrategyClient } from '@stock-bot/api-client';
|
||||
|
||||
// Create a client instance
|
||||
const strategyClient = createStrategyClient('http://localhost:4001');
|
||||
|
||||
// Get a strategy by ID
|
||||
const strategy = await strategyClient.getStrategy('123');
|
||||
|
||||
// Update a strategy
|
||||
await strategyClient.updateStrategy('123', {
|
||||
parameters: {
|
||||
lookbackPeriod: 20,
|
||||
threshold: 0.02
|
||||
}
|
||||
});
|
||||
|
||||
// Enable a strategy
|
||||
await strategyClient.enableStrategy('123');
|
||||
```
|
||||
|
||||
## Creating Custom Clients
|
||||
|
||||
Extend the `BaseApiClient` to create clients for other services:
|
||||
|
||||
```typescript
|
||||
import { BaseApiClient } from '@stock-bot/api-client';
|
||||
|
||||
class RiskGuardianClient extends BaseApiClient {
|
||||
async getRiskLimits(portfolioId: string) {
|
||||
return this.client.get(`/api/risk/limits/${portfolioId}`);
|
||||
}
|
||||
}
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue