backtest-kit 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -9
- package/build/index.cjs +1262 -185
- package/build/index.mjs +1251 -185
- package/package.json +1 -1
- package/types.d.ts +288 -58
package/README.md
CHANGED
|
@@ -21,12 +21,12 @@ npm install
|
|
|
21
21
|
|
|
22
22
|
## Quick Start
|
|
23
23
|
|
|
24
|
-
### 1. Add Data Source (
|
|
24
|
+
### 1. Add Data Source (Exchange)
|
|
25
25
|
|
|
26
26
|
```typescript
|
|
27
|
-
import {
|
|
27
|
+
import { addExchange } from "./src/function/add";
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
addExchange({
|
|
30
30
|
getCandles: async (symbol, interval, since, limit) => {
|
|
31
31
|
// Fetch candle data from your source (exchange API, database, etc.)
|
|
32
32
|
return [
|
|
@@ -164,16 +164,17 @@ console.log(result.accumulator);
|
|
|
164
164
|
```
|
|
165
165
|
src/
|
|
166
166
|
├── function/ # High-level API functions
|
|
167
|
-
│ ├── add.ts # Add schemas (strategy,
|
|
167
|
+
│ ├── add.ts # Add schemas (strategy, exchange)
|
|
168
168
|
│ ├── backtest.ts # Backtesting functions
|
|
169
169
|
│ ├── reduce.ts # Reduce pattern for accumulation
|
|
170
|
-
│
|
|
170
|
+
│ ├── run.ts # Real-time execution
|
|
171
|
+
│ └── exchange.ts # Exchange data functions
|
|
171
172
|
├── client/ # Client implementations
|
|
172
|
-
│ ├──
|
|
173
|
+
│ ├── ClientExchange.ts # Exchange client with VWAP
|
|
173
174
|
│ └── ClientStrategy.ts # Strategy client with signal lifecycle
|
|
174
175
|
├── interfaces/ # TypeScript interfaces
|
|
175
176
|
│ ├── Strategy.interface.ts
|
|
176
|
-
│ └──
|
|
177
|
+
│ └── Exchange.interface.ts
|
|
177
178
|
└── lib/ # Core library with DI
|
|
178
179
|
├── core/ # Dependency injection
|
|
179
180
|
└── services/ # Services (schema, connection, public)
|
|
@@ -200,12 +201,18 @@ export const PERCENT_FEE = 0.1; // 0.1%
|
|
|
200
201
|
|
|
201
202
|
### Functions
|
|
202
203
|
|
|
203
|
-
#### `
|
|
204
|
-
Add
|
|
204
|
+
#### `addExchange(exchangeSchema: IExchangeSchema)`
|
|
205
|
+
Add exchange data source for candles.
|
|
205
206
|
|
|
206
207
|
#### `addStrategy(strategySchema: IStrategySchema)`
|
|
207
208
|
Add trading strategy.
|
|
208
209
|
|
|
210
|
+
#### `getCandles(symbol, interval, limit): Promise<ICandleData[]>`
|
|
211
|
+
Get candle data from exchange.
|
|
212
|
+
|
|
213
|
+
#### `getAveragePrice(symbol): Promise<number>`
|
|
214
|
+
Get VWAP average price based on last 5 1m candles.
|
|
215
|
+
|
|
209
216
|
#### `runBacktest(symbol: string, timeframes: Date[]): Promise<IBacktestResult>`
|
|
210
217
|
Run backtest and return closed trades only.
|
|
211
218
|
|