Skip to main content

Add your description here

Project description

rs_trader

from rs_trader import Exchange
from rs_trader.interfaces import DatabaseInterface
from rs_trader.storage import JsonDatabase
from rs_trader.structs import Order, OrderStatus, OrderType

# Initialize the database and exchange
database = JsonDatabase()
exchange = Exchange(database=database)

# Place a sell order
exchange.place_order(
    Order(user_id=2, item_id=123, order_type=OrderType.SELL, quantity=1000, price=1)
)
exchange.place_order(
    Order(user_id=2, item_id=123, order_type=OrderType.SELL, quantity=100, price=3)
)

# Place a buy order
buy_order = Order(user_id=1, item_id=123, order_type=OrderType.BUY, quantity=150, price=5)
exchange.place_order(buy_order)

orders = exchange.get_orders(item_id=123)
_ = [print(o, database.get_order_remaining_quantity(o.order_id)) for o in orders]

order_parts = exchange.get_order_parts(order_id=buy_order.order_id)
_ = [print(o)for o in order_parts]

median_price = exchange.get_median_price(item_id=123)
print(median_price)

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

rs_trader-0.2.0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

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

rs_trader-0.2.0-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file rs_trader-0.2.0.tar.gz.

File metadata

  • Download URL: rs_trader-0.2.0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for rs_trader-0.2.0.tar.gz
Algorithm Hash digest
SHA256 06799366f0cb977ef56bcb983fd4ac3bcc964dbc81fcf1318f224beb55c79faa
MD5 97460dced320564bce7714f744d0c1f2
BLAKE2b-256 5299e118c699289eac8b7f25e679377b2828def558dfafb3052e8110d8b1534f

See more details on using hashes here.

Provenance

The following attestation bundles were made for rs_trader-0.2.0.tar.gz:

Publisher: python-package.yml on extreme4all/rs_trader

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rs_trader-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: rs_trader-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for rs_trader-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6cb17c9d8cc50e76eb8fd761cef7f8cda4356cc31582b3fe7aac0942271af95f
MD5 0470c2bab6a545ca404845fe9ffe09bc
BLAKE2b-256 eb5faee381509bb1f7c6a685f94de6e5c73edf9c52cc88286c582e6e503f74fb

See more details on using hashes here.

Provenance

The following attestation bundles were made for rs_trader-0.2.0-py3-none-any.whl:

Publisher: python-package.yml on extreme4all/rs_trader

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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