April 2019
Intermediate to advanced
426 pages
11h 13m
English
In the same way that we use for fetching prices, we can reuse the broker variable to send a market order to our broker.
Now suppose that we are interested in buying one unit of the same EUR/USD currency pair; the following code performs this action:
def on_order_event(symbol, quantity, is_buy, transaction_id, status):
print(
dt.datetime.now(), '[ORDER]',
'transaction_id:', transaction_id,
'status:', status,
'symbol:', symbol,
'quantity:', quantity,
'is_buy:', is_buy,
)
broker.on_order_event = on_order_event
broker.send_market_order(SYMBOL, 1, True)
The on_order_event() function is defined as the listener for incoming order updates from our broker and is assigned to the broker.on_order_event event handler. For ...
Read now
Unlock full access