ostium-python-sdk 0.1.20__tar.gz → 0.1.22__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.
Files changed (22) hide show
  1. {ostium_python_sdk-0.1.20 → ostium_python_sdk-0.1.22}/PKG-INFO +70 -5
  2. {ostium_python_sdk-0.1.20 → ostium_python_sdk-0.1.22}/README.md +69 -4
  3. {ostium_python_sdk-0.1.20 → ostium_python_sdk-0.1.22}/ostium_python_sdk.egg-info/PKG-INFO +70 -5
  4. {ostium_python_sdk-0.1.20 → ostium_python_sdk-0.1.22}/setup.py +1 -1
  5. {ostium_python_sdk-0.1.20 → ostium_python_sdk-0.1.22}/ostium_python_sdk/__init__.py +0 -0
  6. {ostium_python_sdk-0.1.20 → ostium_python_sdk-0.1.22}/ostium_python_sdk/abi.py +0 -0
  7. {ostium_python_sdk-0.1.20 → ostium_python_sdk-0.1.22}/ostium_python_sdk/balance.py +0 -0
  8. {ostium_python_sdk-0.1.20 → ostium_python_sdk-0.1.22}/ostium_python_sdk/config.py +0 -0
  9. {ostium_python_sdk-0.1.20 → ostium_python_sdk-0.1.22}/ostium_python_sdk/constants.py +0 -0
  10. {ostium_python_sdk-0.1.20 → ostium_python_sdk-0.1.22}/ostium_python_sdk/formulae.py +0 -0
  11. {ostium_python_sdk-0.1.20 → ostium_python_sdk-0.1.22}/ostium_python_sdk/formulae_wrapper.py +0 -0
  12. {ostium_python_sdk-0.1.20 → ostium_python_sdk-0.1.22}/ostium_python_sdk/ostium.py +0 -0
  13. {ostium_python_sdk-0.1.20 → ostium_python_sdk-0.1.22}/ostium_python_sdk/price.py +0 -0
  14. {ostium_python_sdk-0.1.20 → ostium_python_sdk-0.1.22}/ostium_python_sdk/sdk.py +0 -0
  15. {ostium_python_sdk-0.1.20 → ostium_python_sdk-0.1.22}/ostium_python_sdk/subgraph.py +0 -0
  16. {ostium_python_sdk-0.1.20 → ostium_python_sdk-0.1.22}/ostium_python_sdk/utils.py +0 -0
  17. {ostium_python_sdk-0.1.20 → ostium_python_sdk-0.1.22}/ostium_python_sdk.egg-info/SOURCES.txt +0 -0
  18. {ostium_python_sdk-0.1.20 → ostium_python_sdk-0.1.22}/ostium_python_sdk.egg-info/dependency_links.txt +0 -0
  19. {ostium_python_sdk-0.1.20 → ostium_python_sdk-0.1.22}/ostium_python_sdk.egg-info/requires.txt +0 -0
  20. {ostium_python_sdk-0.1.20 → ostium_python_sdk-0.1.22}/ostium_python_sdk.egg-info/top_level.txt +0 -0
  21. {ostium_python_sdk-0.1.20 → ostium_python_sdk-0.1.22}/pyproject.toml +0 -0
  22. {ostium_python_sdk-0.1.20 → ostium_python_sdk-0.1.22}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ostium-python-sdk
3
- Version: 0.1.20
3
+ Version: 0.1.22
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
@@ -113,9 +113,9 @@ The intraction with Ostium platform is denoted with pair_id and trade_index.
113
113
  | 9 | SOL-USD | Solana |
114
114
  | 10 | SPX-USD | S&P 500 Index |
115
115
 
116
- ## Usage Example
116
+ ## Usage Examples
117
117
 
118
- ### Opening a Trade, Reading Open Trades, Setting Take Profit and Stop Loss, Closing a Trade
118
+ ### Reading available pairs / feeds
119
119
 
120
120
  ```python
121
121
  from ostium_python_sdk import OstiumSDK
@@ -159,8 +159,11 @@ for pair in pairs:
159
159
  for key, value in pair_details.items():
160
160
  print(f"{key}: {value}")
161
161
  print("----------------------------------------")
162
+ ```
162
163
 
