pmxtjs 2.2.0 → 2.3.0
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 +2 -2
- package/dist/esm/generated/src/models/MarketOutcome.d.ts +6 -0
- package/dist/esm/generated/src/models/MarketOutcome.js +2 -0
- package/dist/esm/pmxt/client.js +18 -2
- package/dist/esm/pmxt/models.d.ts +2 -0
- package/dist/generated/src/models/MarketOutcome.d.ts +6 -0
- package/dist/generated/src/models/MarketOutcome.js +2 -0
- package/dist/pmxt/client.js +18 -2
- package/dist/pmxt/models.d.ts +2 -0
- package/generated/docs/MarketOutcome.md +2 -0
- package/generated/package.json +1 -1
- package/generated/src/models/MarketOutcome.ts +8 -0
- package/package.json +2 -2
- package/pmxt/client.ts +24 -2
- package/pmxt/models.ts +3 -0
package/README.md
CHANGED
|
@@ -107,9 +107,9 @@ const limitless = new pmxt.Limitless({
|
|
|
107
107
|
|
|
108
108
|
- `createOrder(params)` - Place a new order
|
|
109
109
|
```typescript
|
|
110
|
+
// Using outcome shorthand (recommended)
|
|
110
111
|
await poly.createOrder({
|
|
111
|
-
|
|
112
|
-
outcomeId: outcome.outcomeId,
|
|
112
|
+
outcome: market.yes,
|
|
113
113
|
side: 'buy',
|
|
114
114
|
type: 'limit',
|
|
115
115
|
amount: 10,
|
|
@@ -21,6 +21,12 @@ export interface MarketOutcome {
|
|
|
21
21
|
* @memberof MarketOutcome
|
|
22
22
|
*/
|
|
23
23
|
outcomeId?: string;
|
|
24
|
+
/**
|
|
25
|
+
* The market this outcome belongs to (set automatically)
|
|
26
|
+
* @type {string}
|
|
27
|
+
* @memberof MarketOutcome
|
|
28
|
+
*/
|
|
29
|
+
marketId?: string;
|
|
24
30
|
/**
|
|
25
31
|
*
|
|
26
32
|
* @type {string}
|
|
@@ -26,6 +26,7 @@ export function MarketOutcomeFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
26
26
|
}
|
|
27
27
|
return {
|
|
28
28
|
'outcomeId': json['outcomeId'] == null ? undefined : json['outcomeId'],
|
|
29
|
+
'marketId': json['marketId'] == null ? undefined : json['marketId'],
|
|
29
30
|
'label': json['label'] == null ? undefined : json['label'],
|
|
30
31
|
'price': json['price'] == null ? undefined : json['price'],
|
|
31
32
|
'priceChange24h': json['priceChange24h'] == null ? undefined : json['priceChange24h'],
|
|
@@ -41,6 +42,7 @@ export function MarketOutcomeToJSONTyped(value, ignoreDiscriminator = false) {
|
|
|
41
42
|
}
|
|
42
43
|
return {
|
|
43
44
|
'outcomeId': value['outcomeId'],
|
|
45
|
+
'marketId': value['marketId'],
|
|
44
46
|
'label': value['label'],
|
|
45
47
|
'price': value['price'],
|
|
46
48
|
'priceChange24h': value['priceChange24h'],
|
package/dist/esm/pmxt/client.js
CHANGED
|
@@ -11,6 +11,7 @@ import { ServerManager } from "./server-manager.js";
|
|
|
11
11
|
function convertMarket(raw) {
|
|
12
12
|
const outcomes = (raw.outcomes || []).map((o) => ({
|
|
13
13
|
outcomeId: o.outcomeId,
|
|
14
|
+
marketId: o.marketId,
|
|
14
15
|
label: o.label,
|
|
15
16
|
price: o.price,
|
|
16
17
|
priceChange24h: o.priceChange24h,
|
|
@@ -18,6 +19,7 @@ function convertMarket(raw) {
|
|
|
18
19
|
}));
|
|
19
20
|
const convertOutcome = (o) => o ? ({
|
|
20
21
|
outcomeId: o.outcomeId,
|
|
22
|
+
marketId: o.marketId,
|
|
21
23
|
label: o.label,
|
|
22
24
|
price: o.price,
|
|
23
25
|
priceChange24h: o.priceChange24h,
|
|
@@ -457,9 +459,23 @@ export class Exchange {
|
|
|
457
459
|
async createOrder(params) {
|
|
458
460
|
await this.initPromise;
|
|
459
461
|
try {
|
|
462
|
+
// Resolve outcome shorthand: extract marketId/outcomeId from outcome object
|
|
463
|
+
let marketId = params.marketId;
|
|
464
|
+
let outcomeId = params.outcomeId;
|
|
465
|
+
if (params.outcome) {
|
|
466
|
+
if (marketId !== undefined || outcomeId !== undefined) {
|
|
467
|
+
throw new Error("Cannot specify both 'outcome' and 'marketId'/'outcomeId'. Use one or the other.");
|
|
468
|
+
}
|
|
469
|
+
const outcome = params.outcome;
|
|
470
|
+
if (!outcome.marketId) {
|
|
471
|
+
throw new Error("outcome.marketId is not set. Ensure the outcome comes from a fetched market.");
|
|
472
|
+
}
|
|
473
|
+
marketId = outcome.marketId;
|
|
474
|
+
outcomeId = outcome.outcomeId;
|
|
475
|
+
}
|
|
460
476
|
const paramsDict = {
|
|
461
|
-
marketId
|
|
462
|
-
outcomeId
|
|
477
|
+
marketId,
|
|
478
|
+
outcomeId,
|
|
463
479
|
side: params.side,
|
|
464
480
|
type: params.type,
|
|
465
481
|
amount: params.amount,
|
|
@@ -13,6 +13,8 @@ export interface MarketOutcome {
|
|
|
13
13
|
* - Kalshi: Market Ticker
|
|
14
14
|
*/
|
|
15
15
|
outcomeId: string;
|
|
16
|
+
/** The market this outcome belongs to (set automatically). */
|
|
17
|
+
marketId?: string;
|
|
16
18
|
/** Human-readable label (e.g., "Trump", "Yes") */
|
|
17
19
|
label: string;
|
|
18
20
|
/** Current price (0.0 to 1.0, representing probability) */
|
|
@@ -21,6 +21,12 @@ export interface MarketOutcome {
|
|
|
21
21
|
* @memberof MarketOutcome
|
|
22
22
|
*/
|
|
23
23
|
outcomeId?: string;
|
|
24
|
+
/**
|
|
25
|
+
* The market this outcome belongs to (set automatically)
|
|
26
|
+
* @type {string}
|
|
27
|
+
* @memberof MarketOutcome
|
|
28
|
+
*/
|
|
29
|
+
marketId?: string;
|
|
24
30
|
/**
|
|
25
31
|
*
|
|
26
32
|
* @type {string}
|
|
@@ -33,6 +33,7 @@ function MarketOutcomeFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
33
33
|
}
|
|
34
34
|
return {
|
|
35
35
|
'outcomeId': json['outcomeId'] == null ? undefined : json['outcomeId'],
|
|
36
|
+
'marketId': json['marketId'] == null ? undefined : json['marketId'],
|
|
36
37
|
'label': json['label'] == null ? undefined : json['label'],
|
|
37
38
|
'price': json['price'] == null ? undefined : json['price'],
|
|
38
39
|
'priceChange24h': json['priceChange24h'] == null ? undefined : json['priceChange24h'],
|
|
@@ -48,6 +49,7 @@ function MarketOutcomeToJSONTyped(value, ignoreDiscriminator = false) {
|
|
|
48
49
|
}
|
|
49
50
|
return {
|
|
50
51
|
'outcomeId': value['outcomeId'],
|
|
52
|
+
'marketId': value['marketId'],
|
|
51
53
|
'label': value['label'],
|
|
52
54
|
'price': value['price'],
|
|
53
55
|
'priceChange24h': value['priceChange24h'],
|
package/dist/pmxt/client.js
CHANGED
|
@@ -14,6 +14,7 @@ const server_manager_js_1 = require("./server-manager.js");
|
|
|
14
14
|
function convertMarket(raw) {
|
|
15
15
|
const outcomes = (raw.outcomes || []).map((o) => ({
|
|
16
16
|
outcomeId: o.outcomeId,
|
|
17
|
+
marketId: o.marketId,
|
|
17
18
|
label: o.label,
|
|
18
19
|
price: o.price,
|
|
19
20
|
priceChange24h: o.priceChange24h,
|
|
@@ -21,6 +22,7 @@ function convertMarket(raw) {
|
|
|
21
22
|
}));
|
|
22
23
|
const convertOutcome = (o) => o ? ({
|
|
23
24
|
outcomeId: o.outcomeId,
|
|
25
|
+
marketId: o.marketId,
|
|
24
26
|
label: o.label,
|
|
25
27
|
price: o.price,
|
|
26
28
|
priceChange24h: o.priceChange24h,
|
|
@@ -460,9 +462,23 @@ class Exchange {
|
|
|
460
462
|
async createOrder(params) {
|
|
461
463
|
await this.initPromise;
|
|
462
464
|
try {
|
|
465
|
+
// Resolve outcome shorthand: extract marketId/outcomeId from outcome object
|
|
466
|
+
let marketId = params.marketId;
|
|
467
|
+
let outcomeId = params.outcomeId;
|
|
468
|
+
if (params.outcome) {
|
|
469
|
+
if (marketId !== undefined || outcomeId !== undefined) {
|
|
470
|
+
throw new Error("Cannot specify both 'outcome' and 'marketId'/'outcomeId'. Use one or the other.");
|
|
471
|
+
}
|
|
472
|
+
const outcome = params.outcome;
|
|
473
|
+
if (!outcome.marketId) {
|
|
474
|
+
throw new Error("outcome.marketId is not set. Ensure the outcome comes from a fetched market.");
|
|
475
|
+
}
|
|
476
|
+
marketId = outcome.marketId;
|
|
477
|
+
outcomeId = outcome.outcomeId;
|
|
478
|
+
}
|
|
463
479
|
const paramsDict = {
|
|
464
|
-
marketId
|
|
465
|
-
outcomeId
|
|
480
|
+
marketId,
|
|
481
|
+
outcomeId,
|
|
466
482
|
side: params.side,
|
|
467
483
|
type: params.type,
|
|
468
484
|
amount: params.amount,
|
package/dist/pmxt/models.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ export interface MarketOutcome {
|
|
|
13
13
|
* - Kalshi: Market Ticker
|
|
14
14
|
*/
|
|
15
15
|
outcomeId: string;
|
|
16
|
+
/** The market this outcome belongs to (set automatically). */
|
|
17
|
+
marketId?: string;
|
|
16
18
|
/** Human-readable label (e.g., "Trump", "Yes") */
|
|
17
19
|
label: string;
|
|
18
20
|
/** Current price (0.0 to 1.0, representing probability) */
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
Name | Type
|
|
8
8
|
------------ | -------------
|
|
9
9
|
`outcomeId` | string
|
|
10
|
+
`marketId` | string
|
|
10
11
|
`label` | string
|
|
11
12
|
`price` | number
|
|
12
13
|
`priceChange24h` | number
|
|
@@ -20,6 +21,7 @@ import type { MarketOutcome } from 'pmxtjs'
|
|
|
20
21
|
// TODO: Update the object below with actual values
|
|
21
22
|
const example = {
|
|
22
23
|
"outcomeId": null,
|
|
24
|
+
"marketId": null,
|
|
23
25
|
"label": null,
|
|
24
26
|
"price": null,
|
|
25
27
|
"priceChange24h": null,
|
package/generated/package.json
CHANGED
|
@@ -25,6 +25,12 @@ export interface MarketOutcome {
|
|
|
25
25
|
* @memberof MarketOutcome
|
|
26
26
|
*/
|
|
27
27
|
outcomeId?: string;
|
|
28
|
+
/**
|
|
29
|
+
* The market this outcome belongs to (set automatically)
|
|
30
|
+
* @type {string}
|
|
31
|
+
* @memberof MarketOutcome
|
|
32
|
+
*/
|
|
33
|
+
marketId?: string;
|
|
28
34
|
/**
|
|
29
35
|
*
|
|
30
36
|
* @type {string}
|
|
@@ -69,6 +75,7 @@ export function MarketOutcomeFromJSONTyped(json: any, ignoreDiscriminator: boole
|
|
|
69
75
|
return {
|
|
70
76
|
|
|
71
77
|
'outcomeId': json['outcomeId'] == null ? undefined : json['outcomeId'],
|
|
78
|
+
'marketId': json['marketId'] == null ? undefined : json['marketId'],
|
|
72
79
|
'label': json['label'] == null ? undefined : json['label'],
|
|
73
80
|
'price': json['price'] == null ? undefined : json['price'],
|
|
74
81
|
'priceChange24h': json['priceChange24h'] == null ? undefined : json['priceChange24h'],
|
|
@@ -88,6 +95,7 @@ export function MarketOutcomeToJSONTyped(value?: MarketOutcome | null, ignoreDis
|
|
|
88
95
|
return {
|
|
89
96
|
|
|
90
97
|
'outcomeId': value['outcomeId'],
|
|
98
|
+
'marketId': value['marketId'],
|
|
91
99
|
'label': value['label'],
|
|
92
100
|
'price': value['price'],
|
|
93
101
|
'priceChange24h': value['priceChange24h'],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmxtjs",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Unified prediction market data API - The ccxt for prediction markets",
|
|
5
5
|
"author": "PMXT Contributors",
|
|
6
6
|
"repository": {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"unified"
|
|
43
43
|
],
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"pmxt-core": "2.
|
|
45
|
+
"pmxt-core": "2.3.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/jest": "^30.0.0",
|
package/pmxt/client.ts
CHANGED
|
@@ -45,6 +45,7 @@ import { ServerManager } from "./server-manager.js";
|
|
|
45
45
|
function convertMarket(raw: any): UnifiedMarket {
|
|
46
46
|
const outcomes: MarketOutcome[] = (raw.outcomes || []).map((o: any) => ({
|
|
47
47
|
outcomeId: o.outcomeId,
|
|
48
|
+
marketId: o.marketId,
|
|
48
49
|
label: o.label,
|
|
49
50
|
price: o.price,
|
|
50
51
|
priceChange24h: o.priceChange24h,
|
|
@@ -53,6 +54,7 @@ function convertMarket(raw: any): UnifiedMarket {
|
|
|
53
54
|
|
|
54
55
|
const convertOutcome = (o: any) => o ? ({
|
|
55
56
|
outcomeId: o.outcomeId,
|
|
57
|
+
marketId: o.marketId,
|
|
56
58
|
label: o.label,
|
|
57
59
|
price: o.price,
|
|
58
60
|
priceChange24h: o.priceChange24h,
|
|
@@ -571,9 +573,29 @@ export abstract class Exchange {
|
|
|
571
573
|
async createOrder(params: any): Promise<Order> {
|
|
572
574
|
await this.initPromise;
|
|
573
575
|
try {
|
|
576
|
+
// Resolve outcome shorthand: extract marketId/outcomeId from outcome object
|
|
577
|
+
let marketId = params.marketId;
|
|
578
|
+
let outcomeId = params.outcomeId;
|
|
579
|
+
|
|
580
|
+
if (params.outcome) {
|
|
581
|
+
if (marketId !== undefined || outcomeId !== undefined) {
|
|
582
|
+
throw new Error(
|
|
583
|
+
"Cannot specify both 'outcome' and 'marketId'/'outcomeId'. Use one or the other."
|
|
584
|
+
);
|
|
585
|
+
}
|
|
586
|
+
const outcome: MarketOutcome = params.outcome;
|
|
587
|
+
if (!outcome.marketId) {
|
|
588
|
+
throw new Error(
|
|
589
|
+
"outcome.marketId is not set. Ensure the outcome comes from a fetched market."
|
|
590
|
+
);
|
|
591
|
+
}
|
|
592
|
+
marketId = outcome.marketId;
|
|
593
|
+
outcomeId = outcome.outcomeId;
|
|
594
|
+
}
|
|
595
|
+
|
|
574
596
|
const paramsDict: any = {
|
|
575
|
-
marketId
|
|
576
|
-
outcomeId
|
|
597
|
+
marketId,
|
|
598
|
+
outcomeId,
|
|
577
599
|
side: params.side,
|
|
578
600
|
type: params.type,
|
|
579
601
|
amount: params.amount,
|
package/pmxt/models.ts
CHANGED