ostium-python-sdk 2.0.15__tar.gz → 2.0.17__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.15 → ostium_python_sdk-2.0.17}/PKG-INFO +14 -33
  2. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/README.md +0 -32
  3. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/ostium_python_sdk/formulae.py +2 -2
  4. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/ostium_python_sdk/formulae_wrapper.py +1 -1
  5. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/ostium_python_sdk/scscript/funding.py +1 -1
  6. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/ostium_python_sdk/sdk.py +2 -2
  7. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/ostium_python_sdk.egg-info/PKG-INFO +14 -33
  8. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/setup.py +1 -1
  9. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/tests/test_get_pending_acc_funding_fees.py +2 -2
  10. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/MANIFEST.in +0 -0
  11. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/ostium_python_sdk/__init__.py +0 -0
  12. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/ostium_python_sdk/abi/__init__.py +0 -0
  13. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/ostium_python_sdk/abi/faucet_testnet_abi.py +0 -0
  14. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/ostium_python_sdk/abi/pairs_info_abi.py +0 -0
  15. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/ostium_python_sdk/abi/pairs_storage_abi.py +0 -0
  16. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/ostium_python_sdk/abi/trading_abi.py +0 -0
  17. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/ostium_python_sdk/abi/trading_storage_abi.py +0 -0
  18. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/ostium_python_sdk/abi/usdc_abi.py +0 -0
  19. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/ostium_python_sdk/abi/vault_abi.py +0 -0
  20. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/ostium_python_sdk/balance.py +0 -0
  21. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/ostium_python_sdk/config.py +0 -0
  22. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/ostium_python_sdk/constants.py +0 -0
  23. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/ostium_python_sdk/exceptions.py +0 -0
  24. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/ostium_python_sdk/faucet.py +0 -0
  25. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/ostium_python_sdk/ostium.py +0 -0
  26. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/ostium_python_sdk/price.py +0 -0
  27. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/ostium_python_sdk/scscript/__init__.py +0 -0
  28. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/ostium_python_sdk/scscript/pairinfos.py +0 -0
  29. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/ostium_python_sdk/subgraph.py +0 -0
  30. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/ostium_python_sdk/utils.py +0 -0
  31. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/ostium_python_sdk.egg-info/SOURCES.txt +0 -0
  32. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/ostium_python_sdk.egg-info/dependency_links.txt +0 -0
  33. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/ostium_python_sdk.egg-info/requires.txt +0 -0
  34. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/ostium_python_sdk.egg-info/top_level.txt +0 -0
  35. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/pyproject.toml +0 -0
  36. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/requirements-dev.txt +0 -0
  37. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/requirements.txt +0 -0
  38. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/setup.cfg +0 -0
  39. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/tests/__init__.py +0 -0
  40. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/tests/conftest.py +0 -0
  41. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/tests/disabled_test_funding.py +0 -0
  42. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/tests/disabled_test_slippage.py +0 -0
  43. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/tests/test_current_total_profit_p.py +0 -0
  44. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/tests/test_current_total_profit_raw.py +0 -0
  45. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/tests/test_current_trade_profit_p.py +0 -0
  46. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/tests/test_current_trade_profit_raw.py +0 -0
  47. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/tests/test_get_opening_fee.py +0 -0
  48. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/tests/test_get_price_impact.py +0 -0
  49. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/tests/test_get_trade_funding_fee.py +0 -0
  50. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/tests/test_get_trade_rollover_fee.py +0 -0
  51. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/tests/test_get_trade_value.py +0 -0
  52. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/tests/test_max_leverage.py +0 -0
  53. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/tests/test_overnight_max_leverage.py +0 -0
  54. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/tests/test_remove_collateral_from_leverage.py +0 -0
  55. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/tests/test_remove_collateral_with_collateral.py +0 -0
  56. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/tests/test_target_funding_rate.py +0 -0
  57. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/tests/test_top_up_with_collateral.py +0 -0
  58. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/tests/test_top_up_with_leverage.py +0 -0
  59. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/tests/test_trade_get_sl_price.py +0 -0
  60. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/tests/test_trade_get_tp_price.py +0 -0
  61. {ostium_python_sdk-2.0.15 → ostium_python_sdk-2.0.17}/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.15
3
+ Version: 2.0.17
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
@@ -463,38 +463,6 @@ except Exception as e:
463
463
 
464
464
  <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 an acceptable stop loss price.
465
465
 