164
+ ### Opening a Trade, Reading Open Trades, Setting TP and SL, Closing a Trade
163
165
 
166
+ ```python
164
167
  # Define trade parameters
165
168
  trade_params = {
166
169
  'collateral': 100, # USDC amount
@@ -214,15 +217,77 @@ try:
214
217
  print(
215
218
  f"Closed trade! Transaction hash: {receipt['transactionHash'].hex()}\n")
216
219
 
217
-
218
-
219
220
  except Exception as e:
220
221
  print(f"Trade failed: {str(e)}")
221
222
 
222
223
  ```
223
224
 
225
+ ### Create a Short ETH Limit Order
226
+
227
+ This example shows how to create a short ETH limit order, 10% below the current ETHUSD price.
228
+
229
+ ```python
230
+ # Get private key from environment variable
231
+ private_key = os.getenv('PRIVATE_KEY')
232
+ if not private_key:
233
+ raise ValueError("PRIVATE_KEY not found in .env file")
234
+
235
+ rpc_url = os.getenv('RPC_URL')
236
+ if not rpc_url:
237
+ raise ValueError("RPC_URL not found in .env file")
238
+
239
+ # Initialize SDK
240
+ config = NetworkConfig.testnet()
241
+ sdk = OstiumSDK(config, private_key)
242
+
243
+ # Define trade parameters
244
+ order_params = {
245
+ 'collateral': 10, # USDC amount
246
+ 'leverage': 50, # Leverage multiplier
247
+ 'asset_type': 1, # 1 for ETH
248
+ 'direction': False, # True for Long, False for Short
249
+ 'order_type': 'LIMIT' # 'MARKET', 'LIMIT', or 'STOP'
250
+ }
251
+
252
+ try:
253
+ # Get latest price for ETH
254
+ latest_price, _ = await sdk.price.get_price("ETH", "USD")
255
+ print(f"Latest price: {latest_price}")
256
+ # Execute trade at current market price
257
+ receipt = sdk.ostium.perform_trade(order_params, at_price=latest_price * 1.1)
258
+ print(
259
+ f"Order successful! Transaction hash: {receipt['transactionHash'].hex()}")
260
+
261
+ # Wait for the transaction to be confirmed
262
+ await asyncio.sleep(10)
263
+
264
+ # Get public address from private key
265
+ account = Account.from_key(private_key)
266
+ trader_public_address = account.address
267
+
268
+ # Get the trade details
269
+ open_orders = await sdk.subgraph.get_orders(trader_public_address)
270
+ for order_index, order_data in enumerate(open_orders):
271
+ print(f"Order {order_index + 1}: {order_data}\n")
272
+
273
+ if len(open_orders) == 0:
274
+ print(
275
+ "No open order found. Maybe the order failed? enough USDC and ETH in the account?")
276
+ else:
277
+ opened_order = open_orders[len(open_orders) - 1]
278
+ print(f"Opened order: {opened_order}\n")
279
+
280
+ except Exception as e:
281
+ print(f"Order failed: {str(e)}")
282
+ ```
283
+
284
+ <b>NOTE:</b> Similiarly you can create a Stop order, just use 'STOP' as the order_type and make sure at_price is set to the stop loss price.
285
+
286
+
287
+
224
288
  ## Example Usage Scripts
225
289
 
