pmxtjs 0.3.1 → 0.4.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/API_REFERENCE.md +230 -1
- package/dist/BaseExchange.d.ts +36 -2
- package/dist/BaseExchange.js +43 -1
- package/dist/exchanges/kalshi/auth.d.ts +23 -0
- package/dist/exchanges/kalshi/auth.js +99 -0
- package/dist/exchanges/kalshi/fetchMarkets.d.ts +3 -0
- package/dist/exchanges/kalshi/fetchMarkets.js +84 -0
- package/dist/exchanges/kalshi/fetchOHLCV.d.ts +3 -0
- package/dist/exchanges/kalshi/fetchOHLCV.js +78 -0
- package/dist/exchanges/kalshi/fetchOrderBook.d.ts +2 -0
- package/dist/exchanges/kalshi/fetchOrderBook.js +32 -0
- package/dist/exchanges/kalshi/fetchTrades.d.ts +3 -0
- package/dist/exchanges/kalshi/fetchTrades.js +31 -0
- package/dist/exchanges/kalshi/getMarketsBySlug.d.ts +7 -0
- package/dist/exchanges/kalshi/getMarketsBySlug.js +46 -0
- package/dist/exchanges/kalshi/index.d.ts +21 -0
- package/dist/exchanges/kalshi/index.js +273 -0
- package/dist/exchanges/kalshi/kalshi.test.d.ts +1 -0
- package/dist/exchanges/kalshi/kalshi.test.js +309 -0
- package/dist/exchanges/kalshi/searchMarkets.d.ts +3 -0
- package/dist/exchanges/kalshi/searchMarkets.js +28 -0
- package/dist/exchanges/kalshi/utils.d.ts +4 -0
- package/dist/exchanges/kalshi/utils.js +70 -0
- package/dist/exchanges/polymarket/auth.d.ts +32 -0
- package/dist/exchanges/polymarket/auth.js +98 -0
- package/dist/exchanges/polymarket/fetchMarkets.d.ts +3 -0
- package/dist/exchanges/polymarket/fetchMarkets.js +75 -0
- package/dist/exchanges/polymarket/fetchOHLCV.d.ts +7 -0
- package/dist/exchanges/polymarket/fetchOHLCV.js +73 -0
- package/dist/exchanges/polymarket/fetchOrderBook.d.ts +6 -0
- package/dist/exchanges/polymarket/fetchOrderBook.js +38 -0
- package/dist/exchanges/polymarket/fetchPositions.d.ts +2 -0
- package/dist/exchanges/polymarket/fetchPositions.js +27 -0
- package/dist/exchanges/polymarket/fetchTrades.d.ts +11 -0
- package/dist/exchanges/polymarket/fetchTrades.js +59 -0
- package/dist/exchanges/polymarket/getMarketsBySlug.d.ts +7 -0
- package/dist/exchanges/polymarket/getMarketsBySlug.js +39 -0
- package/dist/exchanges/polymarket/index.d.ts +23 -0
- package/dist/exchanges/polymarket/index.js +216 -0
- package/dist/exchanges/polymarket/searchMarkets.d.ts +3 -0
- package/dist/exchanges/polymarket/searchMarkets.js +35 -0
- package/dist/exchanges/polymarket/utils.d.ts +7 -0
- package/dist/exchanges/polymarket/utils.js +95 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +8 -8
- package/dist/types.d.ts +38 -0
- package/package.json +5 -1
- package/readme.md +37 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export * from './BaseExchange';
|
|
2
2
|
export * from './types';
|
|
3
|
-
export * from './exchanges/
|
|
4
|
-
export * from './exchanges/
|
|
5
|
-
import { PolymarketExchange } from './exchanges/
|
|
6
|
-
import { KalshiExchange } from './exchanges/
|
|
3
|
+
export * from './exchanges/polymarket';
|
|
4
|
+
export * from './exchanges/kalshi';
|
|
5
|
+
import { PolymarketExchange } from './exchanges/polymarket';
|
|
6
|
+
import { KalshiExchange } from './exchanges/kalshi';
|
|
7
7
|
declare const pmxt: {
|
|
8
8
|
polymarket: typeof PolymarketExchange;
|
|
9
9
|
kalshi: typeof KalshiExchange;
|
package/dist/index.js
CHANGED
|
@@ -16,14 +16,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./BaseExchange"), exports);
|
|
18
18
|
__exportStar(require("./types"), exports);
|
|
19
|
-
__exportStar(require("./exchanges/
|
|
20
|
-
__exportStar(require("./exchanges/
|
|
21
|
-
const
|
|
22
|
-
const
|
|
19
|
+
__exportStar(require("./exchanges/polymarket"), exports);
|
|
20
|
+
__exportStar(require("./exchanges/kalshi"), exports);
|
|
21
|
+
const polymarket_1 = require("./exchanges/polymarket");
|
|
22
|
+
const kalshi_1 = require("./exchanges/kalshi");
|
|
23
23
|
const pmxt = {
|
|
24
|
-
polymarket:
|
|
25
|
-
kalshi:
|
|
26
|
-
Polymarket:
|
|
27
|
-
Kalshi:
|
|
24
|
+
polymarket: polymarket_1.PolymarketExchange,
|
|
25
|
+
kalshi: kalshi_1.KalshiExchange,
|
|
26
|
+
Polymarket: polymarket_1.PolymarketExchange,
|
|
27
|
+
Kalshi: kalshi_1.KalshiExchange
|
|
28
28
|
};
|
|
29
29
|
exports.default = pmxt;
|
package/dist/types.d.ts
CHANGED
|
@@ -45,3 +45,41 @@ export interface Trade {
|
|
|
45
45
|
amount: number;
|
|
46
46
|
side: 'buy' | 'sell' | 'unknown';
|
|
47
47
|
}
|
|
48
|
+
export interface Order {
|
|
49
|
+
id: string;
|
|
50
|
+
marketId: string;
|
|
51
|
+
outcomeId: string;
|
|
52
|
+
side: 'buy' | 'sell';
|
|
53
|
+
type: 'market' | 'limit';
|
|
54
|
+
price?: number;
|
|
55
|
+
amount: number;
|
|
56
|
+
status: 'pending' | 'open' | 'filled' | 'cancelled' | 'rejected';
|
|
57
|
+
filled: number;
|
|
58
|
+
remaining: number;
|
|
59
|
+
timestamp: number;
|
|
60
|
+
fee?: number;
|
|
61
|
+
}
|
|
62
|
+
export interface Position {
|
|
63
|
+
marketId: string;
|
|
64
|
+
outcomeId: string;
|
|
65
|
+
outcomeLabel: string;
|
|
66
|
+
size: number;
|
|
67
|
+
entryPrice: number;
|
|
68
|
+
currentPrice: number;
|
|
69
|
+
unrealizedPnL: number;
|
|
70
|
+
realizedPnL?: number;
|
|
71
|
+
}
|
|
72
|
+
export interface Balance {
|
|
73
|
+
currency: string;
|
|
74
|
+
total: number;
|
|
75
|
+
available: number;
|
|
76
|
+
locked: number;
|
|
77
|
+
}
|
|
78
|
+
export interface CreateOrderParams {
|
|
79
|
+
marketId: string;
|
|
80
|
+
outcomeId: string;
|
|
81
|
+
side: 'buy' | 'sell';
|
|
82
|
+
type: 'market' | 'limit';
|
|
83
|
+
amount: number;
|
|
84
|
+
price?: number;
|
|
85
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmxtjs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "pmxt is a unified prediction market data API. The ccxt for prediction markets.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -21,13 +21,17 @@
|
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"type": "commonjs",
|
|
23
23
|
"dependencies": {
|
|
24
|
+
"@polymarket/clob-client": "^5.2.0",
|
|
24
25
|
"axios": "^1.7.9",
|
|
26
|
+
"dotenv": "^17.2.3",
|
|
27
|
+
"ethers": "^5.8.0",
|
|
25
28
|
"jest": "^30.2.0",
|
|
26
29
|
"tsx": "^4.21.0"
|
|
27
30
|
},
|
|
28
31
|
"devDependencies": {
|
|
29
32
|
"@types/jest": "^30.0.0",
|
|
30
33
|
"@types/node": "^25.0.3",
|
|
34
|
+
"identity-obj-proxy": "^3.0.0",
|
|
31
35
|
"ts-jest": "^29.4.6",
|
|
32
36
|
"typescript": "^5.9.3"
|
|
33
37
|
}
|
package/readme.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
<table>
|
|
9
9
|
<tr>
|
|
10
10
|
<td rowspan="3">
|
|
11
|
-
<a href="https://www.producthunt.com/products/
|
|
11
|
+
<a href="https://www.producthunt.com/products/ccxt-for-prediction-markets?embed=true&utm_source=badge-featured&utm_medium=badge&utm_campaign=badge-ccxt-for-prediction-markets" target="_blank" rel="noopener noreferrer"><img alt="CCXT for Prediction Markets - A unified API for prediction market data across exchanges. | Product Hunt" width="250" height="54" src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=1060549&theme=light&t=1768206672608"></a>
|
|
12
12
|
</td>
|
|
13
13
|
<td>
|
|
14
14
|
<img src="https://img.shields.io/github/watchers/qoery-com/pmxt?style=social" alt="GitHub watchers">
|
|
@@ -80,13 +80,47 @@ npm install pmxtjs
|
|
|
80
80
|
- Polymarket
|
|
81
81
|
- Kalshi
|
|
82
82
|
|
|
83
|
+
## Trading
|
|
84
|
+
pmxt supports trading functionality (placing and cancelling orders).
|
|
85
|
+
|
|
86
|
+
### Setup
|
|
87
|
+
To trade, you must provide your private credentials.
|
|
88
|
+
|
|
89
|
+
- **Polymarket**: Requires your Polygon Private Key. [View Setup Guide](docs/SETUP_POLYMARKET.md)
|
|
90
|
+
- **Kalshi**: Requires API Key & Private Key (Coming Soon).
|
|
91
|
+
|
|
92
|
+
### Trading Example
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
import pmxt from 'pmxtjs';
|
|
96
|
+
|
|
97
|
+
const exchange = new pmxt.Polymarket({
|
|
98
|
+
privateKey: process.env.POLYMARKET_PRIVATE_KEY
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
// Check Balance
|
|
102
|
+
const balance = await exchange.fetchBalance();
|
|
103
|
+
console.log('Balance:', balance);
|
|
104
|
+
|
|
105
|
+
// Place an Order
|
|
106
|
+
const order = await exchange.createOrder({
|
|
107
|
+
marketId: 'market-123',
|
|
108
|
+
outcomeId: 'token-id-456',
|
|
109
|
+
side: 'buy',
|
|
110
|
+
type: 'limit',
|
|
111
|
+
price: 0.50,
|
|
112
|
+
amount: 100
|
|
113
|
+
});
|
|
114
|
+
console.log('Order:', order);
|
|
115
|
+
```
|
|
116
|
+
|
|
83
117
|
## Documentation
|
|
84
118
|
|
|
85
|
-
See the [API Reference](
|
|
119
|
+
See the [API Reference](API_REFERENCE.md) for detailed documentation and more examples.
|
|
86
120
|
|
|
87
121
|
## Examples
|
|
88
122
|
|
|
89
|
-
Check out the [examples](
|
|
123
|
+
Check out the [examples](examples/) directory for more use cases:
|
|
90
124
|
- Market search
|
|
91
125
|
- Order book data
|
|
92
126
|
- Historical prices
|