@vesper85/strategy-sdk 0.1.5 → 0.1.6
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 +17 -16
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @vesper85/strategy-sdk
|
|
2
2
|
|
|
3
3
|
SDK for writing and running trading strategies with Polymarket and Hyperliquid integrations.
|
|
4
4
|
|
|
@@ -15,11 +15,11 @@ SDK for writing and running trading strategies with Polymarket and Hyperliquid i
|
|
|
15
15
|
## Installation
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
|
-
npm install @
|
|
18
|
+
npm install @vesper85/strategy-sdk
|
|
19
19
|
# or
|
|
20
|
-
pnpm add @
|
|
20
|
+
pnpm add @vesper85/strategy-sdk
|
|
21
21
|
# or
|
|
22
|
-
yarn add @
|
|
22
|
+
yarn add @vesper85/strategy-sdk
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
## Quick Start
|
|
@@ -27,7 +27,7 @@ yarn add @osiris-ai/strategy-sdk
|
|
|
27
27
|
### 1. Create a Tick-Based Strategy
|
|
28
28
|
|
|
29
29
|
```typescript
|
|
30
|
-
import type { OsirisContext, CodeStrategy } from '@
|
|
30
|
+
import type { OsirisContext, CodeStrategy } from '@vesper85/strategy-sdk';
|
|
31
31
|
|
|
32
32
|
export default class MyStrategy implements CodeStrategy {
|
|
33
33
|
async shouldTrigger(osiris: OsirisContext): Promise<boolean> {
|
|
@@ -53,7 +53,7 @@ import type {
|
|
|
53
53
|
EventSubscription,
|
|
54
54
|
StrategyEvent,
|
|
55
55
|
OsirisContext
|
|
56
|
-
} from '@
|
|
56
|
+
} from '@vesper85/strategy-sdk';
|
|
57
57
|
|
|
58
58
|
export class PriceAlertStrategy implements CodeStrategy {
|
|
59
59
|
// Define what events to subscribe to
|
|
@@ -98,10 +98,10 @@ async function main() {
|
|
|
98
98
|
});
|
|
99
99
|
|
|
100
100
|
// For tick-based strategies
|
|
101
|
-
const engine = createStrategyEngine(strategy, {
|
|
101
|
+
const engine = createStrategyEngine(strategy, context, {
|
|
102
102
|
logger,
|
|
103
103
|
tickIntervalMs: 60000,
|
|
104
|
-
}
|
|
104
|
+
});
|
|
105
105
|
engine.start();
|
|
106
106
|
|
|
107
107
|
// For event-based strategies
|
|
@@ -129,13 +129,13 @@ interface CodeStrategy {
|
|
|
129
129
|
```
|
|
130
130
|
|
|
131
131
|
```typescript
|
|
132
|
-
import { createStrategyEngine } from '@
|
|
132
|
+
import { createStrategyEngine } from '@vesper85/strategy-sdk';
|
|
133
133
|
|
|
134
|
-
const engine = createStrategyEngine(strategy, {
|
|
134
|
+
const engine = createStrategyEngine(strategy, context, {
|
|
135
135
|
logger,
|
|
136
136
|
strategyId: 'my-strategy',
|
|
137
137
|
tickIntervalMs: 60000, // Run every 60 seconds
|
|
138
|
-
}
|
|
138
|
+
});
|
|
139
139
|
|
|
140
140
|
engine.start();
|
|
141
141
|
// engine.stop();
|
|
@@ -247,7 +247,7 @@ import type {
|
|
|
247
247
|
ActivitySubscription,
|
|
248
248
|
ClobMarketSubscription,
|
|
249
249
|
CommentsSubscription
|
|
250
|
-
} from '@
|
|
250
|
+
} from '@vesper85/strategy-sdk';
|
|
251
251
|
|
|
252
252
|
class MyPolymarketStrategy implements CodeStrategy {
|
|
253
253
|
subscriptions: EventSubscription[] = [
|
|
@@ -370,6 +370,7 @@ const runner = createEventRunner(strategy, {
|
|
|
370
370
|
messageType: '*',
|
|
371
371
|
eventSource: 'polymarket'
|
|
372
372
|
}
|
|
373
|
+
```
|
|
373
374
|
|
|
374
375
|
## Type Guards
|
|
375
376
|
|
|
@@ -394,7 +395,7 @@ import {
|
|
|
394
395
|
// Source routing helpers
|
|
395
396
|
isPolymarketSubscription,
|
|
396
397
|
isOsirisSubscription
|
|
397
|
-
} from '@
|
|
398
|
+
} from '@vesper85/strategy-sdk';
|
|
398
399
|
|
|
399
400
|
// Check if subscription is for Polymarket
|
|
400
401
|
if (isPolymarketSubscription(subscription)) {
|
|
@@ -465,7 +466,7 @@ interface OsirisContext {
|
|
|
465
466
|
#### In-Memory State (for testing)
|
|
466
467
|
|
|
467
468
|
```typescript
|
|
468
|
-
import { MemoryStateManager } from '@
|
|
469
|
+
import { MemoryStateManager } from '@vesper85/strategy-sdk';
|
|
469
470
|
|
|
470
471
|
const stateManager = new MemoryStateManager();
|
|
471
472
|
```
|
|
@@ -473,7 +474,7 @@ const stateManager = new MemoryStateManager();
|
|
|
473
474
|
#### Redis State (for production)
|
|
474
475
|
|
|
475
476
|
```typescript
|
|
476
|
-
import { RedisStateManager } from '@
|
|
477
|
+
import { RedisStateManager } from '@vesper85/strategy-sdk';
|
|
477
478
|
|
|
478
479
|
const stateManager = new RedisStateManager(
|
|
479
480
|
'redis://localhost:6379',
|
|
@@ -535,7 +536,7 @@ const macd = osiris.ta.calculate('macd_12_26_9', ohlcvData, {
|
|
|
535
536
|
### Signing Transactions
|
|
536
537
|
|
|
537
538
|
```typescript
|
|
538
|
-
import { PrivateKeySigner, OsirisSigner } from '@
|
|
539
|
+
import { PrivateKeySigner, OsirisSigner } from '@vesper85/strategy-sdk';
|
|
539
540
|
|
|
540
541
|
// Private key signer
|
|
541
542
|
const signer = new PrivateKeySigner({
|