Intro
In [1]:
Copied!
from securities_exchange import (SecuritiesExchange,
Order,
OrderType,
MarketSide)
from securities_exchange import (SecuritiesExchange,
Order,
OrderType,
MarketSide)
Creating some orders¶
In [2]:
Copied!
orders = [Order("MSFT", OrderType.MARKET, MarketSide.BUY, 10),
Order("MSFT", OrderType.LIMIT, MarketSide.SELL, 10, 411.10),
Order("AMZN", OrderType.LIMIT, MarketSide.BUY, 1000, 160.),
Order("GS", OrderType.MARKET, MarketSide.BUY, 30),
Order("GS", OrderType.MARKET, MarketSide.BUY, 20),
Order("GS", OrderType.LIMIT, MarketSide.BUY, -10, -20),
Order("GS", OrderType.MARKET, MarketSide.BUY, 10, 7),
Order("GS", OrderType.LIMIT, MarketSide.SELL, 40, 387.20)]
orders = [Order("MSFT", OrderType.MARKET, MarketSide.BUY, 10),
Order("MSFT", OrderType.LIMIT, MarketSide.SELL, 10, 411.10),
Order("AMZN", OrderType.LIMIT, MarketSide.BUY, 1000, 160.),
Order("GS", OrderType.MARKET, MarketSide.BUY, 30),
Order("GS", OrderType.MARKET, MarketSide.BUY, 20),
Order("GS", OrderType.LIMIT, MarketSide.BUY, -10, -20),
Order("GS", OrderType.MARKET, MarketSide.BUY, 10, 7),
Order("GS", OrderType.LIMIT, MarketSide.SELL, 40, 387.20)]
Market orders will ignore 'price'. Price attribute set to None
Create a the Security Exchange object¶
SecuritiesExchange has 2 arguments:
- allow_market_queue: that allows for unfilled or partially filled Market orders to be queued waiting for a matching Limit order to come, default is False so unfilled or partially unfilled Market orders will remain as such while with True they could be filled eventually and they will have priority on the limit orders.
In [3]:
Copied!
secEx = SecuritiesExchange()
secEx = SecuritiesExchange()
Feed the orders to the exchange¶
In [4]:
Copied!
for order in orders:
secEx.submit_order(order)
for order in orders:
secEx.submit_order(order)
Order 1707858511901235GSLIMITBUY-10@-20.0 has been REJECTED. - LIMIT orders require a non-null positive PRICE. - Orders require a non-null positive SIZE.