Skip to main content

A python based SDK developed for interacting with Ostium, a leveraged trading application for trading currencies, commodities, indices, crypto and more.

Project description

Ostium Python SDK

A python based SDK developed for interacting with Ostium v1 Trading Platform (https://ostium.app/)

Ostium is a decentralized perpetuals exchange on Arbitrum (Ethereum L2) with a focus on providing a seamless experience for traders for trading currencies, commodities, indices, crypto and more.

This SDK is designed to be used by developers who want to build applications on top of Ostium and automate their trading strategies.

Pip Install

The SDK can be installed via pip:

pip install ostium-python-sdk

Requirements

Developed using:

  python=3.8

Usage Example

Opening a Trade

from ostium_python_sdk import OstiumSDK
from dotenv import load_dotenv

# Load environment variables if using .env file
load_dotenv()

# Initialize SDK (using environment variables)
sdk = OstiumSDK(network="arbitrum")

# Or initialize with explicit private key
# sdk = OstiumSDK(
#     network="arbitrum",
#     private_key="your_private_key_here",
#     rpc_url="https://arb1.arbitrum.io/rpc"
# )

# Define trade parameters
trade_params = {
    'collateral': 100,        # USDC amount
    'leverage': 10,           # Leverage multiplier
    'asset_type': 0,         # 0 for BTC
    'direction': True,       # True for Long, False for Short
    'order_type': 'MARKET'   # 'MARKET', 'LIMIT', or 'STOP'
}

try:
    # Get latest price for BTC
    latest_price = sdk.ostium.get_latest_price(trade_params['asset_type'])
    
    # Execute trade at current market price
    receipt = sdk.ostium.perform_trade(trade_params, at_price=latest_price)
    print(f"Trade successful! Transaction hash: {receipt['transactionHash'].hex()}")
except Exception as e:
    print(f"Trade failed: {str(e)}")

## Example Usage Script


### Read Block Number

To run the example:

```bash
python examples/example-read-block-number.py

See example-read-block-number.py for an example of how to use the SDK.

Read Positions

To run the example:

python examples/example-read-positions.py

See example-read-positions.py for an example of how to use the SDK.

Get Feed Prices

To open a trade you need the latest feed price.

See this example script on how to get the latest feed prices.

python examples/example-get-prices.py

See example-get-prices.py for an example of how to use the SDK.

Get Balance of an Address

See this example script on how to get the latest feed prices.

python examples/example-get-balance.py

See example-get-balance.py for an example of how to use the SDK.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ostium_python_sdk-0.1.10.tar.gz (24.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ostium_python_sdk-0.1.10-py3-none-any.whl (26.2 kB view details)

Uploaded Python 3

File details

Details for the file ostium_python_sdk-0.1.10.tar.gz.

File metadata

  • Download URL: ostium_python_sdk-0.1.10.tar.gz
  • Upload date:
  • Size: 24.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.16

File hashes

Hashes for ostium_python_sdk-0.1.10.tar.gz
Algorithm Hash digest
SHA256 e826ae7c47aafd38130919d1f8086b9ac0527c59c27cd0d53d1785598cadc5e0
MD5 e421f91e7ad1d21bec50a2ed115637ec
BLAKE2b-256 79fe5e316c9c27ac3e9b4ffd6b1aef186d606f2566a511bc80e4d4401f33028c

See more details on using hashes here.

File details

Details for the file ostium_python_sdk-0.1.10-py3-none-any.whl.

File metadata

File hashes

Hashes for ostium_python_sdk-0.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 161e03ab15e5ff020b43de9a2255cdd05a473ac5d993b8528b4328ba4295b723
MD5 02837e0304ad2713cc595fd17e03510f
BLAKE2b-256 0725236de9665704ada1308bc38f9c70480adaccc0cded4b422c04a8a0a8d3a3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page