Skip to main content

Python SDK for MDAS API.

Project description

MDAS Python SDK

A Python SDK for interacting with the MDAS API. This SDK provides an easy-to-use interface for accessing market data and account information.

Installation

From PyPI

pip install mdas-python-sdk

Setup and Configuration

Basic Setup

from mdas_python_sdk import MdasClient

# Create a client instance
client = MdasClient(
    base_url="https://mdas-api.viewtrade.tech/swagger/index.html",  # Replace with your API endpoint
    username="your-username",                       # Replace with your username
    password="your-password"                        # Replace with your password
)

The client will automatically authenticate and obtain a token upon initialization. You can now access various services through the client.

Available Services

  • client.quote: Access market data quotes, charts, and other financial information
  • client.account: Access user account information and settings

Sample Usage

Get Level 1 Quotes

# Get level 1 quote for a single symbol
tesla_quote = client.quote.get_level1_quote("TSLA")
print(tesla_quote)

# Get level 1 quote for multiple symbols
multi_quotes = client.quote.get_level1_quote(["AAPL", "MSFT", "GOOG"])
print(multi_quotes)

Using Response Models

You can convert API responses to model objects for easier access:

from mdas_python_sdk.models.quote import QuoteResponse

# Get quotes and convert to model
quotes_data = client.quote.get_level1_quote(["AAPL", "MSFT"])
quote_response = QuoteResponse.from_dict(quotes_data)

# Access data through model
for quote in quote_response.data:
    print(f"{quote.symbol}: ${quote.last_px} ({quote.change_percent}%)")

Get Historical Data

# Get historical minute chart data
historical_data = client.quote.get_historical_minute_chart("TSLA", "2023-05-12")

# Get historical day chart data
day_chart = client.quote.get_historical_day_chart("AAPL", year="2023")

Working with User Account Data

# Get user information
user_info = client.account.get_user_information_by_id("user123")

# Check if session is active
session_status = client.account.is_session_alive()

Handling Authentication

If your token expires during a long session, you can refresh it:

client.refresh_token()

Error Handling

The SDK handles authentication errors automatically by refreshing tokens when they expire. For other errors, you should implement appropriate try/except blocks:

try:
    quote = client.quote.get_level1_quote("INVALID_SYMBOL")
except Exception as e:
    print(f"An error occurred: {e}")

Available APIs

For a complete list of available API endpoints, see API.md.

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

mdas_python_sdk-0.1.2.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

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

mdas_python_sdk-0.1.2-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

Details for the file mdas_python_sdk-0.1.2.tar.gz.

File metadata

  • Download URL: mdas_python_sdk-0.1.2.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for mdas_python_sdk-0.1.2.tar.gz
Algorithm Hash digest
SHA256 5c104e7a46210ddbc376c94bccd8f9312d78d0a4be6fa6fe203939a90f8d7ef6
MD5 77ddce8fa1218ca5c5ebf11d675f4127
BLAKE2b-256 8a321eda440bd75c8477bcccf148a9db0e207517a23b9be7db9cffa57bf28567

See more details on using hashes here.

File details

Details for the file mdas_python_sdk-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for mdas_python_sdk-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d33bdd30a6bf597c9181cac7bf9502b1688e51ba81eab99d73eed74b2e3813dd
MD5 c9d07da1702d5c6300812ca92adc490a
BLAKE2b-256 380d2aa43c52cf9e24a38bbafaa15c331337159d3a97109367d1c4c52e1a8e1c

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