290
+ More examples can be found in the [examples](https://github.com/0xOstium/ostium_python_sdk/tree/main/examples) folder.
226
291
 
227
292
  ### Read Block Number
228
293
 
@@ -98,9 +98,9 @@ The intraction with Ostium platform is denoted with pair_id and trade_index.
98
98
  | 9 | SOL-USD | Solana |
99
99
  | 10 | SPX-USD | S&P 500 Index |
100
100
 
101
- ## Usage Example
101
+ ## Usage Examples
102
102
 
103
- ### Opening a Trade, Reading Open Trades, Setting Take Profit and Stop Loss, Closing a Trade
103
+ ### Reading available pairs / feeds
104
104
 
105
105
  ```python
106
106
  from ostium_python_sdk import OstiumSDK
@@ -144,8 +144,11 @@ for pair in pairs:
144
144
  for key, value in pair_details.items():
145
145
  print(f"{key}: {value}")
146
146
  print("----------------------------------------")
147
+ ```
147
148
 
149
+ ### Opening a Trade, Reading Open Trades, Setting TP and SL, Closing a Trade
148
150
 
151
+ ```python
149
152
  # Define trade parameters
150
153
  trade_params = {
151
154
  'collateral': 100, # USDC amount
@@ -199,15 +202,77 @@ try:
199
202
  print(
200
203
  f"Closed trade! Transaction hash: {receipt['transactionHash'].hex()}\n")
201
204
 
202
-
203
-
204
205
  except Exception as e:
205
206
  print(f"Trade failed: {str(e)}")
206
207
 
207
208
  ```
208
209
 
210
+ ### Create a Short ETH Limit Order
211
+
212
+ This example shows how to create a short ETH limit order, 10% below the current ETHUSD price.
213
+
214
+ ```python
215
+ # Get private key from environment variable
216
+ private_key = os.getenv('PRIVATE_KEY')
217
+ if not private_key:
218
+ raise ValueError("PRIVATE_KEY not found in .env file")
219
+
220
+ rpc_url = os.getenv('RPC_URL')
221
+ if not rpc_url:
222
+ raise ValueError("RPC_URL not found in .env file")
223
+
224
+ # Initialize SDK
225
+ config = NetworkConfig.testnet()
226
+ sdk = OstiumSDK(config, private_key)
227
+
228
+ # Define trade parameters
229
+ order_params = {
230
+ 'collateral': 10, # USDC amount
231
+ 'leverage': 50, # Leverage multiplier
232
+ 'asset_type': 1, # 1 for ETH
233
+ 'direction': False, # True for Long, False for Short
234
+ 'order_type': 'LIMIT' # 'MARKET', 'LIMIT', or 'STOP'
235
+ }
236
+
237
+ try:
238
+ # Get latest price for ETH
239
+ latest_price, _ = await sdk.price.get_price("ETH", "USD")
240
+ print(f"Latest price: {latest_price}")
241
+ # Execute trade at current market price
242
+ receipt = sdk.ostium.perform_trade(order_params, at_price=latest_price * 1.1)
243
+ print(
244
+ f"Order successful! Transaction hash: {receipt['transactionHash'].hex()}")
245
+
246
+ # Wait for the transaction to be confirmed
247
+ await asyncio.sleep(10)
248
+
249
+ # Get public address from private key
250
+ account = Account.from_key(private_key)
251
+ trader_public_address = account.address
252
+
253
+ # Get the trade details
254
+ open_orders = await sdk.subgraph.get_orders(trader_public_address)
255
+ for order_index, order_data in enumerate(open_orders):
256
+ print(f"Order {order_index + 1}: {order_data}\n")
257
+
258
+ if len(open_orders) == 0:
259
+ print(
260
+ "No open order found. Maybe the order failed? enough USDC and ETH in the account?")
261
+ else:
262
+ opened_order = open_orders[len(open_orders) - 1]
263
+ print(f"Opened order: {opened_order}\n")
264
+
265
+ except Exception as e:
266
+ print(f"Order failed: {str(e)}")
267
+ ```
268
+
269
+ <b>NOTE:</b> Similiarly you can create a Stop order, just use 'STOP' as the order_type and make sure at_price is set to the stop loss price.
270
+
271
+
272
+
209
273
  ## Example Usage Scripts
210
274
 
275
+ More examples can be found in the [examples](https://github.com/0xOstium/ostium_python_sdk/tree/main/examples) folder.
211
276
 
212
277
  ### Read Block Number
213
278
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ostium-python-sdk
3
- Version: 0.1.20
3
+ Version: 0.1.22
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
@@ -113,9 +113,9 @@ The intraction with Ostium platform is denoted with pair_id and trade_index.
113
113
  | 9 | SOL-USD | Solana |
114
114
  | 10 | SPX-USD | S&P 500 Index |
115
115
 
116
- ## Usage Example
116
+ ## Usage Examples
117
117
 
118
- ### Opening a Trade, Reading Open Trades, Setting Take Profit and Stop Loss, Closing a Trade
118
+ ### Reading available pairs / feeds
119
119
 
120
120
  ```python
121
121
  from ostium_python_sdk import OstiumSDK
@@ -159,8 +159,11 @@ for pair in pairs:
159
159
  for key, value in pair_details.items():
160
160
  print(f"{key}: {value}")
161
161
  print("----------------------------------------")
162
+ ```
162
163
 
164
+ ### Opening a Trade, Reading Open Trades, Setting TP and SL, Closing a Trade
163
165
 
166
+ ```python
164
167
  # Define trade parameters
165
168
  trade_params = {
166
169
  'collateral': 100, # USDC amount
@@ -214,15 +217,77 @@ try:
214
217
  print(
215
218
  f"Closed trade! Transaction hash: {receipt['transactionHash'].hex()}\n")
216
219
 
217
-
218
-
219
220
  except Exception as e:
220
221
  print(f"Trade failed: {str(e)}")
221
222
 
222
223
  ```
223
224
 
225
+ ### Create a Short ETH Limit Order
226
+
227
+ This example shows how to create a short ETH limit order, 10% below the current ETHUSD price.
228
+
229
+ ```python
230
+ # Get private key from environment variable
231
+ private_key = os.getenv('PRIVATE_KEY')
232
+ if not private_key:
233
+ raise ValueError("PRIVATE_KEY not found in .env file")
234
+
235
+ rpc_url = os.getenv('RPC_URL')
236
+ if not rpc_url:
237
+ raise ValueError("RPC_URL not found in .env file")
238
+
239
+ # Initialize SDK
240
+ config = NetworkConfig.testnet()
241
+ sdk = OstiumSDK(config, private_key)
242
+
243
+ # Define trade parameters
244
+ order_params = {
245
+ 'collateral': 10, # USDC amount
246
+ 'leverage': 50, # Leverage multiplier
247
+ 'asset_type': 1, # 1 for ETH
248
+ 'direction': False, # True for Long, False for Short
249
+ 'order_type': 'LIMIT' # 'MARKET', 'LIMIT', or 'STOP'
250
+ }
251
+
252
+ try:
253
+ # Get latest price for ETH
254
+ latest_price, _ = await sdk.price.get_price("ETH", "USD")
255
+ print(f"Latest price: {latest_price}")
256
+ # Execute trade at current market price
257
+ receipt = sdk.ostium.perform_trade(order_params, at_price=latest_price * 1.1)
258
+ print(
259
+ f"Order successful! Transaction hash: {receipt['transactionHash'].hex()}")
260
+
261
+ # Wait for the transaction to be confirmed
262
+ await asyncio.sleep(10)
263
+
264
+ # Get public address from private key
265
+ account = Account.from_key(private_key)
266
+ trader_public_address = account.address
267
+
268
+ # Get the trade details
269
+ open_orders = await sdk.subgraph.get_orders(trader_public_address)
270
+ for order_index, order_data in enumerate(open_orders):
271
+ print(f"Order {order_index + 1}: {order_data}\n")
272
+
273
+ if len(open_orders) == 0:
274
+ print(
275
+ "No open order found. Maybe the order failed? enough USDC and ETH in the account?")
276
+ else:
277
+ opened_order = open_orders[len(open_orders) - 1]
278
+ print(f"Opened order: {opened_order}\n")
279
+
280
+ except Exception as e:
281
+ print(f"Order failed: {str(e)}")
282
+ ```
283
+
284
+ <b>NOTE:</b> Similiarly you can create a Stop order, just use 'STOP' as the order_type and make sure at_price is set to the stop loss price.
285
+
286
+
287
+
224
288
  ## Example Usage Scripts
225
289
 
290
+ More examples can be found in the [examples](https://github.com/0xOstium/ostium_python_sdk/tree/main/examples) folder.
226
291
 
227
292
  ### Read Block Number
228
293
 
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="ostium-python-sdk",
5
- version="0.1.20",
5
+ version="0.1.22",
6
6
  packages=find_packages(),
7
7
  install_requires=[
8
8
  "web3>=6.0.0",