Skip to content

Instantly share code, notes, and snippets.

@mementum
mementum / at_dataclass.py
Created April 22, 2024 08:01
Dataclass with Field Annotations using @
#!/usr/bin/env python
# -*- coding: utf-8; py-indent-offset:4 -*-
###############################################################################
from __future__ import annotations
from collections.abc import Callable
import re
import inspect
from typing import Annotated, overload
# dataclasses imports
@mementum
mementum / pep-07xx.rst
Last active August 15, 2023 21:01
PEP-07xx draft
@mementum
mementum / two-million-indicators-only-pypy-run06.txt
Created October 26, 2019 08:50
Two Million Candles Indicators Only PyPy Run 06
$ ./two-million-candles.py --strat indicators=True
Cerebro Start Time: 2019-10-26 09:05:55.967969
Strat Init Time: 2019-10-26 09:06:44.072969
Time Loading Data Feeds: 48.10
Number of data feeds: 100
Total indicators: 300
Moving Average to be used: SMA
Indicators period 1: 10
Indicators period 2: 50
Strat Start Time: 2019-10-26 09:06:44.779971
@mementum
mementum / two-million-trade-pypy-run05.txt
Created October 26, 2019 08:49
Two Million Candles Trade PyPy Run 05
$ ./two-million-candles.py --strat indicators=True,trade=True
Cerebro Start Time: 2019-10-26 08:57:36.114415
Strat Init Time: 2019-10-26 08:58:25.569448
Time Loading Data Feeds: 49.46
Number of data feeds: 100
Total indicators: 300
Moving Average to be used: SMA
Indicators period 1: 10
Indicators period 2: 50
Strat Start Time: 2019-10-26 08:58:26.230445
@mementum
mementum / two-million-exactbars-pypy-run04.txt
Created October 26, 2019 08:48
Two Million Candles Exactbars Mode PyPy Run 04
$ ./two-million-candles.py --cerebro exactbars=True,stdstats=False
Cerebro Start Time: 2019-10-26 08:44:32.309689
Strat Init Time: 2019-10-26 08:44:32.406689
Time Loading Data Feeds: 0.10
Number of data feeds: 100
Strat Start Time: 2019-10-26 08:44:32.409689
Pre-Next Start Time: 2019-10-26 08:44:32.451689
Time Calculating Indicators: 0.04
Next Start Time: 2019-10-26 08:44:32.451689
Strat warm-up period Time: 0.00
@mementum
mementum / two-million-exactbars-run03.txt
Created October 26, 2019 08:46
Two Million Candles Exactbars Mode Run 03
$ ./two-million-candles.py --cerebro exactbars=False,stdstats=False
Cerebro Start Time: 2019-10-26 08:37:08.014348
Strat Init Time: 2019-10-26 08:38:21.850392
Time Loading Data Feeds: 73.84
Number of data feeds: 100
Strat Start Time: 2019-10-26 08:38:21.851394
Pre-Next Start Time: 2019-10-26 08:38:21.857393
Time Calculating Indicators: 0.01
Next Start Time: 2019-10-26 08:38:21.857393
Strat warm-up period Time: 0.00
@mementum
mementum / two-million-batch-pypy-run02.txt
Created October 26, 2019 08:45
Two Million Candles Batch Mode PyPy Run 01
$ ./two-million-candles.py
Cerebro Start Time: 2019-10-26 08:39:42.958689
Strat Init Time: 2019-10-26 08:40:31.260691
Time Loading Data Feeds: 48.30
Number of data feeds: 100
Strat Start Time: 2019-10-26 08:40:31.338692
Pre-Next Start Time: 2019-10-26 08:40:31.612688
Time Calculating Indicators: 0.27
Next Start Time: 2019-10-26 08:40:31.612688
Strat warm-up period Time: 0.00
@mementum
mementum / two-million-batch-run01.txt
Created October 26, 2019 08:44
Two Million Candles Batch Mode Run 01
$ ./two-million-candles.py
Cerebro Start Time: 2019-10-26 08:33:15.563088
Strat Init Time: 2019-10-26 08:34:31.845349
Time Loading Data Feeds: 76.28
Number of data feeds: 100
Strat Start Time: 2019-10-26 08:34:31.864349
Pre-Next Start Time: 2019-10-26 08:34:32.670352
Time Calculating Indicators: 0.81
Next Start Time: 2019-10-26 08:34:32.671351
Strat warm-up period Time: 0.00
@mementum
mementum / performance-test.py
Created October 26, 2019 08:43
Peformance Test Script
#!/usr/bin/env python
# -*- coding: utf-8; py-indent-offset:4 -*-
###############################################################################
import argparse
import datetime
import backtrader as bt
class St(bt.Strategy):
@mementum
mementum / generate-candles.py
Created October 26, 2019 08:42
Generate Cancles
import numpy as np
import pandas as pd
COLUMNS = ['open', 'high', 'low', 'close', 'volume', 'openinterest']
CANDLES = 20000
STOCKS
dateindex = pd.date_range(start='2010-01-01', periods=CANDLES, freq='15min')
for i in range(STOCKS):