Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
furechan committed Jun 8, 2024
1 parent c2cc3ba commit 5cf8e45
Show file tree
Hide file tree
Showing 25 changed files with 9,120 additions and 7,828 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Removed deprecated `helper` module
- Added support for minute data labels
- Removed deprecated stylesheet logic
- Added oolor options to most primitives

## 0.0.8
- Added tasks.py for project management
Expand Down
357 changes: 273 additions & 84 deletions examples/builtin-indicators.ipynb

Large diffs are not rendered by default.

298 changes: 298 additions & 0 deletions examples/candlestick-chart.ipynb

Large diffs are not rendered by default.

93 changes: 40 additions & 53 deletions examples/drawing-primitives.ipynb

Large diffs are not rendered by default.

267 changes: 267 additions & 0 deletions examples/ohlc-chart.ipynb

Large diffs are not rendered by default.

146 changes: 73 additions & 73 deletions examples/typical-usage.ipynb

Large diffs are not rendered by default.

235 changes: 235 additions & 0 deletions examples/volume-chart.ipynb

Large diffs are not rendered by default.

131 changes: 131 additions & 0 deletions misc/auto-label.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
{
"cells": [
{
"cell_type": "code",
"id": "6c7eafeb028e7924",
"metadata": {
"collapsed": true,
"ExecuteTime": {
"end_time": "2024-06-08T20:24:43.262799Z",
"start_time": "2024-06-08T20:24:43.241174Z"
}
},
"source": [
"from inspect import Signature, Parameter\n",
"\n",
"\n",
"def auto_label(self):\n",
" cname = self.__class__.__qualname__\n",
" signature = Signature.from_callable(self.__init__)\n",
" args, keyword_only = [], False\n",
"\n",
" for p in signature.parameters.values():\n",
" v = getattr(self, p.name, p.default)\n",
"\n",
" if p.kind in (Parameter.VAR_POSITIONAL, Parameter.VAR_KEYWORD):\n",
" raise ValueError(f\"Unsupported parameter type {p.kind}\")\n",
"\n",
" if p.kind == Parameter.KEYWORD_ONLY:\n",
" keyword_only = True\n",
" elif isinstance(p.default, (type(None), str, bool)):\n",
" keyword_only = True\n",
"\n",
" if v == p.default:\n",
" # skip argument if not equal to default\n",
" if keyword_only or not isinstance(v, (int, float)):\n",
" keyword_only = True\n",
" continue\n",
"\n",
" if keyword_only:\n",
" args.append(f\"{p.name}={v!r}\")\n",
" else:\n",
" args.append(f\"{v!r}\")\n",
"\n",
" args = \", \".join(args)\n",
"\n",
" return f\"{cname}({args})\"\n",
"\n",
"\n",
"class Indicator:\n",
" \"\"\"Implements a basic __repr__ based on __init__ signature\"\"\"\n",
"\n",
" def __init_subclass__(cls, **kwargs):\n",
" super().__init_subclass__(**kwargs)\n",
" cls.__repr__ = auto_label\n",
"\n",
"\n"
],
"outputs": [],
"execution_count": 19
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2024-06-08T20:24:43.889003Z",
"start_time": "2024-06-08T20:24:43.871067Z"
}
},
"cell_type": "code",
"source": [
"from dataclasses import dataclass, field\n",
"\n",
"@dataclass(frozen=True)\n",
"class EMA(Indicator):\n",
" period: int = 20\n",
" adjust : bool = False\n",
" item: str = field(default=None)\n",
"\n",
" def __call__(self, prices):\n",
" print(self.__class__.__name__, self.period, self.item)\n",
" return prices\n",
"\n",
"\n",
"for i in EMA(20), EMA(adjust=True), EMA(20, item=\"close\"):\n",
" print(i)\n",
"\n"
],
"id": "378856a846836d89",
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"EMA(20)\n",
"EMA(20, adjust=True)\n",
"EMA(20, item='close')\n"
]
}
],
"execution_count": 20
},
{
"metadata": {},
"cell_type": "code",
"outputs": [],
"execution_count": null,
"source": "",
"id": "3cce5ce0a9e1eec4"
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
243 changes: 243 additions & 0 deletions misc/charting-test.ipynb

Large diffs are not rendered by default.

Loading

0 comments on commit 5cf8e45

Please sign in to comment.