ostium-python-sdk 2.0.18__tar.gz → 2.0.19__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.18 → ostium_python_sdk-2.0.19}/PKG-INFO +1 -1
- ostium_python_sdk-2.0.19/ostium_python_sdk/price.py +90 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/ostium_python_sdk.egg-info/PKG-INFO +1 -1
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/setup.py +1 -1
- ostium_python_sdk-2.0.18/ostium_python_sdk/price.py +0 -46
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/MANIFEST.in +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/README.md +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/ostium_python_sdk/__init__.py +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/ostium_python_sdk/abi/__init__.py +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/ostium_python_sdk/abi/faucet_testnet_abi.py +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/ostium_python_sdk/abi/pairs_info_abi.py +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/ostium_python_sdk/abi/pairs_storage_abi.py +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/ostium_python_sdk/abi/trading_abi.py +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/ostium_python_sdk/abi/trading_storage_abi.py +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/ostium_python_sdk/abi/usdc_abi.py +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/ostium_python_sdk/abi/vault_abi.py +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/ostium_python_sdk/balance.py +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/ostium_python_sdk/config.py +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/ostium_python_sdk/constants.py +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/ostium_python_sdk/exceptions.py +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/ostium_python_sdk/faucet.py +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/ostium_python_sdk/formulae.py +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/ostium_python_sdk/formulae_wrapper.py +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/ostium_python_sdk/ostium.py +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/ostium_python_sdk/scscript/__init__.py +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/ostium_python_sdk/scscript/funding.py +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/ostium_python_sdk/scscript/pairinfos.py +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/ostium_python_sdk/sdk.py +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/ostium_python_sdk/subgraph.py +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/ostium_python_sdk/utils.py +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/ostium_python_sdk.egg-info/SOURCES.txt +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/ostium_python_sdk.egg-info/dependency_links.txt +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/ostium_python_sdk.egg-info/requires.txt +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/ostium_python_sdk.egg-info/top_level.txt +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/pyproject.toml +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/requirements-dev.txt +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/requirements.txt +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/setup.cfg +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/tests/__init__.py +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/tests/conftest.py +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/tests/disabled_test_funding.py +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/tests/disabled_test_slippage.py +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/tests/test_current_total_profit_p.py +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/tests/test_current_total_profit_raw.py +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/tests/test_current_trade_profit_p.py +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/tests/test_current_trade_profit_raw.py +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/tests/test_get_opening_fee.py +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/tests/test_get_pending_acc_funding_fees.py +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/tests/test_get_price_impact.py +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/tests/test_get_trade_funding_fee.py +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/tests/test_get_trade_rollover_fee.py +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/tests/test_get_trade_value.py +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/tests/test_max_leverage.py +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/tests/test_overnight_max_leverage.py +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/tests/test_remove_collateral_from_leverage.py +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/tests/test_remove_collateral_with_collateral.py +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/tests/test_target_funding_rate.py +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/tests/test_top_up_with_collateral.py +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/tests/test_top_up_with_leverage.py +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/tests/test_trade_get_sl_price.py +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/tests/test_trade_get_tp_price.py +0 -0
- {ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/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.
|
|
3
|
+
Version: 2.0.19
|
|
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
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import aiohttp
|
|
2
|
+
import ssl
|
|
3
|
+
from typing import Tuple
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Price:
|
|
7
|
+
def __init__(self, verbose=False):
|
|
8
|
+
self.verbose = verbose
|
|
9
|
+
self.base_url = "https://metadata-backend.ostium.io"
|
|
10
|
+
|
|
11
|
+
def log(self, message):
|
|
12
|
+
if self.verbose:
|
|
13
|
+
print(message)
|
|
14
|
+
|
|
15
|
+
async def get_latest_prices(self):
|
|
16
|
+
"""
|
|
17
|
+
Fetches the latest prices from the Ostium metadata-backend service.
|
|
18
|
+
Returns a dictionary of price data.
|
|
19
|
+
"""
|
|
20
|
+
# Create SSL context that doesn't verify certificates
|
|
21
|
+
ssl_context = ssl.create_default_context()
|
|
22
|
+
ssl_context.check_hostname = False
|
|
23
|
+
ssl_context.verify_mode = ssl.CERT_NONE
|
|
24
|
+
|
|
25
|
+
# Create connector with SSL context and additional options for better compatibility
|
|
26
|
+
connector = aiohttp.TCPConnector(
|
|
27
|
+
ssl=ssl_context,
|
|
28
|
+
use_dns_cache=True,
|
|
29
|
+
ttl_dns_cache=300,
|
|
30
|
+
limit=100,
|
|
31
|
+
limit_per_host=30
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
timeout = aiohttp.ClientTimeout(total=30)
|
|
35
|
+
|
|
36
|
+
try:
|
|
37
|
+
async with aiohttp.ClientSession(connector=connector, timeout=timeout) as session:
|
|
38
|
+
async with session.get(f"{self.base_url}/PricePublish/latest-prices") as response:
|
|
39
|
+
if response.status == 200:
|
|
40
|
+
return await response.json()
|
|
41
|
+
else:
|
|
42
|
+
raise Exception(
|
|
43
|
+
f"Failed to fetch prices: {response.status}")
|
|
44
|
+
except aiohttp.ClientConnectorCertificateError as e:
|
|
45
|
+
# If SSL certificate verification fails, try with a more permissive approach
|
|
46
|
+
self.log(f"SSL certificate verification failed, trying alternative approach: {e}")
|
|
47
|
+
|
|
48
|
+
# Create a completely unverified SSL context
|
|
49
|
+
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
|
|
50
|
+
ssl_context.check_hostname = False
|
|
51
|
+
ssl_context.verify_mode = ssl.CERT_NONE
|
|
52
|
+
|
|
53
|
+
connector = aiohttp.TCPConnector(
|
|
54
|
+
ssl=ssl_context,
|
|
55
|
+
use_dns_cache=True,
|
|
56
|
+
ttl_dns_cache=300,
|
|
57
|
+
limit=100,
|
|
58
|
+
limit_per_host=30
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
async with aiohttp.ClientSession(connector=connector, timeout=timeout) as session:
|
|
62
|
+
async with session.get(f"{self.base_url}/PricePublish/latest-prices") as response:
|
|
63
|
+
if response.status == 200:
|
|
64
|
+
return await response.json()
|
|
65
|
+
else:
|
|
66
|
+
raise Exception(
|
|
67
|
+
f"Failed to fetch prices: {response.status}")
|
|
68
|
+
except Exception as e:
|
|
69
|
+
raise Exception(f"Error fetching prices: {str(e)}")
|
|
70
|
+
|
|
71
|
+
# Returns a json, e.g: {'feed_id': '0x00039d9e45394f473ab1f050a1b963e6b05351e52d71e507509ada0c95ed75b8', 'bid': 107646.01338169997, 'mid': 107646.03680130735, 'ask': 107646.06022091472, 'isMarketOpen': True, 'isDayTradingClosed': False, 'secondsToToggleIsDayTradingClosed': -1, 'from': 'BTC', 'to': 'USD', 'timestampSeconds': 1748460056}
|
|
72
|
+
async def get_latest_price_json(self, from_asset: str, to_asset: str):
|
|
73
|
+
prices = await self.get_latest_prices()
|
|
74
|
+
for price_data in prices:
|
|
75
|
+
if (price_data.get('from') == from_asset and
|
|
76
|
+
price_data.get('to') == to_asset):
|
|
77
|
+
self.log(f"get_latest_price_json: {price_data}")
|
|
78
|
+
return price_data
|
|
79
|
+
raise ValueError(f"No price found for pair: {from_asset}/{to_asset}")
|
|
80
|
+
|
|
81
|
+
# Returns a mid price and isMarketOpen tuple, e.g: (97243.36503172085, True)
|
|
82
|
+
async def get_price(self, from_currency, to_currency) -> Tuple[float, bool, bool]:
|
|
83
|
+
self.log(f"Getting price for {from_currency}/{to_currency}")
|
|
84
|
+
prices = await self.get_latest_prices()
|
|
85
|
+
for price_data in prices:
|
|
86
|
+
if (price_data.get('from') == from_currency and
|
|
87
|
+
price_data.get('to') == to_currency):
|
|
88
|
+
return float(price_data.get('mid', 0)), price_data.get('isMarketOpen', False), price_data.get('isDayTradingClosed', False)
|
|
89
|
+
raise ValueError(
|
|
90
|
+
f"No price found for pair: {from_currency}/{to_currency}")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ostium-python-sdk
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.19
|
|
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
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import aiohttp
|
|
2
|
-
from typing import Tuple
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class Price:
|
|
6
|
-
def __init__(self, verbose=False):
|
|
7
|
-
self.verbose = verbose
|
|
8
|
-
self.base_url = "https://metadata-backend.ostium.io"
|
|
9
|
-
|
|
10
|
-
def log(self, message):
|
|
11
|
-
if self.verbose:
|
|
12
|
-
print(message)
|
|
13
|
-
|
|
14
|
-
async def get_latest_prices(self):
|
|
15
|
-
"""
|
|
16
|
-
Fetches the latest prices from the Ostium metadata-backend service.
|
|
17
|
-
Returns a dictionary of price data.
|
|
18
|
-
"""
|
|
19
|
-
async with aiohttp.ClientSession() as session:
|
|
20
|
-
async with session.get(f"{self.base_url}/PricePublish/latest-prices") as response:
|
|
21
|
-
if response.status == 200:
|
|
22
|
-
return await response.json()
|
|
23
|
-
else:
|
|
24
|
-
raise Exception(
|
|
25
|
-
f"Failed to fetch prices: {response.status}")
|
|
26
|
-
|
|
27
|
-
# Returns a json, e.g: {'feed_id': '0x00039d9e45394f473ab1f050a1b963e6b05351e52d71e507509ada0c95ed75b8', 'bid': 107646.01338169997, 'mid': 107646.03680130735, 'ask': 107646.06022091472, 'isMarketOpen': True, 'isDayTradingClosed': False, 'secondsToToggleIsDayTradingClosed': -1, 'from': 'BTC', 'to': 'USD', 'timestampSeconds': 1748460056}
|
|
28
|
-
async def get_latest_price_json(self, from_asset: str, to_asset: str):
|
|
29
|
-
prices = await self.get_latest_prices()
|
|
30
|
-
for price_data in prices:
|
|
31
|
-
if (price_data.get('from') == from_asset and
|
|
32
|
-
price_data.get('to') == to_asset):
|
|
33
|
-
self.log(f"get_latest_price_json: {price_data}")
|
|
34
|
-
return price_data
|
|
35
|
-
raise ValueError(f"No price found for pair: {from_asset}/{to_asset}")
|
|
36
|
-
|
|
37
|
-
# Returns a mid price and isMarketOpen tuple, e.g: (97243.36503172085, True)
|
|
38
|
-
async def get_price(self, from_currency, to_currency) -> Tuple[float, bool, bool]:
|
|
39
|
-
self.log(f"Getting price for {from_currency}/{to_currency}")
|
|
40
|
-
prices = await self.get_latest_prices()
|
|
41
|
-
for price_data in prices:
|
|
42
|
-
if (price_data.get('from') == from_currency and
|
|
43
|
-
price_data.get('to') == to_currency):
|
|
44
|
-
return float(price_data.get('mid', 0)), price_data.get('isMarketOpen', False), price_data.get('isDayTradingClosed', False)
|
|
45
|
-
raise ValueError(
|
|
46
|
-
f"No price found for pair: {from_currency}/{to_currency}")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/ostium_python_sdk/abi/faucet_testnet_abi.py
RENAMED
|
File without changes
|
{ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/ostium_python_sdk/abi/pairs_info_abi.py
RENAMED
|
File without changes
|
{ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/ostium_python_sdk/abi/pairs_storage_abi.py
RENAMED
|
File without changes
|
|
File without changes
|
{ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/ostium_python_sdk/abi/trading_storage_abi.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/ostium_python_sdk/scscript/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/ostium_python_sdk/scscript/pairinfos.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/ostium_python_sdk.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/ostium_python_sdk.egg-info/requires.txt
RENAMED
|
File without changes
|
{ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/ostium_python_sdk.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/tests/test_current_total_profit_raw.py
RENAMED
|
File without changes
|
|
File without changes
|
{ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/tests/test_current_trade_profit_raw.py
RENAMED
|
File without changes
|
|
File without changes
|
{ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/tests/test_get_pending_acc_funding_fees.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ostium_python_sdk-2.0.18 → ostium_python_sdk-2.0.19}/tests/test_remove_collateral_from_leverage.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|