Skip to content

Instantly share code, notes, and snippets.

View izikeros's full-sized avatar

Krystian Safjan izikeros

View GitHub Profile
@izikeros
izikeros / README.md
Last active March 15, 2024 19:53
[License reports] License reporting with liccheck #python #project #qa

License reporting with liccheck

This script rely on liccheck python package and contains some parts of code extracted and modified to fullfil my needs.

Requirements

  • liccheck installed: pip install liccheck
  • added configuration file or content in pyproject.tom, e.g.
[tool.liccheck]
authorized_licenses = [
@izikeros
izikeros / README.md
Last active March 15, 2024 19:54
[DataFrame in console with rich] Use Rich library to display Pandas DataFrame in console #pandas

rich_display_dataframe

rich_display_dataframe is a Python function that allows you to display a Pandas DataFrame as a table using the rich library.

rich_dataframe

Usage

def rich_display_dataframe(df, title="Dataframe") -> None:
@izikeros
izikeros / sphinx-documentation.md
Created September 17, 2022 21:47 — forked from rinaldo-rex/sphinx-documentation.md
Sphinx documentation cheatsheet

Overview

This document is a simple resource to create sphinx documentation for projects with python(or not). This isn't exhaustive, but it'll help us get started without much hassle, (which, is typical for sphinx generated documenting)

Prerequisites

For better results, ensure that you're inside a virtual env. This document assumes you're in a Pipenv based environment. Update it later to include other python package management tools (hopefully poetry)

@izikeros
izikeros / DataBricksNotebook2Ipynb.jq
Last active March 15, 2024 20:02 — forked from jnothman/DataBricksNotebook2Ipynb.jq
[Databricks notebook to ipynb] Approximately convert DataBricks notebook (unzipped .dbc file) to ipynb using jq #jupyter #databricks #notebook #jq
.language as $lang |
{
"metadata" : {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
@izikeros
izikeros / binance_ccxt.py
Last active March 14, 2024 10:01 — forked from rodrigo-brito/binance_ccxt.py
[CCXT example] Binance example of usage #crypto #python
class Binance:
def __init__(self, key, secret, test=False):
self.exchange = ccxt.binance({
'apiKey': key,
'secret': secret,
'enableRateLimit': True,
})
self.test = test
def buy(self, symbol, amount):
@izikeros
izikeros / README.md
Last active March 14, 2024 09:58 — forked from rodrigo-brito/main.py
[Trading on Binance] using Backtrader and CCXT #crypto

Backtrader integration with Binance

Backtrader does not allows natively for trading on Binance however it supports CCXT which is an universal interface to multiple exchanges. This example uses CCXT to allow Backtrader perform trades on this exchange.

Requirements

Create virtualenv, install ccxt store for backtrader:

pip install git+git://github.com/Dave-Vallance/bt-ccxt-store@master#bt-ccxt-store

and backtrader package

@izikeros
izikeros / medium_copilot_check_lists_example.py
Created June 2, 2022 17:38
Code snippet example for medium article
def check_lists_equal_nested(list_1: list, list_2: list) -> bool:
"""
Check if two nested lists have the same dictionaries
:param list_1: list
:param list_2: list
:return: bool
"""
# 1. Check if two top-level lists have the same length
if len(list_1) != len(list_2):
return False
@izikeros
izikeros / medium_copilot_get_images_example.py
Created June 2, 2022 17:34
Code snippet with example for medium article
def get_images_in_dir(directory: str, extensions: List[str]) -> list:
"""
Get list of images in a directory, recursively. Include extensions:
.jpg, .png, cr2, etc.
:param directory: str
:param extensions: list
:return: list
"""
images = []
for root, dirs, files in os.walk(directory):
@izikeros
izikeros / pytest.ini
Last active March 15, 2024 20:05
[pytest CLI logging] Logging settings for pytest. log_cli=true enables display logs during testing. #pytest #configuration
[pytest]
log_cli=true
log_level=NOTSET
log_format=[%(levelname)-.1s] %(message)s
@izikeros
izikeros / yahoo_download_ticker_ohlc.py
Last active March 15, 2024 20:12
[OHLC from Yahoo] Download OHLC ticker data from Yahoo #finance
import yfinance as yf
from datetime import datetime # To get the current date and time
start_date = datetime(2011, 1, 1)
end_date = datetime(2011, 5, 1)
ticker = "MSFT"
yf_ticker_obj = yf.Ticker(ticker)