ostium-python-sdk 2.0.11__tar.gz → 2.0.13__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 (61) hide show
  1. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/PKG-INFO +11 -3
  2. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/README.md +2 -2
  3. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/ostium_python_sdk/price.py +4 -5
  4. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/ostium_python_sdk/sdk.py +8 -5
  5. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/ostium_python_sdk.egg-info/PKG-INFO +11 -3
  6. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/setup.py +1 -1
  7. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/tests/disabled_test_slippage.py +1 -1
  8. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/MANIFEST.in +0 -0
  9. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/ostium_python_sdk/__init__.py +0 -0
  10. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/ostium_python_sdk/abi/__init__.py +0 -0
  11. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/ostium_python_sdk/abi/faucet_testnet_abi.py +0 -0
  12. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/ostium_python_sdk/abi/pairs_info_abi.py +0 -0
  13. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/ostium_python_sdk/abi/pairs_storage_abi.py +0 -0
  14. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/ostium_python_sdk/abi/trading_abi.py +0 -0
  15. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/ostium_python_sdk/abi/trading_storage_abi.py +0 -0
  16. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/ostium_python_sdk/abi/usdc_abi.py +0 -0
  17. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/ostium_python_sdk/abi/vault_abi.py +0 -0
  18. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/ostium_python_sdk/balance.py +0 -0
  19. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/ostium_python_sdk/config.py +0 -0
  20. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/ostium_python_sdk/constants.py +0 -0
  21. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/ostium_python_sdk/exceptions.py +0 -0
  22. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/ostium_python_sdk/faucet.py +0 -0
  23. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/ostium_python_sdk/formulae.py +0 -0
  24. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/ostium_python_sdk/formulae_wrapper.py +0 -0
  25. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/ostium_python_sdk/ostium.py +0 -0
  26. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/ostium_python_sdk/scscript/__init__.py +0 -0
  27. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/ostium_python_sdk/scscript/funding.py +0 -0
  28. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/ostium_python_sdk/scscript/pairinfos.py +0 -0
  29. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/ostium_python_sdk/subgraph.py +0 -0
  30. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/ostium_python_sdk/utils.py +0 -0
  31. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/ostium_python_sdk.egg-info/SOURCES.txt +0 -0
  32. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/ostium_python_sdk.egg-info/dependency_links.txt +0 -0
  33. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/ostium_python_sdk.egg-info/requires.txt +0 -0
  34. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/ostium_python_sdk.egg-info/top_level.txt +0 -0
  35. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/pyproject.toml +0 -0
  36. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/requirements-dev.txt +0 -0
  37. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/requirements.txt +0 -0
  38. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/setup.cfg +0 -0
  39. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/tests/__init__.py +0 -0
  40. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/tests/conftest.py +0 -0
  41. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/tests/disabled_test_funding.py +0 -0
  42. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/tests/test_current_total_profit_p.py +0 -0
  43. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/tests/test_current_total_profit_raw.py +0 -0
  44. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/tests/test_current_trade_profit_p.py +0 -0
  45. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/tests/test_current_trade_profit_raw.py +0 -0
  46. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/tests/test_get_opening_fee.py +0 -0
  47. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/tests/test_get_pending_acc_funding_fees.py +0 -0
  48. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/tests/test_get_price_impact.py +0 -0
  49. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/tests/test_get_trade_funding_fee.py +0 -0
  50. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/tests/test_get_trade_rollover_fee.py +0 -0
  51. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/tests/test_get_trade_value.py +0 -0
  52. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/tests/test_max_leverage.py +0 -0
  53. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/tests/test_overnight_max_leverage.py +0 -0
  54. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/tests/test_remove_collateral_from_leverage.py +0 -0
  55. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/tests/test_remove_collateral_with_collateral.py +0 -0
  56. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/tests/test_target_funding_rate.py +0 -0
  57. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/tests/test_top_up_with_collateral.py +0 -0
  58. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/tests/test_top_up_with_leverage.py +0 -0
  59. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/tests/test_trade_get_sl_price.py +0 -0
  60. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/tests/test_trade_get_tp_price.py +0 -0
  61. {ostium_python_sdk-2.0.11 → ostium_python_sdk-2.0.13}/tests/test_trade_liquidation_price.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ostium-python-sdk
3
- Version: 2.0.11
3
+ Version: 2.0.13
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
@@ -322,7 +322,7 @@ try:
322
322
  print(f"Slippage percentage set to: {sdk.ostium.get_slippage_percentage()}%")
323
323
 
324
324
  # Get latest price for BTC
325
- latest_price, _ = await sdk.price.get_price("BTC", "USD")
325
+ latest_price, _, _ = await sdk.price.get_price("BTC", "USD")
326
326
  print(f"Latest price: {latest_price}")
327
327
  # Execute trade at current market price
328
328
  receipt = sdk.ostium.perform_trade(trade_params, at_price=latest_price)
