2023-11-14 16:15:11 +01:00
# @fin.cx/opendata
2025-07-13 15:08:19 +00:00
🚀 **Real-time financial data and German business intelligence in one powerful TypeScript library**
2023-11-14 16:15:11 +01:00
2025-07-13 15:08:19 +00:00
Access live stock prices, cryptocurrencies, forex, commodities AND comprehensive German company data - all through a single, unified API.
2024-12-31 14:43:08 +01:00
2025-07-13 15:08:19 +00:00
## Installation
2025-04-09 06:26:52 +00:00
2025-07-13 15:08:19 +00:00
```bash
npm install @fin .cx/opendata
# or
yarn add @fin .cx/opendata
2025-04-09 08:40:23 +00:00
```
2025-04-09 06:26:52 +00:00
2025-07-13 15:08:19 +00:00
## Quick Start
2024-12-31 14:43:08 +01:00
2025-07-13 15:08:19 +00:00
### 📈 Real-Time Stock Data
2024-12-31 14:43:08 +01:00
2025-07-13 15:08:19 +00:00
Get live market data in seconds:
2024-12-31 19:58:18 +01:00
2024-12-31 14:43:08 +01:00
```typescript
2025-07-13 15:08:19 +00:00
import { StockPriceService, YahooFinanceProvider } from '@fin .cx/opendata';
2024-12-31 14:43:08 +01:00
2025-07-13 15:08:19 +00:00
// Initialize the service
const stockService = new StockPriceService();
stockService.register(new YahooFinanceProvider());
2024-12-31 14:43:08 +01:00
2025-07-13 15:08:19 +00:00
// Get single stock price
const apple = await stockService.getPrice({ ticker: 'AAPL' });
console.log(`Apple: $${apple.price} (${apple.changePercent.toFixed(2)}%)` );
2024-12-31 14:43:08 +01:00
2025-07-13 15:08:19 +00:00
// Get multiple prices at once
const prices = await stockService.getPrices({
tickers: ['AAPL', 'MSFT', 'GOOGL', 'BTC-USD', 'ETH-USD']
});
2024-12-31 14:43:08 +01:00
2025-07-13 15:08:19 +00:00
// Market indices, crypto, forex, commodities - all supported!
const marketData = await stockService.getPrices({
tickers: ['^GSPC', '^DJI', 'BTC-USD', 'EURUSD=X', 'GC=F']
});
2024-12-31 14:43:08 +01:00
```
2025-07-13 15:08:19 +00:00
### 🏢 German Business Data
2025-04-09 06:26:52 +00:00
2025-07-13 15:08:19 +00:00
Access comprehensive data on German companies:
2024-12-31 14:43:08 +01:00
2024-12-31 19:58:18 +01:00
```typescript
2025-04-09 06:26:52 +00:00
import { OpenData } from '@fin .cx/opendata';
2024-12-31 19:58:18 +01:00
2025-07-13 15:08:19 +00:00
const openData = new OpenData();
await openData.start();
2025-04-09 06:26:52 +00:00
2025-07-13 15:08:19 +00:00
// Create a business record
const company = new openData.CBusinessRecord();
company.data = {
name: "TechStart GmbH",
city: "Berlin",
registrationId: "HRB 123456",
// ... more fields
2025-04-09 06:26:52 +00:00
};
2025-07-13 15:08:19 +00:00
await company.save();
2025-04-09 06:26:52 +00:00
2025-07-13 15:08:19 +00:00
// Search companies by city
const berlinCompanies = await openData.db
.collection('businessrecords')
.find({ city: "Berlin" })
.toArray();
2025-04-09 06:26:52 +00:00
2025-07-13 15:08:19 +00:00
// Import bulk data from official sources
await openData.buildInitialDb();
2024-12-31 19:58:18 +01:00
```
2025-07-13 15:08:19 +00:00
## Features
2025-04-09 06:26:52 +00:00
2025-07-13 15:08:19 +00:00
### 🎯 Stock Market Module
2025-04-09 06:26:52 +00:00
2025-07-13 15:08:19 +00:00
- **Real-time prices** for stocks, ETFs, indices, crypto, forex, and commodities
- **Batch operations** - fetch 100+ symbols in one request
- **Smart caching** - configurable TTL, automatic invalidation
- **Provider system** - easily extensible for new data sources
- **Automatic retries** and fallback mechanisms
- **Type-safe** - full TypeScript support with detailed interfaces
2025-04-09 06:26:52 +00:00
2025-07-13 15:08:19 +00:00
### 🇩🇪 German Business Intelligence
2025-04-09 06:26:52 +00:00
2025-07-13 15:08:19 +00:00
- **MongoDB integration** for scalable data storage
- **Bulk JSONL import** from official German data sources
- **Handelsregister automation** - automated document retrieval
- **CRUD operations** with validation
- **Streaming processing** for multi-GB datasets
2024-12-31 19:58:18 +01:00
2025-07-13 15:08:19 +00:00
## Advanced Examples
2025-04-09 06:26:52 +00:00
2025-07-13 15:08:19 +00:00
### Market Dashboard
2025-04-09 06:26:52 +00:00
2025-07-13 15:08:19 +00:00
Create a real-time market overview:
2024-12-31 19:58:18 +01:00
```typescript
2025-07-13 15:08:19 +00:00
const indicators = [
// Indices
{ ticker: '^GSPC', name: 'S& P 500' },
{ ticker: '^IXIC', name: 'NASDAQ' },
// Tech Giants
{ ticker: 'AAPL', name: 'Apple' },
{ ticker: 'MSFT', name: 'Microsoft' },
// Crypto
{ ticker: 'BTC-USD', name: 'Bitcoin' },
{ ticker: 'ETH-USD', name: 'Ethereum' },
// Commodities
{ ticker: 'GC=F', name: 'Gold' },
{ ticker: 'CL=F', name: 'Oil' }
];
2024-12-31 14:43:08 +01:00
2025-07-13 15:08:19 +00:00
const prices = await stockService.getPrices({
tickers: indicators.map(i => i.ticker)
});
2025-04-09 06:26:52 +00:00
2025-07-13 15:08:19 +00:00
// Display with color-coded changes
prices.forEach(price => {
const indicator = indicators.find(i => i.ticker === price.ticker);
const arrow = price.change >= 0 ? '↑' : '↓';
const color = price.change >= 0 ? '\x1b[32m' : '\x1b[31m';
console.log(
`${indicator.name.padEnd(15)} ${price.price.toFixed(2).padStart(10)} ` +
`${color}${arrow} ${price.changePercent.toFixed(2)}%\x1b[0m`
);
});
2025-04-09 06:26:52 +00:00
```
2025-07-13 15:08:19 +00:00
### Handelsregister Integration
2024-12-31 14:43:08 +01:00
2025-07-13 15:08:19 +00:00
Automate German company data retrieval:
2024-12-31 14:43:08 +01:00
2024-12-31 19:58:18 +01:00
```typescript
2025-07-13 15:08:19 +00:00
// Search for a company
const results = await openData.handelsregister.searchCompany("Siemens AG");
// Get detailed information and documents
const details = await openData.handelsregister.getSpecificCompany({
court: "Munich",
type: "HRB",
number: "6684"
});
2025-04-09 06:26:52 +00:00
2025-07-13 15:08:19 +00:00
// Downloaded files include:
// - XML data (SI files)
// - PDF documents (AD files)
for (const file of details.files) {
await file.writeToDir('./downloads');
}
2025-04-09 06:26:52 +00:00
```
2025-07-13 15:08:19 +00:00
### Combined Data Analysis
2024-12-31 14:43:08 +01:00
2025-07-13 15:08:19 +00:00
Merge financial and business data:
2025-04-09 06:26:52 +00:00
```typescript
2025-07-13 15:08:19 +00:00
// Find all public German companies (AG)
const publicCompanies = await openData.db
.collection('businessrecords')
.find({ legalForm: 'AG' })
.toArray();
// Enrich with stock data
for (const company of publicCompanies) {
2025-04-09 06:26:52 +00:00
try {
2025-07-13 15:08:19 +00:00
// Map company to ticker (custom logic needed)
const ticker = mapCompanyToTicker(company.data.name);
if (ticker) {
const stock = await stockService.getPrice({ ticker });
// Add financial metrics
company.data.stockPrice = stock.price;
company.data.marketCap = stock.price * getSharesOutstanding(ticker);
company.data.priceChange = stock.changePercent;
await company.save();
2025-04-09 06:26:52 +00:00
}
} catch (error) {
2025-07-13 15:08:19 +00:00
// Handle missing tickers gracefully
2024-12-31 14:43:08 +01:00
}
2025-07-13 15:08:19 +00:00
}
2025-04-09 06:26:52 +00:00
```
2025-07-13 15:08:19 +00:00
## Configuration
2025-04-09 06:26:52 +00:00
2025-07-13 15:08:19 +00:00
### Stock Service Options
2025-04-09 06:26:52 +00:00
```typescript
2025-07-13 15:08:19 +00:00
const stockService = new StockPriceService({
ttl: 60000, // Cache for 1 minute
maxEntries: 1000 // Max cached symbols
});
2025-04-09 06:26:52 +00:00
2025-07-13 15:08:19 +00:00
// Provider configuration
stockService.register(new YahooFinanceProvider(), {
enabled: true,
priority: 100,
timeout: 10000,
retryAttempts: 3,
retryDelay: 1000
});
2024-12-31 14:43:08 +01:00
```
2025-07-13 15:08:19 +00:00
### MongoDB Setup
2025-04-09 06:26:52 +00:00
2025-07-13 15:08:19 +00:00
Set environment variables:
2025-04-09 06:26:52 +00:00
2025-07-13 15:08:19 +00:00
```env
MONGODB_URL=mongodb://localhost:27017
MONGODB_NAME=opendata
MONGODB_USER=myuser
MONGODB_PASS=mypass
2025-04-09 06:26:52 +00:00
```
2024-12-31 14:43:08 +01:00
2025-07-13 15:08:19 +00:00
## API Reference
2025-04-09 06:26:52 +00:00
2025-07-13 15:08:19 +00:00
### Stock Types
2025-04-09 06:26:52 +00:00
```typescript
2025-07-13 15:08:19 +00:00
interface IStockPrice {
ticker: string;
price: number;
currency: string;
change: number;
changePercent: number;
previousClose: number;
timestamp: Date;
provider: string;
marketState: 'PRE' | 'REGULAR' | 'POST' | 'CLOSED';
exchange?: string;
exchangeName?: string;
}
2025-04-09 06:26:52 +00:00
```
2025-07-13 15:08:19 +00:00
### Key Methods
2025-04-09 06:26:52 +00:00
2025-07-13 15:08:19 +00:00
**StockPriceService**
- `getPrice(request)` - Single stock price
- `getPrices(request)` - Batch prices
- `register(provider)` - Add data provider
- `clearCache()` - Clear price cache
2025-04-09 06:26:52 +00:00
2025-07-13 15:08:19 +00:00
**OpenData**
- `start()` - Initialize MongoDB connection
- `buildInitialDb()` - Import bulk data
- `CBusinessRecord` - Business record class
- `handelsregister` - Registry automation
2025-04-09 06:26:52 +00:00
2025-07-13 15:08:19 +00:00
## Performance
2025-04-09 06:26:52 +00:00
2025-07-13 15:08:19 +00:00
- **Batch fetching**: Get 100+ prices in < 500ms
- **Caching**: Instant repeated queries
- **Concurrent processing**: Handle 1000+ records/second
- **Streaming**: Process GB-sized datasets without memory issues
2025-04-09 06:26:52 +00:00
2025-07-13 15:08:19 +00:00
## Extensibility
2025-04-09 06:26:52 +00:00
2025-07-13 15:08:19 +00:00
The provider architecture makes it easy to add new data sources:
2025-04-09 06:26:52 +00:00
2025-07-13 15:08:19 +00:00
```typescript
class MyCustomProvider implements IStockProvider {
name = 'My Provider';
async fetchPrice(request: IStockQuoteRequest): Promise< IStockPrice > {
// Your implementation
2024-12-31 14:43:08 +01:00
}
2025-07-13 15:08:19 +00:00
// ... other required methods
}
2025-04-09 06:26:52 +00:00
2025-07-13 15:08:19 +00:00
stockService.register(new MyCustomProvider());
2024-12-31 14:43:08 +01:00
```
2025-07-13 15:08:19 +00:00
## Testing
2025-04-09 06:26:52 +00:00
2025-07-13 15:08:19 +00:00
Run the comprehensive test suite:
2025-04-09 06:26:52 +00:00
2025-07-13 15:08:19 +00:00
```bash
npm test
```
2025-04-09 06:26:52 +00:00
2025-07-13 15:08:19 +00:00
View live market data:
2024-12-31 14:43:08 +01:00
2025-07-13 15:08:19 +00:00
```bash
npm test -- --grep "market indicators"
```
2024-12-31 14:43:08 +01:00
2025-07-13 15:08:19 +00:00
## Contributing
2024-12-31 19:58:18 +01:00
2025-07-13 15:08:19 +00:00
We welcome contributions! Please see our contributing guidelines for details.
2025-01-04 13:40:50 +01:00
## License and Legal Information
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license ](license ) file within this repository.
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
### Trademarks
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
### Company Information
Task Venture Capital GmbH
Registered at District court Bremen HRB 35230 HB, Germany
For any legal inquiries or if you require further information, please contact us via email at hello@task .vc.
2025-07-13 15:08:19 +00:00
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.