Trading application with live data feed
As always, we start by doing some imports:
import json import threading import queue from datetime import datetime from websocket import create_connection
Next, we create a class that contains the strategy metadata (see the Trading logic component section):
class tradingSystemMetadata: def __init__(self): self.initial_capital = 10000 self.leverage = 30 self.market_position = 0 self.equity = 0 self.last_price = 0 self.equity_timeseries = []
Now, we prepare three (!) tick data queues:
tick_feed_0 = queue.Queue() tick_feed_1 = queue.Queue() tick_feed_2 = queue.Queue()
Why three? This is one of the solutions to the thread...