Skip to content

Instantly share code, notes, and snippets.

from struct import calcsize
import polars as pl
def scid_parse_trades(filepath: str) -> pl.DataFrame:
"""Sierrachart's SCID format. Must be configured to record single trade ticks."""
intraday_record_struct = np.dtype(
[
("timestamp", "<q"),
("open", "<f"),
("ask_price", "<f"),
@goraj
goraj / make_window_borderless.py
Created June 11, 2018 21:10
Borderless opencv window
def make_window_borderless(self):
"""
Requires: pywin32
https://www.lfd.uci.edu/~gohlke/pythonlibs/#pywin32
import win32gui as wg
import win32api as wa
import win32con as wc
Based on: https://github.com/howardjohn/pyty/blob/master/src/window_api.py
"""
@goraj
goraj / explode_multi_column.py
Last active May 31, 2023 11:09
explode_multi_column.py
from typing import List
import pandas as pd
def explode_multi_column(
df: pd.DataFrame, index_cols: List[str], sep: str
):
"""
In [13]:
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@goraj
goraj / exchanges.json
Created January 31, 2023 01:59
exchanges.json
{
"results": [
{
"id": 1,
"type": "exchange",
"asset_class": "stocks",
"locale": "us",
"name": "NYSE American, LLC",
"acronym": "AMEX",
"mic": "XASE",
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@goraj
goraj / openeye_bug.ipynb
Created March 31, 2022 14:38
openeye_bug.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@goraj
goraj / nautilus_parquet_example.py
Last active February 19, 2022 19:59
nautilus parquet example
from nautilus_trader.backtest.data.wranglers import BarDataWrangler
from nautilus_trader.persistence.external.readers import ParquetReader
from nautilus_trader.persistence.catalog import DataCatalog
from functools import partial
from nautilus_trader.core.datetime import dt_to_unix_nanos
from nautilus_trader.model.c_enums.bar_aggregation import BarAggregation
from nautilus_trader.model.data.bar import Bar, BarType, BarSpecification
from nautilus_trader.model.enums import AggregationSource, PriceType
from nautilus_trader.persistence.external.core import process_files, write_objects
@goraj
goraj / incremental_lightgbm.py
Last active October 1, 2021 03:25
incremental learning lightgbm
# -*- coding: utf-8 -*-
"""
@author: goraj
"""
import lightgbm as lgbm
from sklearn.datasets import load_digits
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.metrics import roc_auc_score
@goraj
goraj / st_rerun.py
Last active April 2, 2021 19:15 — forked from demmerichs/st_rerun.py
Rerun a Streamlit 0.57.3 app from the top! See https://discuss.streamlit.io/t/update-sidebar/531
import streamlit.ReportThread as ReportThread
from streamlit.ScriptRequestQueue import RerunData
from streamlit.ScriptRunner import RerunException
from streamlit.server.Server import Server
def rerun():
"""Rerun a Streamlit app from the top!"""
widget_states = _get_widget_states()
raise RerunException(RerunData(widget_states))