ostium-python-sdk 2.0.3__tar.gz → 2.0.5__tar.gz
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.
- {ostium_python_sdk-2.0.3 → ostium_python_sdk-2.0.5}/PKG-INFO +30 -10
- {ostium_python_sdk-2.0.3 → ostium_python_sdk-2.0.5}/README.md +14 -8
- ostium_python_sdk-2.0.5/ostium_python_sdk/abi/__init__.py +7 -0
- ostium_python_sdk-2.0.5/ostium_python_sdk/abi/pairs_info_abi.py +2585 -0
- ostium_python_sdk-2.0.5/ostium_python_sdk/abi/pairs_storage_abi.py +1428 -0
- ostium_python_sdk-2.0.5/ostium_python_sdk/abi/trading_abi.py +2003 -0
- ostium_python_sdk-2.0.3/ostium_python_sdk/abi/abi.py → ostium_python_sdk-2.0.5/ostium_python_sdk/abi/trading_storage_abi.py +45 -2239
- ostium_python_sdk-2.0.5/ostium_python_sdk/abi/usdc_abi.py +313 -0
- ostium_python_sdk-2.0.5/ostium_python_sdk/abi/vault_abi.py +2414 -0
- {ostium_python_sdk-2.0.3 → ostium_python_sdk-2.0.5}/ostium_python_sdk/balance.py +1 -1
- {ostium_python_sdk-2.0.3 → ostium_python_sdk-2.0.5}/ostium_python_sdk/faucet.py +1 -1
- {ostium_python_sdk-2.0.3 → ostium_python_sdk-2.0.5}/ostium_python_sdk/formulae.py +39 -15
- {ostium_python_sdk-2.0.3 → ostium_python_sdk-2.0.5}/ostium_python_sdk/formulae_wrapper.py +7 -5
- ostium_python_sdk-2.0.5/ostium_python_sdk/ostium.py +736 -0
- {ostium_python_sdk-2.0.3 → ostium_python_sdk-2.0.5}/ostium_python_sdk/scscript/funding.py +1 -1
- {ostium_python_sdk-2.0.3 → ostium_python_sdk-2.0.5}/ostium_python_sdk/sdk.py +35 -5
- {ostium_python_sdk-2.0.3 → ostium_python_sdk-2.0.5}/ostium_python_sdk/subgraph.py +120 -1
- {ostium_python_sdk-2.0.3 → ostium_python_sdk-2.0.5}/ostium_python_sdk/utils.py +2 -2
- {ostium_python_sdk-2.0.3 → ostium_python_sdk-2.0.5}/ostium_python_sdk.egg-info/PKG-INFO +30 -10
- {ostium_python_sdk-2.0.3 → ostium_python_sdk-2.0.5}/ostium_python_sdk.egg-info/SOURCES.txt +7 -2
- {ostium_python_sdk-2.0.3 → ostium_python_sdk-2.0.5}/setup.py +5 -2
- {ostium_python_sdk-2.0.3 → ostium_python_sdk-2.0.5}/tests/test_trade_liquidation_price.py +37 -22
- ostium_python_sdk-2.0.3/ostium_python_sdk/abi/__init__.py +0 -7
- ostium_python_sdk-2.0.3/ostium_python_sdk/ostium.py +0 -354
- {ostium_python_sdk-2.0.3 → ostium_python_sdk-2.0.5}/MANIFEST.in +0 -0
- {ostium_python_sdk-2.0.3 → ostium_python_sdk-2.0.5}/ostium_python_sdk/__init__.py +0 -0
- /ostium_python_sdk-2.0.3/ostium_python_sdk/abi/faucet_abi.py → /ostium_python_sdk-2.0.5/ostium_python_sdk/abi/faucet_testnet_abi.py +0 -0
- {ostium_python_sdk-2.0.3 → ostium_python_sdk-2.0.5}/ostium_python_sdk/config.py +0 -0
- {ostium_python_sdk-2.0.3 → ostium_python_sdk-2.0.5}/ostium_python_sdk/constants.py +0 -0
- {ostium_python_sdk-2.0.3 → ostium_python_sdk-2.0.5}/ostium_python_sdk/exceptions.py +0 -0
- {ostium_python_sdk-2.0.3 → ostium_python_sdk-2.0.5}/ostium_python_sdk/price.py +0 -0
- {ostium_python_sdk-2.0.3 → ostium_python_sdk-2.0.5}/ostium_python_sdk/scscript/__init__.py +0 -0
- {ostium_python_sdk-2.0.3 → ostium_python_sdk-2.0.5}/ostium_python_sdk.egg-info/dependency_links.txt +0 -0
- {ostium_python_sdk-2.0.3 → ostium_python_sdk-2.0.5}/ostium_python_sdk.egg-info/requires.txt +0 -0
- {ostium_python_sdk-2.0.3 → ostium_python_sdk-2.0.5}/ostium_python_sdk.egg-info/top_level.txt +0 -0
- {ostium_python_sdk-2.0.3 → ostium_python_sdk-2.0.5}/pyproject.toml +0 -0
- {ostium_python_sdk-2.0.3 → ostium_python_sdk-2.0.5}/requirements-dev.txt +0 -0
- {ostium_python_sdk-2.0.3 → ostium_python_sdk-2.0.5}/requirements.txt +0 -0
- {ostium_python_sdk-2.0.3 → ostium_python_sdk-2.0.5}/setup.cfg +0 -0
- {ostium_python_sdk-2.0.3 → ostium_python_sdk-2.0.5}/tests/__init__.py +0 -0
- {ostium_python_sdk-2.0.3 → ostium_python_sdk-2.0.5}/tests/test_current_total_profit_p.py +0 -0
- {ostium_python_sdk-2.0.3 → ostium_python_sdk-2.0.5}/tests/test_current_total_profit_raw.py +0 -0
- {ostium_python_sdk-2.0.3 → ostium_python_sdk-2.0.5}/tests/test_current_trade_profit_p.py +0 -0
- {ostium_python_sdk-2.0.3 → ostium_python_sdk-2.0.5}/tests/test_current_trade_profit_raw.py +0 -0
- {ostium_python_sdk-2.0.3 → ostium_python_sdk-2.0.5}/tests/test_funding.py +0 -0
- {ostium_python_sdk-2.0.3 → ostium_python_sdk-2.0.5}/tests/test_get_price_impact.py +0 -0
- {ostium_python_sdk-2.0.3 → ostium_python_sdk-2.0.5}/tests/test_get_trade_funding_fee.py +0 -0
- {ostium_python_sdk-2.0.3 → ostium_python_sdk-2.0.5}/tests/test_get_trade_rollover_fee.py +0 -0
- {ostium_python_sdk-2.0.3 → ostium_python_sdk-2.0.5}/tests/test_remove_collateral_from_leverage.py +0 -0
- {ostium_python_sdk-2.0.3 → ostium_python_sdk-2.0.5}/tests/test_remove_collateral_with_collateral.py +0 -0
- {ostium_python_sdk-2.0.3 → ostium_python_sdk-2.0.5}/tests/test_slippage.py +0 -0
- {ostium_python_sdk-2.0.3 → ostium_python_sdk-2.0.5}/tests/test_top_up_with_collateral.py +0 -0
- {ostium_python_sdk-2.0.3 → ostium_python_sdk-2.0.5}/tests/test_top_up_with_leverage.py +0 -0
- {ostium_python_sdk-2.0.3 → ostium_python_sdk-2.0.5}/tests/test_trade_get_sl_price.py +0 -0
- {ostium_python_sdk-2.0.3 → ostium_python_sdk-2.0.5}/tests/test_trade_get_tp_price.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: ostium-python-sdk
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.5
|
|
4
4
|
Summary: A python based SDK developed for interacting with Ostium, a leveraged trading application for trading currencies, commodities, indices, crypto and more.
|
|
5
5
|
Home-page: https://github.com/0xOstium/ostium-python-sdk
|
|
6
6
|
Author: ami@ostium.io
|
|
@@ -56,7 +56,8 @@ Basically you can perfrom any operation that is supported by the Ostium's web si
|
|
|
56
56
|
|
|
57
57
|
- Get list of feeds and their details
|
|
58
58
|
- Create a Trade/Order
|
|
59
|
-
- Close a Trade, Set Take Profit, Set Stop Loss
|
|
59
|
+
- Close a Trade, Partial Close a trade, Set Take Profit, Set Stop Loss
|
|
60
|
+
- Add Colleteral, Remove Collateral
|
|
60
61
|
- Cancel an Order, Set Take Profit, Set Stop Loss, Set Entry Price
|
|
61
62
|
- Read Open Trades aka Positions
|
|
62
63
|
- Read Open Orders (Limit, Stop)
|
|
@@ -151,10 +152,10 @@ if not rpc_url:
|
|
|
151
152
|
|
|
152
153
|
# Initialize SDK (default: verbose=False for quiet operation)
|
|
153
154
|
configTestnet = NetworkConfig.testnet()
|
|
154
|
-
sdk = OstiumSDK(configTestnet, private_key)
|
|
155
|
+
sdk = OstiumSDK(configTestnet, private_key, rpc_url)
|
|
155
156
|
|
|
156
157
|
# For verbose mode with detailed logging:
|
|
157
|
-
sdk = OstiumSDK(configTestnet, private_key, verbose=True)
|
|
158
|
+
sdk = OstiumSDK(configTestnet, private_key, rpc_url, verbose=True)
|
|
158
159
|
```
|
|
159
160
|
|
|
160
161
|
<b>NOTE:</b> create a .env file with PRIVATE_KEY and RPC_URL to use the SDK. An RPC URL is required to use the SDK. You can get one by signing up for a free account at https://www.alchemy.com/ and creating an app.
|
|
@@ -178,7 +179,7 @@ As you can see above, we show use case on testnet. In order to use Ostium on tes
|
|
|
178
179
|
```python
|
|
179
180
|
# Get current token amount from faucet
|
|
180
181
|
# On testnet
|
|
181
|
-
sdk = OstiumSDK(NetworkConfig.testnet(), private_key)
|
|
182
|
+
sdk = OstiumSDK(NetworkConfig.testnet(), private_key, rpc_url)
|
|
182
183
|
|
|
183
184
|
# Check if tokens can be requested
|
|
184
185
|
if sdk.faucet.can_request_tokens(address):
|
|
@@ -261,20 +262,20 @@ if not rpc_url:
|
|
|
261
262
|
|
|
262
263
|
# Initialize SDK
|
|
263
264
|
config = NetworkConfig.testnet()
|
|
264
|
-
sdk = OstiumSDK(config, private_key)
|
|
265
|
+
sdk = OstiumSDK(config, private_key, rpc_url)
|
|
265
266
|
|
|
266
267
|
# Or, initialize:
|
|
267
268
|
#
|
|
268
269
|
# (1) mainnet:
|
|
269
270
|
#
|
|
270
271
|
# config = NetworkConfig.mainnet()
|
|
271
|
-
# sdk = OstiumSDK(config, private_key)
|
|
272
|
+
# sdk = OstiumSDK(config, private_key, rpc_url)
|
|
272
273
|
#
|
|
273
274
|
# (2) with explicit private key & rpc url, i.e: not read from env variables
|
|
274
275
|
# sdk = OstiumSDK(
|
|
275
276
|
# network="arbitrum",
|
|
276
277
|
# private_key="your_private_key_here",
|
|
277
|
-
# rpc_url="https://arb1.arbitrum.io/rpc"
|
|
278
|
+
# rpc_url="https://arb1.arbitrum.io/rpc...."
|
|
278
279
|
# )
|
|
279
280
|
|
|
280
281
|
# Get all available pairs
|
|
@@ -390,7 +391,7 @@ if not rpc_url:
|
|
|
390
391
|
|
|
391
392
|
# Initialize SDK
|
|
392
393
|
config = NetworkConfig.testnet()
|
|
393
|
-
sdk = OstiumSDK(config, private_key)
|
|
394
|
+
sdk = OstiumSDK(config, private_key, rpc_url)
|
|
394
395
|
|
|
395
396
|
# Define trade parameters
|
|
396
397
|
order_params = {
|
|
@@ -421,6 +422,11 @@ try:
|
|
|
421
422
|
open_orders = await sdk.subgraph.get_orders(trader_public_address)
|
|
422
423
|
for order_index, order_data in enumerate(open_orders):
|
|
423
424
|
print(f"Order {order_index + 1}: {order_data}\n")
|
|
425
|
+
limit_type, _, _, _, _, _, _, pairIndex, index, _, _ = get_order_details(order_data)
|
|
426
|
+
print(f"You can cancel_limit_order / update_limit_order using pair_id: {pairIndex} and index: {index}\n")
|
|
427
|
+
receipt = sdk.ostium.cancel_limit_order(pairIndex, index)
|
|
428
|
+
print(
|
|
429
|
+
f"Limit Order cancelled! Transaction hash: {receipt['transactionHash'].hex()}")
|
|
424
430
|
|
|
425
431
|
if len(open_orders) == 0:
|
|
426
432
|
print(
|
|
@@ -544,6 +550,20 @@ All notable changes to the Ostium Python SDK will be documented in this file.
|
|
|
544
550
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
545
551
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
546
552
|
|
|
553
|
+
## [2.0.5] - 2025-05-26
|
|
554
|
+
|
|
555
|
+
- Support new ABIs from smart-contracts v.1.2.3: PairInfo, PairStorage, Trading, TradingStorage, Vault.
|
|
556
|
+
- Fix getTradeLiquidationPrice() exposed in sdk.get_open_trade_metrics()
|
|
557
|
+
- Allow get_open_trades() with an optional parameter trader_address
|
|
558
|
+
- Add sdk.get_rollover_rate_for_pair_id()
|
|
559
|
+
|
|
560
|
+
## [2.0.4] - 2025-05-26
|
|
561
|
+
|
|
562
|
+
### Added
|
|
563
|
+
- `track_order_and_trade` that let's you track an order status until its processed.
|
|
564
|
+
- Added support for delegation which allows an approved
|
|
565
|
+
address (delegate) to execute trades on behalf of another address (trader).
|
|
566
|
+
|
|
547
567
|
## [2.0.3] - 2025-03-06
|
|
548
568
|
|
|
549
569
|
### Added
|
|
@@ -17,7 +17,8 @@ Basically you can perfrom any operation that is supported by the Ostium's web si
|
|
|
17
17
|
|
|
18
18
|
- Get list of feeds and their details
|
|
19
19
|
- Create a Trade/Order
|
|
20
|
-
- Close a Trade, Set Take Profit, Set Stop Loss
|
|
20
|
+
- Close a Trade, Partial Close a trade, Set Take Profit, Set Stop Loss
|
|
21
|
+
- Add Colleteral, Remove Collateral
|
|
21
22
|
- Cancel an Order, Set Take Profit, Set Stop Loss, Set Entry Price
|
|
22
23
|
- Read Open Trades aka Positions
|
|
23
24
|
- Read Open Orders (Limit, Stop)
|
|
@@ -112,10 +113,10 @@ if not rpc_url:
|
|
|
112
113
|
|
|
113
114
|
# Initialize SDK (default: verbose=False for quiet operation)
|
|
114
115
|
configTestnet = NetworkConfig.testnet()
|
|
115
|
-
sdk = OstiumSDK(configTestnet, private_key)
|
|
116
|
+
sdk = OstiumSDK(configTestnet, private_key, rpc_url)
|
|
116
117
|
|
|
117
118
|
# For verbose mode with detailed logging:
|
|
118
|
-
sdk = OstiumSDK(configTestnet, private_key, verbose=True)
|
|
119
|
+
sdk = OstiumSDK(configTestnet, private_key, rpc_url, verbose=True)
|
|
119
120
|
```
|
|
120
121
|
|
|
121
122
|
<b>NOTE:</b> create a .env file with PRIVATE_KEY and RPC_URL to use the SDK. An RPC URL is required to use the SDK. You can get one by signing up for a free account at https://www.alchemy.com/ and creating an app.
|
|
@@ -139,7 +140,7 @@ As you can see above, we show use case on testnet. In order to use Ostium on tes
|
|
|
139
140
|
```python
|
|
140
141
|
# Get current token amount from faucet
|
|
141
142
|
# On testnet
|
|
142
|
-
sdk = OstiumSDK(NetworkConfig.testnet(), private_key)
|
|
143
|
+
sdk = OstiumSDK(NetworkConfig.testnet(), private_key, rpc_url)
|
|
143
144
|
|
|
144
145
|
# Check if tokens can be requested
|
|
145
146
|
if sdk.faucet.can_request_tokens(address):
|
|
@@ -222,20 +223,20 @@ if not rpc_url:
|
|
|
222
223
|
|
|
223
224
|
# Initialize SDK
|
|
224
225
|
config = NetworkConfig.testnet()
|
|
225
|
-
sdk = OstiumSDK(config, private_key)
|
|
226
|
+
sdk = OstiumSDK(config, private_key, rpc_url)
|
|
226
227
|
|
|
227
228
|
# Or, initialize:
|
|
228
229
|
#
|
|
229
230
|
# (1) mainnet:
|
|
230
231
|
#
|
|
231
232
|
# config = NetworkConfig.mainnet()
|
|
232
|
-
# sdk = OstiumSDK(config, private_key)
|
|
233
|
+
# sdk = OstiumSDK(config, private_key, rpc_url)
|
|
233
234
|
#
|
|
234
235
|
# (2) with explicit private key & rpc url, i.e: not read from env variables
|
|
235
236
|
# sdk = OstiumSDK(
|
|
236
237
|
# network="arbitrum",
|
|
237
238
|
# private_key="your_private_key_here",
|
|
238
|
-
# rpc_url="https://arb1.arbitrum.io/rpc"
|
|
239
|
+
# rpc_url="https://arb1.arbitrum.io/rpc...."
|
|
239
240
|
# )
|
|
240
241
|
|
|
241
242
|
# Get all available pairs
|
|
@@ -351,7 +352,7 @@ if not rpc_url:
|
|
|
351
352
|
|
|
352
353
|
# Initialize SDK
|
|
353
354
|
config = NetworkConfig.testnet()
|
|
354
|
-
sdk = OstiumSDK(config, private_key)
|
|
355
|
+
sdk = OstiumSDK(config, private_key, rpc_url)
|
|
355
356
|
|
|
356
357
|
# Define trade parameters
|
|
357
358
|
order_params = {
|
|
@@ -382,6 +383,11 @@ try:
|
|
|
382
383
|
open_orders = await sdk.subgraph.get_orders(trader_public_address)
|
|
383
384
|
for order_index, order_data in enumerate(open_orders):
|
|
384
385
|
print(f"Order {order_index + 1}: {order_data}\n")
|
|
386
|
+
limit_type, _, _, _, _, _, _, pairIndex, index, _, _ = get_order_details(order_data)
|
|
387
|
+
print(f"You can cancel_limit_order / update_limit_order using pair_id: {pairIndex} and index: {index}\n")
|
|
388
|
+
receipt = sdk.ostium.cancel_limit_order(pairIndex, index)
|
|
389
|
+
print(
|
|
390
|
+
f"Limit Order cancelled! Transaction hash: {receipt['transactionHash'].hex()}")
|
|
385
391
|
|
|
386
392
|
if len(open_orders) == 0:
|
|
387
393
|
print(
|