pmxtjs 0.3.1 → 0.4.1

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.
Files changed (48) hide show
  1. package/API_REFERENCE.md +230 -1
  2. package/dist/BaseExchange.d.ts +36 -2
  3. package/dist/BaseExchange.js +43 -1
  4. package/dist/exchanges/kalshi/auth.d.ts +23 -0
  5. package/dist/exchanges/kalshi/auth.js +99 -0
  6. package/dist/exchanges/kalshi/fetchMarkets.d.ts +3 -0
  7. package/dist/exchanges/kalshi/fetchMarkets.js +110 -0
  8. package/dist/exchanges/kalshi/fetchOHLCV.d.ts +3 -0
  9. package/dist/exchanges/kalshi/fetchOHLCV.js +78 -0
  10. package/dist/exchanges/kalshi/fetchOrderBook.d.ts +2 -0
  11. package/dist/exchanges/kalshi/fetchOrderBook.js +32 -0
  12. package/dist/exchanges/kalshi/fetchTrades.d.ts +3 -0
  13. package/dist/exchanges/kalshi/fetchTrades.js +31 -0
  14. package/dist/exchanges/kalshi/getMarketsBySlug.d.ts +7 -0
  15. package/dist/exchanges/kalshi/getMarketsBySlug.js +62 -0
  16. package/dist/exchanges/kalshi/index.d.ts +21 -0
  17. package/dist/exchanges/kalshi/index.js +273 -0
  18. package/dist/exchanges/kalshi/kalshi.test.d.ts +1 -0
  19. package/dist/exchanges/kalshi/kalshi.test.js +309 -0
  20. package/dist/exchanges/kalshi/searchMarkets.d.ts +3 -0
  21. package/dist/exchanges/kalshi/searchMarkets.js +28 -0
  22. package/dist/exchanges/kalshi/utils.d.ts +5 -0
  23. package/dist/exchanges/kalshi/utils.js +85 -0
  24. package/dist/exchanges/polymarket/auth.d.ts +32 -0
  25. package/dist/exchanges/polymarket/auth.js +98 -0
  26. package/dist/exchanges/polymarket/fetchMarkets.d.ts +3 -0
  27. package/dist/exchanges/polymarket/fetchMarkets.js +75 -0
  28. package/dist/exchanges/polymarket/fetchOHLCV.d.ts +7 -0
  29. package/dist/exchanges/polymarket/fetchOHLCV.js +73 -0
  30. package/dist/exchanges/polymarket/fetchOrderBook.d.ts +6 -0
  31. package/dist/exchanges/polymarket/fetchOrderBook.js +38 -0
  32. package/dist/exchanges/polymarket/fetchPositions.d.ts +2 -0
  33. package/dist/exchanges/polymarket/fetchPositions.js +27 -0
  34. package/dist/exchanges/polymarket/fetchTrades.d.ts +11 -0
  35. package/dist/exchanges/polymarket/fetchTrades.js +59 -0
  36. package/dist/exchanges/polymarket/getMarketsBySlug.d.ts +7 -0
  37. package/dist/exchanges/polymarket/getMarketsBySlug.js +39 -0
  38. package/dist/exchanges/polymarket/index.d.ts +23 -0
  39. package/dist/exchanges/polymarket/index.js +216 -0
  40. package/dist/exchanges/polymarket/searchMarkets.d.ts +3 -0
  41. package/dist/exchanges/polymarket/searchMarkets.js +35 -0
  42. package/dist/exchanges/polymarket/utils.d.ts +7 -0
  43. package/dist/exchanges/polymarket/utils.js +95 -0
  44. package/dist/index.d.ts +4 -4
  45. package/dist/index.js +8 -8
  46. package/dist/types.d.ts +38 -0
  47. package/package.json +5 -1
  48. 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/Polymarket';
4
- export * from './exchanges/Kalshi';
5
- import { PolymarketExchange } from './exchanges/Polymarket';
6
- import { KalshiExchange } from './exchanges/Kalshi';
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/Polymarket"), exports);
20
- __exportStar(require("./exchanges/Kalshi"), exports);
21
- const Polymarket_1 = require("./exchanges/Polymarket");
22
- const Kalshi_1 = require("./exchanges/Kalshi");
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: Polymarket_1.PolymarketExchange,
25
- kalshi: Kalshi_1.KalshiExchange,
26
- Polymarket: Polymarket_1.PolymarketExchange,
27
- Kalshi: Kalshi_1.KalshiExchange
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.1",
3
+ "version": "0.4.1",
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/qoery-python-sdk?embed=true&amp;utm_source=badge-featured&amp;utm_medium=badge&amp;utm_campaign=badge-qoery-python-sdk" target="_blank" rel="noopener noreferrer"><img alt="Qoery Python SDK - 50% cheaper crypto data. Now in Python. | Product Hunt" width="250" height="54" src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=1056631&amp;theme=light&amp;t=1767263265752"></a>
11
+ <a href="https://www.producthunt.com/products/ccxt-for-prediction-markets?embed=true&amp;utm_source=badge-featured&amp;utm_medium=badge&amp;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&amp;theme=light&amp;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.
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](pmxt/API_REFERENCE.md) for detailed documentation and more examples.
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](pmxt/examples/) directory for more use cases:
123
+ Check out the [examples](examples/) directory for more use cases:
90
124
  - Market search
91
125
  - Order book data
92
126
  - Historical prices