Skip to main content

Primary API Models

Models for Primary API (REST / WS) messages

API Documentation: https://apihub.primary.com.ar/

Use with

Installation

pip install primary-api-models

Usage

  • Segments
import pyRofex
from primary_api_models import SegmentsResponse

pyRofex.initialize(...)

# Get all segments
response = pyRofex.get_segments()
data = SegmentsResponse.model_validate(response)
print(data.segments)
  • All Instruments
import pyRofex
from primary_api_models import AllInstrumentsResponse

pyRofex.initialize(...)

# Get available instrument list
response = pyRofex.get_all_instruments()
data = AllInstrumentsResponse.model_validate(response)
print(data.instruments)
  • Instruments by Segments/Cficode
import pyRofex
from primary_api_models import InstrumentsByResponse

pyRofex.initialize(...)

# Get instrument list by given cfi code or segment:
response = pyRofex.get_instruments('by_cfi', ...)
response = pyRofex.get_instruments('by_segments', ...)
data = InstrumentsByResponse.model_validate(response)
print(data.instruments)
  • Detailed Instruments List
import pyRofex
from primary_api_models import DetailedInstrumentsResponse

pyRofex.initialize(...)

# Get detailed instrument list
response = pyRofex.get_detailed_instruments()
data = DetailedInstrumentsResponse.model_validate(response)
print(data.instruments)
  • Instrument Details
import pyRofex
from primary_api_models import InstrumentDetailsResponse

pyRofex.initialize(...)

# Get instrument details
response = pyRofex.get_instrument_details(ticker="MERV - XMEV - AAPL - 24hs")
data = InstrumentDetailsResponse.model_validate(response)
print(data.instrument)
  • Order Status
import pyRofex
from primary_api_models import OrderStatusResponse

pyRofex.initialize(...)

# Get all order reports for the configured account
response = pyRofex.get_all_orders_status()
data = OrderStatusResponse.model_validate(response)
print(data.orders)

# Get order status
response = pyRofex.get_order_status(...)
data = OrderStatusResponse.model_validate(response)
print(data.order)
  • Market Data
import pyRofex
from primary_api_models import StatusResponse
from primary_api_models import MarketDataResponse, MarketData

pyRofex.initialize(...)

# Makes a request to the Rest API and get bids, offers and last price
# Use the MarketDataEntry enum to specify the data
entries = [pyRofex.MarketDataEntry.BIDS,
           pyRofex.MarketDataEntry.OFFERS,
           pyRofex.MarketDataEntry.LAST]

response = pyRofex.get_market_data(ticker="MERV - XMEV - AAPL - 24hs", entries=entries)
data = MarketDataResponse.model_validate(response)

if data.status == StatusResponse.OK:
    md = data.market_data
    bids = md.BI
    asks = md.OF
    last_trade = md.LA
    print(last_trade)
  • Send Order
import pyRofex
from primary_api_models import StatusResponse
from primary_api_models import Order, OrderConfirmationResponse

pyRofex.initialize(...)

new_order = Order(
    ticker="MERV - XMEV - AAPL - 24hs",
    side=pyRofex.Side.BUY,
    price=1000,
    size=5,
    order_type=pyRofex.OrderType.LIMIT,
)

response = pyRofex.send_order(**new_order.model_dump())
data = OrderConfirmationResponse.model_validate(response)
if data.status == StatusResponse.OK:
    print(data.client_id)
  • Account Report
import pyRofex
from primary_api_models import AccountReportResponse

pyRofex.initialize(...)

# Get account report
response = pyRofex.get_account_report(...)
data = AccountReportResponse.model_validate(response)
print(data.account_data)
  • Account Positions
import pyRofex
from primary_api_models import PositionsResponse

pyRofex.initialize(...)

# Get all positions for an account
response = pyRofex.get_account_report(...)
data = PositionsResponse.model_validate(response)
print(data.positions)
  • Detailed Positions
import pyRofex
from primary_api_models import DetailedPositionsResponse

pyRofex.initialize(...)

# Get detailed positions for an account
response = pyRofex.get_detailed_position(...)
data = DetailedPositionsResponse.model_validate(response)
print(data.detailed_position)

Model list

[
    // Enums
    "StatusResponse",
    "MessageType",
    "MarketId",
    "Side",
    "OrderType",
    "OrderStatus",
    "TimeInForce",
    "Currency",
    "CurrencyIndex",
    "SettlementIndex",
    "MarketDataEntry",
    "CFICode",
    "MarketSegment",
    "ContractType",
    // Models
    "AccountReportResponse",
    "AccountData",
    "CommonResponse",
    "PriceSize",
    "PriceSizeDate",
    "InstrumentId",
    "Instrument",
    "DetailedInstrumentsResponse",
    "DetailedPositionsResponse",
    "DetailedPositionData",
    "DetailedPosition",
    "EnhancedOrderReport",
    "InstrumentDetailsResponse",
    "InstrumentDetails",
    "AllInstrumentsResponse",
    "InstrumentsByResponse",
    "MarketDataResponse",
    "MarketDataMessage",
    "MarketData",
    "Order",
    "OrderReportMessage",
    "OrderReport",
    "OrderStatusResponse",
    "OrderConfirmationResponse",
    "PositionsResponse",
    "Position",
    "SegmentsResponse"
]

Metadata

Release files for primary-api-models 0.4.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for primary-api-models 0.4.8
File Size Uploaded Provenance Actions
primary_api_models-0.4.8.tar.gz 13.0 kB Without provenance Details for primary_api_models-0.4.8.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for primary-api-models 0.4.8
File Interpreter ABI Platform Actions
primary_api_models-0.4.8-py3-none-any.whl Python 3 none any Details for primary_api_models-0.4.8-py3-none-any.whl

Total release size: 25.3 kB

Release files / primary_api_models-0.4.8.tar.gz

Download URL primary_api_models-0.4.8.tar.gz
Size 13.0 kB
Tags Source
SHA-256 checksum
How to use checksums
d98c727a99f77aa726101cbca1a99bf1dd6acf46b2d4e5a3be6f820abfcf9eb3
BLAKE2b-256 checksum
How to use checksums
c380915dee38b7964194c933bb471162d7c248c3508473e4fa4eea3e9e6f1ae3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.13

Release files / primary_api_models-0.4.8-py3-none-any.whl

Download URL primary_api_models-0.4.8-py3-none-any.whl
Size 12.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
50aa32351d95892710065d215b43483db7b01aef9fbc7b98935d3c589fe10155
BLAKE2b-256 checksum
How to use checksums
690fd6dc5d149132186d6ef451dfecbff5e430af1e998f5a38e6f21f5c81c422
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.13

Security for primary-api-models 0.4.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.4.8 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page