@@ -412,7 +412,7 @@ order_params = {
412
412
 
413
413
  try:
414
414
  # Get latest price for ETH
415
- latest_price, _ = await sdk.price.get_price("ETH", "USD")
415
+ latest_price, _, _ = await sdk.price.get_price("ETH", "USD")
416
416
  print(f"Latest price: {latest_price}")
417
417
  # Execute LIMIT trade order at 10% above the current price
418
418
  receipt = sdk.ostium.perform_trade(order_params, at_price=latest_price * 1.1)
@@ -558,6 +558,14 @@ All notable changes to the Ostium Python SDK will be documented in this file.
558
558
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
559
559
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
560
560
 
561
+ ## [2.0.12] - 2025-05-28
562
+
563
+ - return isDayTradingClosed in sdk.get_formatted_pairs_details()
564
+
565
+ ## [2.0.11] - 2025-05-28
566
+
567
+ - improve sdk.get_formatted_pairs_details()
568
+
561
569
  ## [2.0.10] - 2025-05-27
562
570
 
563
571
  - Add sdk.get_target_funding_rate() for pair
@@ -283,7 +283,7 @@ try:
283
283
  print(f"Slippage percentage set to: {sdk.ostium.get_slippage_percentage()}%")
284
284
 
285
285
  # Get latest price for BTC
286
- latest_price, _ = await sdk.price.get_price("BTC", "USD")
286
+ latest_price, _, _ = await sdk.price.get_price("BTC", "USD")
287
287
  print(f"Latest price: {latest_price}")
288
288
  # Execute trade at current market price
289
289
  receipt = sdk.ostium.perform_trade(trade_params, at_price=latest_price)
@@ -373,7 +373,7 @@ order_params = {
373
373
 
374
374
  try:
375
375
  # Get latest price for ETH
376
- latest_price, _ = await sdk.price.get_price("ETH", "USD")
376
+ latest_price, _, _ = await sdk.price.get_price("ETH", "USD")
377
377
  print(f"Latest price: {latest_price}")
378
378
  # Execute LIMIT trade order at 10% above the current price
379
379
  receipt = sdk.ostium.perform_trade(order_params, at_price=latest_price * 1.1)
@@ -5,16 +5,15 @@ from typing import Tuple
5
5
  class Price:
6
6
  def __init__(self, verbose=False):
7
7
  self.verbose = verbose
8
- self.base_url = "https://listener.ostium.io"
8
+ self.base_url = "https://metadata-backend.ostium.io"
9
9
 
10
10
  def log(self, message):
11
11
  if self.verbose:
12
12
  print(message)
13
13
 
14
- # Returns a list of price data, e.g: [{'feed_id': '0x00039d9e45394f473ab1f050a1b963e6b05351e52d71e507509ada0c95ed75b8', 'bid': 97241.43864211132, 'mid': 97243.36503172085, 'ask': 97245.2739217016, 'isMarketOpen': True, 'from': 'BTC', 'to': 'USD', 'timestampSeconds': 1740043714}, ...]
15
14
  async def get_latest_prices(self):
16
15
  """
17
- Fetches the latest prices from the Ostium price listener service.
16
+ Fetches the latest prices from the Ostium metadata-backend service.
18
17
  Returns a dictionary of price data.
19
18
  """
20
19
  async with aiohttp.ClientSession() as session:
@@ -36,12 +35,12 @@ class Price:
36
35
  raise ValueError(f"No price found for pair: {from_asset}/{to_asset}")
37
36
 
38
37
  # Returns a mid price and isMarketOpen tuple, e.g: (97243.36503172085, True)
39
- async def get_price(self, from_currency, to_currency):
38
+ async def get_price(self, from_currency, to_currency) -> Tuple[float, bool, bool]:
40
39
  self.log(f"Getting price for {from_currency}/{to_currency}")
41
40
  prices = await self.get_latest_prices()
42
41
  for price_data in prices:
43
42
  if (price_data.get('from') == from_currency and
44
43
  price_data.get('to') == to_currency):
45
- return float(price_data.get('mid', 0)), price_data.get('isMarketOpen', False)
44
+ return float(price_data.get('mid', 0)), price_data.get('isMarketOpen', False), price_data.get('isDayTradingClosed', False)
46
45
  raise ValueError(
47
46
  f"No price found for pair: {from_currency}/{to_currency}")
@@ -155,7 +155,7 @@ class OstiumSDK:
155
155
 
156
156
  currLongOI = Decimal(pair_details['longOI']) / PRECISION_6
157
157
  currShortOI = Decimal(pair_details['shortOI']) / PRECISION_6
158
- maxOI = Decimal(pair_details['maxOI']) / PRECISION_6
158
+ maxOI = Decimal(pair_details['maxOI']) / PRECISION_6 # maxOI is in USD
159
159
 
160
160
  openInterestMax = max(currLongOI, currShortOI)
161
161
  normalizedOiDelta = ((currLongOI - currShortOI).quantize(PRECISION_6, rounding=ROUND_DOWN) / max(
@@ -267,13 +267,13 @@ class OstiumSDK:
267
267
  'maxOI': Decimal(pair['maxOI']) / PRECISION_6,
268
268
  'makerFeeP': Decimal(pair['makerFeeP']) / PRECISION_6,
269
269
  'takerFeeP': Decimal(pair['takerFeeP']) / PRECISION_6,
270
- 'minLeverage': int(pair['minLeverage']) / 100 if int(
270
+ 'minLeverage': int(pair['minLeverage']) / PRECISION_2 if int(
271
271
  pair['group']['minLeverage']) == 0 else Decimal(pair['group']['minLeverage']) / PRECISION_2,
272
- 'maxLeverage': int(pair['maxLeverage']) / 100 if int(
272
+ 'maxLeverage': int(pair['maxLeverage']) / PRECISION_2 if int(
273
273
  pair['group']['maxLeverage']) == 0 else Decimal(pair['group']['maxLeverage']) / PRECISION_2,
274
274
  'makerMaxLeverage': Decimal(pair['makerMaxLeverage']) / PRECISION_2,
275
275
  'groupMaxCollateralP': Decimal(pair['group']['maxCollateralP']) / PRECISION_2,
276
- 'minLevPos': Decimal(pair['fee']['minLevPos']) / PRECISION_9,
276
+ 'minLevPos': Decimal(pair['fee']['minLevPos']) / PRECISION_6,
277
277
  'lastFundingRate': Decimal(pair['lastFundingRate']) / PRECISION_9,
278
278
  'curFundingLong': Decimal(pair['curFundingLong']) / PRECISION_9,
279
279
  'curFundingShort': Decimal(pair['curFundingShort']) / PRECISION_9,
@@ -287,7 +287,7 @@ class OstiumSDK:
287
287
  if including_current_price_and_market_status:
288
288
  # Get current price and market status
289
289
  try:
290
- price, is_market_open = await self.price.get_price(
290
+ price, is_market_open, is_day_trading_closed = await self.price.get_price(
291
291
  pair['from'],
292
292
  pair['to']
293
293
  )
@@ -295,9 +295,12 @@ class OstiumSDK:
295
295
  formatted_pair['price'] = price
296
296
  if is_market_open is not None:
297
297
  formatted_pair['isMarketOpen'] = is_market_open
298
+ if is_day_trading_closed is not None:
299
+ formatted_pair['isDayTradingClosed'] = is_day_trading_closed
298
300
  except ValueError:
299
301
  pass
300
302
 
301
303
  formatted_pairs.append(formatted_pair)
302
304
 
305
+ formatted_pairs.sort(key=lambda x: x['id'])
303
306
  return formatted_pairs
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ostium-python-sdk
3
- Version: 2.0.11
3
+ Version: 2.0.13
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
@@ -322,7 +322,7 @@ try:
322
322
  print(f"Slippage percentage set to: {sdk.ostium.get_slippage_percentage()}%")
323
323
 
324
324
  # Get latest price for BTC
325
- latest_price, _ = await sdk.price.get_price("BTC", "USD")
325
+ latest_price, _, _ = await sdk.price.get_price("BTC", "USD")
326
326
  print(f"Latest price: {latest_price}")
327
327
  # Execute trade at current market price
328
328
  receipt = sdk.ostium.perform_trade(trade_params, at_price=latest_price)
@@ -412,7 +412,7 @@ order_params = {
412
412
 
413
413
  try:
414
414
  # Get latest price for ETH
415
- latest_price, _ = await sdk.price.get_price("ETH", "USD")
415
+ latest_price, _, _ = await sdk.price.get_price("ETH", "USD")
416
416
  print(f"Latest price: {latest_price}")
417
417
  # Execute LIMIT trade order at 10% above the current price
418
418
  receipt = sdk.ostium.perform_trade(order_params, at_price=latest_price * 1.1)
@@ -558,6 +558,14 @@ All notable changes to the Ostium Python SDK will be documented in this file.
558
558
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
559
559
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
560
560
 
561
+ ## [2.0.12] - 2025-05-28
562
+
563
+ - return isDayTradingClosed in sdk.get_formatted_pairs_details()
564
+
565
+ ## [2.0.11] - 2025-05-28
566
+
567
+ - improve sdk.get_formatted_pairs_details()
568
+
561
569
  ## [2.0.10] - 2025-05-27
562
570
 
563
571
  - Add sdk.get_target_funding_rate() for pair
@@ -22,7 +22,7 @@ if changelog_path.exists():
22
22
 
23
23
  setup(
24
24
  name="ostium-python-sdk",
25
- version="2.0.11",
25
+ version="2.0.13",
26
26
  packages=find_packages(),
27
27
  install_requires=read_requirements('requirements.txt'),
28
28
  extras_require={
@@ -45,7 +45,7 @@ async def test_slippage_validation(sdk):
45
45
  pytest.skip(msg)
46
46
 
47
47
  # Get latest price for BTC
48
- latest_price, _ = await sdk.price.get_price("BTC", "USD")
48
+ latest_price, _, _ = await sdk.price.get_price("BTC", "USD")
49
49
  latest_price = Decimal(str(latest_price)) # Convert float to Decimal
50
50
  print(f"Latest price: {latest_price}")
51
51