CSVDataFeed for backtesting¶
Load CSV¶
csv
parameters is reflect of pandas.read_csv()
parameters
In [1]:
Copied!
from lettrade.exchange.backtest import CSVBackTestDataFeed
df = CSVBackTestDataFeed(
"example/data/data/DAT_ASCII_AUDUSD_M1_2022.csv",
csv=dict(
# skiprows=[0],
names=["datetime", "open", "high", "low", "close", "volumn"],
header=None,
delimiter=";",
parse_dates=[0],
date_format="%Y%m%d %H%M%S",
),
name="AUDUSD",
timeframe="1m",
)
# df = df[df.high != df.low]
df
from lettrade.exchange.backtest import CSVBackTestDataFeed
df = CSVBackTestDataFeed(
"example/data/data/DAT_ASCII_AUDUSD_M1_2022.csv",
csv=dict(
# skiprows=[0],
names=["datetime", "open", "high", "low", "close", "volumn"],
header=None,
delimiter=";",
parse_dates=[0],
date_format="%Y%m%d %H%M%S",
),
name="AUDUSD",
timeframe="1m",
)
# df = df[df.high != df.low]
df
Out[1]:
open | high | low | close | volumn | |
---|---|---|---|---|---|
datetime | |||||
2022-01-02 17:10:00 | 0.72538 | 0.72545 | 0.72538 | 0.72545 | 0 |
2022-01-02 17:11:00 | 0.72545 | 0.72553 | 0.72545 | 0.72553 | 0 |
2022-01-02 17:12:00 | 0.72553 | 0.72553 | 0.72542 | 0.72547 | 0 |
2022-01-02 17:13:00 | 0.72547 | 0.72550 | 0.72547 | 0.72547 | 0 |
2022-01-02 17:14:00 | 0.72547 | 0.72547 | 0.72547 | 0.72547 | 0 |
... | ... | ... | ... | ... | ... |
2022-01-11 17:30:00 | 0.72105 | 0.72105 | 0.72105 | 0.72105 | 0 |
2022-01-11 17:31:00 | 0.72105 | 0.72105 | 0.72079 | 0.72091 | 0 |
2022-01-11 17:32:00 | 0.72091 | 0.72091 | 0.72090 | 0.72090 | 0 |
2022-01-11 17:33:00 | 0.72079 | 0.72089 | 0.72079 | 0.72089 | 0 |
2022-01-11 17:34:00 | 0.72089 | 0.72089 | 0.72089 | 0.72089 | 0 |
10000 rows × 5 columns
In [2]:
Copied!
import plotly.io as pio
pio.renderers.default = "notebook"
pio.templates.default = "plotly_dark"
import plotly.io as pio
pio.renderers.default = "notebook"
pio.templates.default = "plotly_dark"
Show¶
In [3]:
Copied!
import plotly.graph_objects as go
fig = go.Figure(
data=[
go.Candlestick(
x=df.index,
open=df.open,
high=df.high,
low=df.low,
close=df.close,
)
]
)
fig.show()
import plotly.graph_objects as go
fig = go.Figure(
data=[
go.Candlestick(
x=df.index,
open=df.open,
high=df.high,
low=df.low,
close=df.close,
)
]
)
fig.show()