<gh_stars>0
import random
from datetime import datetime
import plotly.graph_objects as go
import pandas as pd
import sarl
from DataObject import DataObject

data = pd.read_csv("EURUSD5MIN/28.07.2005-27.07.2008.csv")

date = []
for i in data['Gmt time']:
    date.append(datetime.strptime(i, '%d.%m.%Y %H:%M:%S.%f'))
data['date'] = date
data.drop(['Gmt time'], axis=1, inplace=True)
data.columns = ['open','high','low','close','volume','date']
del date

for i in range(1):
    index = random.randint(100, len(data))
    df = data.iloc[index:index+864]
    df.reset_index(inplace=True)
    oneDay = DataObject(6)
    twoDays = DataObject(6)
    halfDay = DataObject(6)

    oneDay.set_OHLC(df.iloc[-576:-288])
    twoDays.set_OHLC(df.iloc[:-288])
    halfDay.set_OHLC(df.iloc[-432:-288])

    oneDaySarl = sarl.lines(oneDay)
    twoDaySarl = sarl.lines(twoDays)
    halfDaySarl = sarl.lines(halfDay)

    static_lines = []
    dynamic_lines = []

    static_lines += twoDaySarl.static_line(twoDays.scaled_data[1], twoDays.scaled_data[2], False,50,4)
    static_lines += oneDaySarl.static_line(oneDay.scaled_data[1], oneDay.scaled_data[2], False, 50, 2)

    dynamic_lines += oneDaySarl.dynamic_lines(False, 60, 2, 4)
    dynamic_lines += halfDaySarl.dynamic_lines(False, 60, 2, 2)

    lines_points_y = []
    lines_points_x = []

    for i in static_lines:
        line_y1 = []
        line_x1 = []
        line_y2 = []
        line_x2 = []
        for j in df['date']:
            line_y1.append(i[0] - twoDaySarl.threshold / 2)
            line_x1.append(j)
            line_y2.append(i[0] + twoDaySarl.threshold / 2)
            line_x2.append(j)
        lines_points_y.append(line_y1)
        lines_points_x.append(line_x1)
        lines_points_y.append(line_y2)
        lines_points_x.append(line_x2)

    for i in dynamic_lines:
        line_y1 = []
        line_x1 = []
        line_y2 = []
        for j in df['date']:
            x = int(j.strftime('%s'))
            y = i[0] * x + i[1]
            if y > df['low'].min() and y < df['high'].max():
                line_y1.append((i[0] * x + i[1]) - twoDaySarl.threshold / 2)
                line_y2.append((i[0] * x + i[1]) + twoDaySarl.threshold / 2)

                line_x1.append(datetime.fromtimestamp(x).strftime("%Y-%m-%d %H:%M:%S"))
        lines_points_y.append(line_y1)
        lines_points_y.append(line_y2)
        lines_points_x.append(line_x1)
        lines_points_x.append(line_x1)



    # plotting OHLC data
    fig = go.Figure()
    fig.add_ohlc(x=df['date'],
                 open=df['open'],
                 high=df['high'],
                 low=df['low'],
                 close=df['close'])
    # adding neowave cash data to OHLC chart to compare
    for i in range(len(lines_points_x)):
        fig.add_trace(go.Scatter(
            mode="lines", x=lines_points_x[i], y=lines_points_y[i]))

    fig.show()

import random
from datetime import datetime
import plotly.graph_objects as go
import pandas as pd
import sarl
from DataObject import DataObject

data = pd.read_csv("EURUSD5MIN/28.07.2005-27.07.2008.csv")

date = []
for i in data['Gmt time']:
    date.append(datetime.strptime(i, '%d.%m.%Y %H:%M:%S.%f'))
data['date'] = date
data.drop(['Gmt time'], axis=1, inplace=True)
data.columns = ['open','high','low','close','volume','date']
del date

for i in range(1):
    index = random.randint(100, len(data))
    df = data.iloc[index:index+864]
    df.reset_index(inplace=True)
    oneDay = DataObject(6)
    twoDays = DataObject(6)
    halfDay = DataObject(6)

    oneDay.set_OHLC(df.iloc[-576:-288])
    twoDays.set_OHLC(df.iloc[:-288])
    halfDay.set_OHLC(df.iloc[-432:-288])

    oneDaySarl = sarl.lines(oneDay)
    twoDaySarl = sarl.lines(twoDays)
    halfDaySarl = sarl.lines(halfDay)

    static_lines = []
    dynamic_lines = []

    static_lines += twoDaySarl.static_line(twoDays.scaled_data[1], twoDays.scaled_data[2], False,50,4)
    static_lines += oneDaySarl.static_line(oneDay.scaled_data[1], oneDay.scaled_data[2], False, 50, 2)

    dynamic_lines += oneDaySarl.dynamic_lines(False, 60, 2, 4)
    dynamic_lines += halfDaySarl.dynamic_lines(False, 60, 2, 2)

    lines_points_y = []
    lines_points_x = []

    for i in static_lines:
        line_y1 = []
        line_x1 = []
        line_y2 = []
        line_x2 = []
        for j in df['date']:
            line_y1.append(i[0] - twoDaySarl.threshold / 2)
            line_x1.append(j)
            line_y2.append(i[0] + twoDaySarl.threshold / 2)
            line_x2.append(j)
        lines_points_y.append(line_y1)
        lines_points_x.append(line_x1)
        lines_points_y.append(line_y2)
        lines_points_x.append(line_x2)

    for i in dynamic_lines:
        line_y1 = []
        line_x1 = []
        line_y2 = []
        for j in df['date']:
            x = int(j.strftime('%s'))
            y = i[0] * x + i[1]
            if y > df['low'].min() and y < df['high'].max():
                line_y1.append((i[0] * x + i[1]) - twoDaySarl.threshold / 2)
                line_y2.append((i[0] * x + i[1]) + twoDaySarl.threshold / 2)

                line_x1.append(datetime.fromtimestamp(x).strftime("%Y-%m-%d %H:%M:%S"))
        lines_points_y.append(line_y1)
        lines_points_y.append(line_y2)
        lines_points_x.append(line_x1)
        lines_points_x.append(line_x1)



    # plotting OHLC data
    fig = go.Figure()
    fig.add_ohlc(x=df['date'],
                 open=df['open'],
                 high=df['high'],
                 low=df['low'],
                 close=df['close'])
    # adding neowave cash data to OHLC chart to compare
    for i in range(len(lines_points_x)):
        fig.add_trace(go.Scatter(
            mode="lines", x=lines_points_x[i], y=lines_points_y[i]))

    fig.show()
# plotting OHLC data # adding neowave cash data to OHLC chart to compare