あけましておめでとうございます。キリンです。今年もよろしくお願いいたします。 作ったもの rust_decimal::Decimal を Python ライブラリ化 C API Decimal class using PyO3, which can be imported from other pyo3 libraries. - fx-kirin/pyo3_decimal: C API Decimal class using PyO3,... レポジトリ上の pyo3_decimal が rust_decimal::Decimal の Python 上の ラッパーライブラリで、Python pyo3_decimal.Decimal というクラスを作成しています。 pyo3_decimal_api が rust-numpy のような仕組みのヘッダーファイルのようなライブラリです。 実際の外部
[追記] This has been implemented and will be in pip 21.1. You can try the main branch with –use-feature=in-tree-build. https://github.com/pypa/pip/issues/9819 だそうです。 困った。 状況としては setuptools-rust を使って相対パスで指定した Rust の dependencies がパスが存在しないとして処理されてしまう。 pip install . でインストールできなかったのだが、pip を使ってインストールすると、インストール前にそのパッケージが /tmp 以下のフォルダに一時的にコピーされてしまうことが原因のようだった。 poetry を使っていると全部 pip でインストールしようとしてしまうので、python
Python で使える WordPress OAuth クライアントがない Boostnote から Wordpress に画像つきで記事投稿するBoostnote から Wordpress への投稿は標準にある画像の投稿の部分を除けば、 Boostnote から直接 Wordpress への投稿をする方法は標準であります。ここの記事にもあるように、最終的には "コピ...fx-kirin.com2021-03-15 先日、こういう記事を投稿したのですが、Boostnote to WordPress というスクリプトを作成するに当たり、Python から使える OAuth 認証の WordPress REST API Client がないことが分かりました。このブログ自体、今後 SSL 対応する予定ではあるのですが、セキュリティ的に生のパスワードを暗号化せずに通信させるのはなかなかまずいの
pip 使ってますよね Pythonを使っている人であれば、pip installでライブラリをインストールすることはもはや常識ですね。 pip でインストールできるようにするには? PYPI にパッケージを登録すれば、pip でインストールできるようになります。パッケージのアップロードのためにはPYPIアカウントが必要になるので、作成しておいてください。
Javascriptを実行するとアウトプットセルの行が増える これがとても面倒だった。上の画像のように、Widgetのボタンを押すとからの行がセルのアウトプットに表示されてしまう。Jupyter Dashboard上から使おうと思っているのに、表示が崩れてしまって困った。 widgets.Output を使って、出力を瞬間で消す。 from IPython.display import Javascript, display from ipywidgets import widgets out = widgets.Output() def run_all(ev): with out: display(Javascript('IPython.notebook.execute_all_cells()')) out.clear_output() button = widgets.Button(d
Bokeh Plotting Backend for Pandas and GeoPandas. Contribute to PatrikHlobil/Pandas-Bokeh development by creating an account on GitHub. インストール pip install pandas-bokeh 使い方 最初にpandas_bokehの読み込みコマンドを実行します。今回はjupyter notebook上で使いたいので、ouutput_notebook としました。 import pandas_bokeh pandas_bokeh.output_notebook() plotをplot_bokehに変えるだけ Pandasをよく使っている人は、DataFrame.plot.bar()でチャートを書くことができることは知っていると思います。Pandas-B
SQLAlchemyの作者が作ったデータベースマイグレーションツール。個人的には、SQLAlchemyは使わないが、スキーマの作成に使っている。 モデル定義から自動作成 モデル定義から自動的にマイグレーションスクリプトを作成できる。前回からの変更分なども、現在のスキーマと比較して作成してくれる。ということで、モデル定義だけ変更すればあとはよしなにやってくれる。 プロジェクト作成コマンド 適応させたいプロジェクトのルートで実行する。 alembic init alembic model のインポート env.pyファイルを使ってsqlalchemyのmapsクラスをインポートして、テーブルの設定が読み込まれたBase.metadataをtarget_metadataに割り当てる。 import <Target Maps Package> target_metadata = <Target M
こんにちは。キリンです。 最近、年に数度のMQLを書くときがきたのですが、Pythonに慣れまくっていると苦行でしかないですねw昔は毎日のようにMQLばかり書いていた時期があるのが懐かしいです。あのころにPythonの有用性を知っていたら、もっと成長できていなんじゃないかなぁと思ったり。技術ブログばっかり書いていて、珍しく前書きみたいなものを書いているんですが、これにはきっかけがありまして、MT4の検索をしていると昔の自分の記事がたまにヒットして、あの頃はちゃんと頻繁にブログを書いていたなぁと思ったからでして。あの頃は毎日何か書けるネタがないかと探している日々だったのですが、今となっては逆にかけるネタはたくさん思い当たるのにほとんど書かなくなってしまったので、アウトプットをもう少し増やしてもいいかなぁと思っています。ただ、子育てと仕事の上に最近は咳喘息で日々体調が悪いので、かなり難しいので
最初に追加 struct module_state { PyObject *error; }; #if PY_MAJOR_VERSION >= 3 #define GETSTATE(m) ((struct module_state*)PyModule_GetState(m)) #else #define GETSTATE(m) (&_state) static struct module_state _state; #endif #ifndef Py_TYPE #define Py_TYPE(ob) (((PyObject*)(ob))->ob_type) #endif モジュールの初期化と状態情報を書き換える initmyextension 関数などの初期状態の関数を書き換える #if PY_MAJOR_VERSION >= 3 static int myextension_traver
Interactive Brokers 証券とは 日本には珍しく自動売買プラットフォームが提供されいてる証券会社です。基本的には全部JAVAで書かれていますが、最近Pythonも公式に対応しました。 Python ライブラリの入手 Our proprietary API solutions let you create your own trading programs that take advantage of our high-speed order routing and broad mark... Latest版のzipをダウンロードしてください。Stable版にはPythonが同梱されていないととても小さい文字で書いてありました。Python3のみ対応とのこと。 Pythonのパッケージディレクトリから下記コマンドでインストールしておきます。 python3 setup.py
GitHub is where people build software. More than 28 million people use GitHub to discover, fork, and contribute to over 85 million projects. python-highcharts のラッパー pandas の DataFrame や Series からお手軽に使える Jupyterからローソク足チャートを使いたいと思った時、色々試しましたが一番良かったのが Highcharts でした。それをできるだけ自分が使いやすいようにラッパーを書いたのがkanichartです。 Highcharts の良いところ JSなのでインタラクティブに操作可能 マウスオーバー時に数値を表示など細かいところが標準で充実 x軸を共有した際の動作が優秀 時系列解析には必須 pyt
主張:高速化は最後のおたのしみにしましょう。 無駄にいじいじして高速化させて満足し、結局その後はほとんど使わなかったなあ、、、が私の日常です。 えらい人も言っていますが、高速化なんてホント最後でいいんです・・・。 今まで何十回後悔したことか。。。(これからもまたやりますが。) pythonであれば numba,cython,swig など、コンパイルしちゃう系の力(パワー)を借りることで、 全く同じアルゴリズムでもざっくり100倍単位で簡単に高速化できます。 しかし、このやり方ではpythonのインタープリターなゆるふわ△言語の良さを(該当コード部分において)捨ててしまいます。結局C/C++に魂を売っているだけです。 私は魂を売ることそれ自体が好きなので良いですが、この行為はpythonの持つ別の面での高速性、つまり "生産性の高さ" を犠牲にしています。 コードの実行スピードが速くなって
pdbでのデバッグにはreload機能がない IPythonには優秀なautorelaod機能がマジックコマンドで存在していたが、pdb環境で開発する人にとってはreload機能でなかなか便利なものがなかった。 Python の reload は使いづらい インスタンスメソッドはreloadしても更新されなかったり、なかなか面倒だった。調べた限り、Pythn3 には reload 用のライブラリが存在しているようだったが、Python2では動かなかったので、自分で作ることにした。 インスタンスメソッドは更新されない 普通にreloadするだけでは、すでに作成しているインスタンスのメソッドの更新までは行われない。それを自動で可能な限り更新できるようにしておいた。 インストール pip install reload_all 使い方 from reload_all import reload_a
プロジェクトが大きくなるにつれて、プログラムの不備を見つけるのにログの構成、ログデザインを考えることが重要になってくる。上手なログの書き方を覚えれば、プリントデバッグがとても用意になるので、習慣づける価値はある。 システムトレードの取引をしていると、サーバーの遅延や分散処理による非同期処理が増えて全体としてのフローが複雑になって、取引残高がずれた時の原因究明が容易ではなくなっていく。その時に、ログを上手に使ってトラッキングできるようにしておくと、不具合が起こった時の対処が楽になる。
概要 Broker を間に置いた REQ/REP パターンを作ってみます。 基本的にはどう頑張っても 1:N しか出来ないのですが中間に Broker をおくことで、 N:N を実現しています。 実現したいこと REQ と REP どちらかの 1:N 構成ではなく、N:N 構成をする ただ、今回は REQ 側はめんどくさいので 1 構成になっています。 構成 1 つの Broker に対して複数の REP と REQ がぶら下がります。Broker が死ぬと破綻します。 broker.py Broker を実現するには ROUTER と DEALER を使います。 簡単に言えば集約して、再度配るといった感じです。 Broker は ROUTER と DEALER 両方で bind しています。 import zmq from zmq.eventloop import ioloop loop
Rust で Python の拡張ライブラリを書く なぜRustなのか この当たりを書いていると時間が無くなりそうなので、割愛したい。ただ、C++に馴染みのあるユーザーで高速に動作するコードを手っ取り早く書いていくにはRustが良さそうであるというのが自分なりの理解。特に、パッケージマネジャー当たりの優秀さはC++にはなくとても助かりそうである。メモリマネジメントもC++よりストレスレス。 PythonのAdventでRustなの? Pythonのヘビーユースしだすと、C/C++ Extention を書いたり、Cythonなどを使って高速化していくことは特別なことではなくなる。そのひとつの選択肢として、これからはRustが良さそうだということで、勉強を兼ねて今回の記事を書くことにした。私自身はRustの初心者なので、間違っているところ等があればぜひご指摘いただきたい。 Rustのインスト
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く