Live Trading¶
Classes:
|
The Trade object contains functions used for Trade tab |
Functions:
|
Calculates Bollinger Bands (BOL) |
|
Forecasting with Exponential Weighted Moving Average |
|
Calculates Moving Average Convergence Divergence (MACD) |
|
Calculates Relative Strength Index (RSI) |
|
Calculates Simple Moving Average (SMA) |
- class main.components.trade.Trade(use_mt5=False)¶
The Trade object contains functions used for Trade tab
Methods:
get_candlestick_chart(symbol, n_points, ...)Get figure for plot
get_rates_data(symbol, timeframe, n_points)Compute rate data (time, open, high, low, close, tick volume, spread)
Get symbol names
- static get_candlestick_chart(symbol: str, n_points: int, rates_df: DataFrame, indicators_ind: List[str], forecast_methods: List[str]) Dict[str, Any]¶
Get figure for plot
Adds plotly.graph_objects charts for candlestick plot, visualizing trade movement
- Parameters:
symbol – symbol to plot for
n_points – number of points on candlestick
rates_df – rate data (time, open, high, low, close, tick volume, spread)
indicators_ind – list of indicators to plot
forecast_methods – list of forecasting methods
- Returns:
graphical result of trade
- get_rates_data(symbol: str, timeframe: str, n_points: int) DataFrame¶
Compute rate data (time, open, high, low, close, tick volume, spread)
- Parameters:
symbol – symbol to plot for
timeframe – frequency of candlestick
n_points – number of points on candlestick
- Returns:
result of rate data
- get_symbol_names() List[str]¶
Get symbol names
- main.components.trade.bol(data_close: Series, data_low: Series, data_high: Series, periods: int = 20, num_std: int = 2) Series¶
Calculates Bollinger Bands (BOL)
BOL measures volatility of market and overbought and oversold conditions and made up of SMA and upper and lower band. The closer the price is to the upper band, the closer to overbought conditions, vice versa. If bands are very close (low volatility), this can be indication of potential future volatility, vice versa
- Parameters:
data_close – input pandas Series for closing price
data_low – input pandas Series for low price
data_high – input pandas Series for high price
periods – number of periods to smooth, defaults to 20
num_std – number of standard deviation, defaults to 2
- main.components.trade.forecast_ewm(data: Series, alpha: float = 0.8) float¶
Forecasting with Exponential Weighted Moving Average
- Parameters:
data – input pandas Series
alpha – weight given to preceding EMA value
- main.components.trade.macd(data: Series, fast: int = 12, slow: int = 26, signal: int = 9)¶
Calculates Moving Average Convergence Divergence (MACD)
MACD is a momentum indicator that signal shifts in market momentum and signal potential breakouts. MACD measures the relationship between fast and slow EMA (typically 12-day and 26-day respectively). Signal/Trigger measures EMA of period shorter than shortest period used in calculating MACD (typically 9-day). Difference between MACD and Trigger represent current selling pressures, positive represent bullish trend whereas negative indicate bearish one
- Parameters:
data – input pandas Series
fast – number of period to calculate fast EMA, defaults to 12
slow – number of periods to calculate slow EMA, defaults to 26
signal – number of periods to calculate signal, defaults to 9
- Returns:
MACD, MACD SIGNAL, MACD - Signal
- Return type:
(pd.Series, pd.Series, pd.Series)
- main.components.trade.rsi(data: Series, periods: int = 14, ema: bool = True) Series¶
Calculates Relative Strength Index (RSI)
RSI is a momentum indicator that measures the magnitude of recent price changes to evaluate overbought or oversold conditions in the price of an asset. RSI measures price change in relation to recent price highs and lows
- Parameters:
data – input pandas Series
periods – number of periods to calculate RSI, defaults to 14
ema – indicator to use exponential moving average, defaults to True
- main.components.trade.sma(data: Series, window: int) Series¶
Calculates Simple Moving Average (SMA)
SMA is a lagging indicator that smooths out price action and highlights direction of trend
- Parameters:
data – input pandas Series
window – number of historical periods to calculate SMA
Classes:
The TradeSocket object contains functions used for Trade tab |
- class main.components.trade_socket.TradeSocket¶
The TradeSocket object contains functions used for Trade tab
Methods:
get_candlestick_chart(symbol, n_points, ...)Get figure for plot
get_historical_data(ticker, granularity[, ...])Get historical data of stock symbol
get_rates_data(symbol, granularity, n_points)Compute rate data (time, open, high, low, close)
Get symbol names
on_message(ws, message, granularity)Websocket callback object, called when received data
on_open(ws, symbol)Websocket callback object, called when opening websocket
run_socket(ticker, granularity)Connect to web socket
- static get_candlestick_chart(symbol: str, n_points: int, rates_df: DataFrame, indicators_ind: List[str], forecast_methods: List[str]) Dict[str, Any]¶
Get figure for plot
Adds plotly.graph_objects charts for candlestick plot, visualizing trade movement
- Parameters:
symbol – symbol to plot for
n_points – number of points on candlestick
rates_df – rate data (time, open, high, low, close, tick volume, spread)
indicators_ind – list of indicators to plot
forecast_methods – list of forecasting methods
- Returns:
graphical result of trade
- get_historical_data(ticker: str, granularity: str, start: str | None = None, end: str | None = None) DataFrame¶
Get historical data of stock symbol
- Parameters:
ticker – symbol to display
granularity – granularity of candlestick chart
start – start datetime of historical data
end – end datetime of historical data
- get_rates_data(symbol: str, granularity: str, n_points: int) DataFrame¶
Compute rate data (time, open, high, low, close)
- Parameters:
symbol – symbol to display
granularity – granularity of candlestick chart
n_points – number of points on candlestick
- static get_symbol_names() List[str]¶
Get symbol names
- on_message(ws, message: str, granularity: str)¶
Websocket callback object, called when received data
- Parameters:
ws (WebSocketApp) – websocket class object
message – utf-8 data received from server
granularity – granularity of candlestick chart
- Returns:
(pd.DataFrame)
- on_open(ws, symbol: str)¶
Websocket callback object, called when opening websocket
- Parameters:
ws (WebSocketApp) – websocket object
symbol – symbol to display
- run_socket(ticker: str, granularity: str)¶
Connect to web socket
- Parameters:
ticker – symbol to display
granularity – granularity of candlestick chart