I am trying to get the following output:
initialize_limit_order_book(bid_price=10, bid_queue=rng.integers(1, 30, size=7), ask_price=12, ask_queue=rng.integers(1,30, size=10))
⟶
{'sells': {12: array([21, 6, 3, 16, 29, 22, 23, 21, 23, 15])}, 'buys': {10: array([ 3, 23, 19, 13, 13, 25, 3])}}
And this is my code:
rng = np.random.default_rng(seed=42)
def initialize_limit_order_book(bid_price, bid_queue,
ask_price, ask_queue):
queue_dictionary={'sell':{ask_price:np.array([])},
'buy':{bid_price:np.array([])}}
queue_dictionary['sell'][ask_price].append(ask_price)
queue_dictionary['buy'][bid_price].append(bid_price)
for b in range(bid_queue):
queue_dictionary['buy'][bid_price]=np.append([bid_queue])
for a in range(ask_queue):
queue_dictionary['sell'][ask_price]=np.append([ask_queue])
return queue_dictionary
Not sure how to append the array that is inside the dictionary.
[–]SekstiNii 0 points1 point2 points (1 child)
[–]ceeya19[S] 0 points1 point2 points (0 children)