466
-
467
- ### Add Colateral
468
-
469
- Added in version 0.1.2
470
-
471
- ### Add control of Slippage - Not only default 2%
472
-
473
- Added in version 0.1.25
474
-
475
- ### Remove Colleteral - Add when Audit is done
476
- TBD
477
-
478
- ### Tp / Sl - explain not specifying what means - 900 % for TP max and SL meaning
479
- TBD
480
-
481
- ### Maybe take or Make sure we have the error mapping from code to string errro msgs.
482
- TBD
483
-
484
-
485
- ### Get a certain Pair Net Rate % (Funding Fees, Rollover)
486
-
487
- ```bash
488
- ### Use sdk.get_pair_net_rate_percent_per_hours()
489
- ```
490
-
491
- ### Open Trade Fees calculation - SDK to get breakdown of FF, RF, PnL, etc.
492
-
493
- ```bash
494
- ## Use sdk.get_open_trade_metrics()
495
- ```
496
-
497
-
498
466
  ## Example Usage Scripts
499
467
 
500
468
  More examples can be found in the [examples](https://github.com/0xOstium/ostium_python_sdk/tree/main/examples) folder.
@@ -572,6 +540,19 @@ All notable changes to the Ostium Python SDK will be documented in this file.
572
540
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
573
541
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
574
542
 
543
+ ## [2.0.17] - 2025-06-03
544
+
545
+ - Return target_funding_rate from getPendingAccFundingFees()
546
+
547
+ ## [2.0.16] - 2025-05-31
548
+
549
+ - query optional different address in sdk.get_open_trade_metrics()
550
+
551
+ ## [2.0.15] - 2025-05-28
552
+
553
+ - Updated Readme with list of pairs
554
+ - Add additional fields to get_open_trade_metrics: bid, mid, ask, status
555
+
575
556
  ## [2.0.12] - 2025-05-28
576
557
 
577
558
  - return isDayTradingClosed in sdk.get_formatted_pairs_details()
@@ -424,38 +424,6 @@ except Exception as e:
424
424
 
425
425
  <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 an acceptable stop loss price.
426
426
 
427
-
428
- ### Add Colateral
429
-
430
- Added in version 0.1.2
431
-
432
- ### Add control of Slippage - Not only default 2%
433
-
434
- Added in version 0.1.25
435
-
436
- ### Remove Colleteral - Add when Audit is done
437
- TBD
438
-
439
- ### Tp / Sl - explain not specifying what means - 900 % for TP max and SL meaning
440
- TBD
441
-
442
- ### Maybe take or Make sure we have the error mapping from code to string errro msgs.
443
- TBD
444
-
445
-
446
- ### Get a certain Pair Net Rate % (Funding Fees, Rollover)
447
-
448
- ```bash
449
- ### Use sdk.get_pair_net_rate_percent_per_hours()
450
- ```
451
-
452
- ### Open Trade Fees calculation - SDK to get breakdown of FF, RF, PnL, etc.
453
-
454
- ```bash
455
- ## Use sdk.get_open_trade_metrics()
456
- ```
457
-
458
-
459
427
  ## Example Usage Scripts
460
428
 
461
429
  More examples can be found in the [examples](https://github.com/0xOstium/ostium_python_sdk/tree/main/examples) folder.
@@ -242,7 +242,7 @@ def GetFundingRate(
242
242
  sFactorDownScaleP: str,
243
243
  verbose: bool = False
244
244
  ):
245
- acc_funding_long, acc_funding_short, latest_funding_rate = getPendingAccFundingFees(
245
+ acc_funding_long, acc_funding_short, latest_funding_rate, target_funding_rate = getPendingAccFundingFees(
246
246
  blockNumber=Decimal(latestBlock),
247
247
  lastUpdateBlock=Decimal(lastUpdateBlock),
248
248
  valueLong=Decimal(accPerOiLong) / PRECISION_18,
@@ -264,5 +264,5 @@ def GetFundingRate(
264
264
  'accFundingLong': acc_funding_long,
265
265
  'accFundingShort': acc_funding_short,
266
266
  'latestFundingRate': latest_funding_rate,
267
- # 'targetFundingRate': target_fr
267
+ 'targetFundingRate': target_funding_rate
268
268
  }
@@ -144,7 +144,7 @@ def get_trade_metrics(trade_details, price_data, block_number, pair_max_leverage
144
144
  pnl = Decimal(pnl_raw)
145
145
  pnl_percent = Decimal(pnl_percent_raw)
146
146
  net_pnl = Decimal(total_profit_raw)
147
-
147
+
148
148
  funding = Decimal(trade_funding_fee)
149
149
  rollover = Decimal(trade_rollover_fee)
150
150
  net_value = net_pnl + (Decimal(trade_details['collateral']) / PRECISION_6)
@@ -78,7 +78,7 @@ def getPendingAccFundingFees(
78
78
  valueShort -= accFundingRate
79
79
  valueLong += (accFundingRate * openInterestUsdcShort / openInterestUsdcLong).quantize(quantization_18, rounding=ROUND_DOWN) if openInterestUsdcLong > 0 else 0
80
80
 
81
- return (valueLong.quantize(quantization_18, rounding=ROUND_DOWN), valueShort.quantize(quantization_18, rounding=ROUND_DOWN), fr.quantize(quantization_18, rounding=ROUND_DOWN))
81
+ return (valueLong.quantize(quantization_18, rounding=ROUND_DOWN), valueShort.quantize(quantization_18, rounding=ROUND_DOWN), fr.quantize(quantization_18, rounding=ROUND_DOWN), targetFr.quantize(quantization_18, rounding=ROUND_DOWN))
82
82
 
83
83
 
84
84
  def exponentialApproximation(value):
@@ -107,8 +107,8 @@ class OstiumSDK:
107
107
  # such as: funding fee, roll over fee, Unrealized Pnl, Profit Percent, etc.
108
108
  #
109
109
  # Will thorw in case SDK instantiated with no private key
110
- async def get_open_trade_metrics(self, pair_id, trade_index):
111
- open_trades, trader_public_address = await self.get_open_trades()
110
+ async def get_open_trade_metrics(self, pair_id, trade_index, trader_address=None):
111
+ open_trades, trader_public_address = await self.get_open_trades(trader_address)
112
112
 
113
113
  liq_margin_threshold_p = await self.subgraph.get_liq_margin_threshold_p()
114
114
  self.log(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ostium-python-sdk
3
- Version: 2.0.15
3
+ Version: 2.0.17
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
@@ -463,38 +463,6 @@ except Exception as e:
463
463
 
464
464
  <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 an acceptable stop loss price.
465
465
 
466
-
467
- ### Add Colateral
468
-
469
- Added in version 0.1.2
470
-
471
- ### Add control of Slippage - Not only default 2%
472
-
473
- Added in version 0.1.25
474
-
475
- ### Remove Colleteral - Add when Audit is done
476
- TBD
477
-
478
- ### Tp / Sl - explain not specifying what means - 900 % for TP max and SL meaning
479
- TBD
480
-
481
- ### Maybe take or Make sure we have the error mapping from code to string errro msgs.
482
- TBD
483
-
484
-
485
- ### Get a certain Pair Net Rate % (Funding Fees, Rollover)
486
-
487
- ```bash
488
- ### Use sdk.get_pair_net_rate_percent_per_hours()
489
- ```
490
-
491
- ### Open Trade Fees calculation - SDK to get breakdown of FF, RF, PnL, etc.
492
-
493
- ```bash
494
- ## Use sdk.get_open_trade_metrics()
495
- ```
496
-
497
-
498
466
  ## Example Usage Scripts
499
467
 
500
468
  More examples can be found in the [examples](https://github.com/0xOstium/ostium_python_sdk/tree/main/examples) folder.
@@ -572,6 +540,19 @@ All notable changes to the Ostium Python SDK will be documented in this file.
572
540
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
573
541
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
574
542
 
543
+ ## [2.0.17] - 2025-06-03
544
+
545
+ - Return target_funding_rate from getPendingAccFundingFees()
546
+
547
+ ## [2.0.16] - 2025-05-31
548
+
549
+ - query optional different address in sdk.get_open_trade_metrics()
550
+
551
+ ## [2.0.15] - 2025-05-28
552
+
553
+ - Updated Readme with list of pairs
554
+ - Add additional fields to get_open_trade_metrics: bid, mid, ask, status
555
+
575
556
  ## [2.0.12] - 2025-05-28
576
557
 
577
558
  - return isDayTradingClosed in sdk.get_formatted_pairs_details()
@@ -22,7 +22,7 @@ if changelog_path.exists():
22
22
 
23
23
  setup(
24
24
  name="ostium-python-sdk",
25
- version="2.0.15",
25
+ version="2.0.17",
26
26
  packages=find_packages(),
27
27
  install_requires=read_requirements('requirements.txt'),
28
28
  extras_require={
@@ -79,7 +79,7 @@ test_cases = [
79
79
  def test_get_pending_acc_funding_fees(test_case):
80
80
  """Test getPendingAccFundingFees function with various test cases"""
81
81
  # Call the function with test case parameters
82
- acc_funding_long, acc_funding_short, latest_funding_rate = getPendingAccFundingFees(
82
+ acc_funding_long, acc_funding_short, latest_funding_rate, target_funding_rate = getPendingAccFundingFees(
83
83
  blockNumber=test_case['blockNumber'],
84
84
  lastUpdateBlock=test_case['lastUpdateBlock'],
85
85
  valueLong=test_case['valueLong'],
@@ -102,7 +102,7 @@ def test_get_pending_acc_funding_fees(test_case):
102
102
  print(f"acc_funding_long: {acc_funding_long}")
103
103
  print(f"acc_funding_short: {acc_funding_short}")
104
104
  print(f"latest_funding_rate: {latest_funding_rate}")
105
-
105
+ print(f"target_funding_rate: {target_funding_rate}")
106
106
  # Assertions
107
107
  assert acc_funding_long == pytest.approx(test_case['expected_acc_funding_long'], rel=Decimal('1e-12')), \
108
108
  f"acc_funding_long {acc_funding_long} != {test_case['expected_acc_funding_long']}"