Skip to content

Commit

Permalink
documentation update
Browse files Browse the repository at this point in the history
  • Loading branch information
extreme4all committed Nov 22, 2024
1 parent baeb965 commit 20ce422
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,4 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
test.py
24 changes: 20 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# rs_trader

```py
from uuid import UUID

from rs_trader import Exchange
from rs_trader.interfaces import DatabaseInterface
from rs_trader.storage import JsonDatabase
Expand All @@ -11,14 +13,28 @@ database = JsonDatabase()
exchange = Exchange(database=database)

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

# Place a sell order
sell_order = Order(user_id=2, item_id=1001, order_type=OrderType.SELL, quantity=5, price=140)
sell_order = Order(
user_id=2, item_id=1001, order_type=OrderType.SELL, quantity=5, price=140
)
exchange.place_order(sell_order)

#TODO: this will probably move to exchange.get_orders()
# TODO: this will probably move to exchange.get_orders()
orders = database.get_orders()
print(orders)
[print(o) for o in orders]

first_order = orders[0].model_dump(mode="json")
first_order_id = first_order.pop("order_id")

print(
first_order,
"remaining quantity:",
database.get_order_remaining_quantity(UUID(first_order_id)),
)

```

0 comments on commit 20ce422

Please sign in to comment.