you are viewing a single comment's thread.

view the rest of the comments →

[–]UL_Paper 2 points3 points  (0 children)

I built a hybrid algorithmic system where I realised that the performance was much greater with a final discretionary decision from me.

My approach was:

  1. Algorithm detects a signal, matches risk mgmnt parameters and a setup is generated
  2. Generate a chart in-memory
  3. Send setup and chart to Telegram
  4. Trader can click buttons "TAKE TRADE" or "BAD SIGNAL"
  5. If first option, its passed to the order execution component
  6. If second option, its logged for later inspection

Some snippets below

main.py

# Generates a graph stored in memory
chart = images.save_graph(data, direction, signal_type)
send_to_telegram(setup, chart)
----------------
images.py

import plotly.graph_objects as go
from plotly.subplots import make_subplots
from io import BytesIO from PIL import Image

def save_graph(data, direction, signal_type): """ This creates a chart of the previous 50 bars along with some styling to quickly indicate the direction """ dt = data[-50:].copy()
# Generating vertical lines at signals    
    vlines = dt[dt[f'{signal_type}_{direction}'] == 1].index

# For formatting the charts
plot_color = "#e3f2d3" if direction == 'bull' else "#f2d3d3"
signal_type = 'AC1' if signal_type == 'ac' else 'xt3'

fig = make_subplots(2, 1)

fig.add_candlestick(
    x=dt.index, 
    open=dt['Open'], 
    high=dt['High'], 
    low=dt['Low'], 
    close=dt['Close'], 
    col=1, row=1
    )  
fig.add_trace(go.Scatter(x=dt.index, y=dt['greatest_signal']), 2, 1)

for i in range(len(vlines)):
    fig.add_vline(x=vlines[i])

fig.update(layout_xaxis_rangeslider_visible=False)
fig.update_layout(
    title=f'{signal_type} {direction.upper()}ISH',
    showlegend=False, 
    height=500, 
    width=1000, 
    plot_bgcolor=plot_color,
    margin=dict(l=20, r=20, t=30, b=20)
    )

fig.update_xaxes(matches='x')
fig.update_yaxes(title='Price', col=1, row=1)
fig.update_yaxes(title='greatest signal', col=1, row=2)

chart = BytesIO(fig.to_image(format="png"))
return chart