driller/どりらん
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # fin-pyコードリーディング会#1 :bookmark_tabs: ## 概要 ### fin-pyについて https://github.com/fin-py/guideline ### 参加方法 終了 ### タイムテーブル :clock1: 1. 自己紹介: 10min 2. コードを読む/わからないところを聞いてみる/議論する: 40min 3. クロージング(コードを読んだ感想など): 10min ### コードリーディング #### 読むコード [pybotters](https://github.com/MtkN1/pybotters) #### pybottersにした理由 - 金融関連 - fin-pyなので - 規模が大きくないパッケージ - pure Python - 新しい記法が使われている - 型ヒント - async, await - パッケージ開発に必要な工程が学べる - poetry - flake8 - pytest - GitHub Actions - discord: https://t.co/CTGJ2rZxEL?amp=1 #### 進め方 - 読み方は自由です - 気になったところ、感心したところ、質問してみたいところなどを話し合いましょう #### 控えること 雑談や世間話は問題ありませんが、会の本題から外れないように - トレードの手法をきく - ネガティブな表現 - Pythonの基礎構文(例: defってなんですか?) - ドキュメントに書いてある内容 ## 自己紹介・メモ :name_badge: :pencil: :::info 自己紹介を記入してください 下記は例です ### なまえ - Python(またはプログラム)の使いみち - 参加した目的や動機 - この会でやりたいこと #### コードを読んでみて staticmethodを使っているコードをあまり見たことがなかったので新鮮だった。どういう理由で使ってるか確認してみたい。 ```python= class Auth: @staticmethod def bybit(args: Tuple[str, URL], kwargs: Dict[str, Any]) -> Tuple[str, URL]: method: str = args[0] url: URL = args[1] data: Dict[str, Any] = kwargs['data'] or {} ``` ::: ### どりらん - twittter: [patraqushe](https://twitter.com/patraqushe) - ふだんは日経225オプションをトレードしています - Python関連の本書いたりもします - [![](https://drive.google.com/uc?export=view&id=1LpODktjvW15-a7_mHxXerB_GYmo0L--J)](https://www.amazon.co.jp/kindle-dbs/entity/author/B075MWYT5C/ref=as_li_ss_tl?_encoding=UTF8&node=465392&offset=0&pageSize=12&searchAlias=stripbooks&sort=author-sidecar-rank&page=1&langFilter=default&linkCode=sl2&tag=eleshis-22&linkId=8432829b7324b5c92b1f03baa04c7402&language=ja_JP) - pandasとか可視化ライブラリでデータをゴニョゴニョ - 独学で学ぶことが多いので、ほかの人の視点をきいてみたい Jupyter上でasyncio https://ipython.readthedocs.io/en/stable/interactive/autoawait.html event loop > https://stackoverflow.com/questions/55409641/asyncio-run-cannot-be-called-from-a-running-event-loop aiohttpがベースになっているみたいなので、GETリクエストをaiohttpで書いてみる ```python= import asyncio import aiohttp async def main(): async with aiohttp.ClientSession() as session: url = "https://api.bybit.com/v2/public/orderBook/L2" return await session.get(url, params={"symbol": "BTCUSD"}) r = await main() await r.json() ``` pybotterで実装 ```python= import pybotters async def main(): async with pybotters.Client(base_url="https://api.bybit.com") as client: return await client.get("/v2/public/orderBook/L2", params={"symbol": "BTCUSD"}) r = await main() await r.json() ``` - wikiの内容をSphinxでビルドして、ReadTheDocsにデプロイできるのでは? - wikiのソースはgitでとれそう ```bash git clone https://github.com/MtkN1/pybotters.wiki.git ``` - Sphinxでドキュメント化してPRを出してみたい - Web全般の知識が足りなかった - [Real World HTTP ミニ版](https://www.oreilly.co.jp/books/9784873118789/)が無料で購入できる ### しんせいたろう - twitter: [shinseitaro](https://twitter.com/shinseitaro) - Python(またはプログラム)の使いみち: pandas を使った可視化をよくしてます。Djangoもちょっと。 - 参加した目的や動機: pybotters を読みたいと言った人。まちゅけんさん、突然のお誘いにもかかわらずご参加いただきありがとうございます。 - この会でやりたいこと: async, typing など、普段私は使わないライブラリがたくさん使われているので、読み込んで学びたい。 - 圧倒的に非同期処理力が無いことがわかったので、がんばりたい。 - 学んだこと - `logger.error(repr(e)) ` の repr(e) にしている理由はオブジェクト確認がやりやすいから - `store.py` 197行目 ```python def get(self, name: str, type: Type[TDataStore]) -> TDataStore: return cast(type, self._stores.get(name)) ``` 型変換を間違いなくちゃんと行うためにcast - `store.py` 136行目 ```python def find(self, query: Item = {}) -> List[Item]: if query: return [ item for item in self if all(k in item and query[k] == item[k] for k in query) ] else: return list(self) ``` self の中身が ```python def __iter__(self) -> Iterator[Item]: return iter(self._data.values()) ``` なのは、特殊メソッドを呼ぶPythonの機能を利用しているから。 ### まちゅけん - twitter: [MtkN1XBt](https://twitter.com/MtkN1XBt) - pybotters開発者です。他にもpybybitを開発したりTwitterではbotterとして活動しています。本職はWeb系エンジニアでPythonバックエンドがメインです。 - 参加した目的や動機: pybottersを取り上げてくださりありがとうございます。是非pybotters内の技術を共有できたらと思います。 - @staticmethodやreprなど自分の嗜好でコーディングしている部分があったのでその辺りを見直したい。 - mypyやドキュメント自動化を将来的には実装したい。 ### もりもと - 普段は python を書いてないですが、コードリーディングのイベントに気になったので参加してみました - 気になったところ - @staticmethod を多用しているところの背景 - except で補足した例外を無視しているところがいくつかあるのが気になる - https://ja.wikisource.org/wiki/%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9E%E3%81%8C%E7%9F%A5%E3%82%8B%E3%81%B9%E3%81%8D97%E3%81%AE%E3%81%93%E3%81%A8/%E3%82%A8%E3%83%A9%E3%83%BC%E3%82%92%E7%84%A1%E8%A6%96%E3%81%99%E3%82%8B%E3%81%AA - DataStoreInterface よりは DataStoreBase の方が適切?抽象基底クラスの方があっている気がした - `session.__dict__['_apis']` は `session._apis` でアクセスできないのかな? - 学んだこと - aiohttp を使ったコードをあまり読んだことがなかったので勉強になりました - rest api, websocket 両方扱える ### yoshi - レベルが高かった。Web全般の知識が全然ないので、非同期処理やシングルスレッドなど後でググらないといけない単語がわかったことが収穫です。ありがとうございます。 ### saru999 コードリーディング会に初めて参加しました。 単にプログラムが動くとかぐらいしか考えていなかったのですが、他の参加者の意見交換を聞いてより深いプログラムの理解ができました。 ありがとうございました。 ### takei - 自分で独学で作るより、プロに作っていただいたものを使うほうがシンプルに強いと思いました。 - 自分の書き方と違うプログラムは難しい。。 - これから勉強すること:aiohttp, hash ### Toshi - 有難うございました。次回は質問できるよう勉強して、参加枠に登録します。 ## 次回に向けて - まちゅけんさんに質問できてよかった - 時間帯足りなかった - 事前知識 - ハードル高かった? - ドメイン知識 - Python知識 - 事前に読んでおいて、質問を考えておく? - 実際に読んでみて、自分に足りない知識がわかった - 誰かの画面を共有する時間を増やす - コードを絞る - ファシリテーターが画面を出す - 輪番で回す - 不安な人は事前に読み込む - 5人くらい - プレッシャーかかる - 聞くだけ枠 -> にぎやかし枠 - 話を振らないほうがよい? - 枠は残す - 条件をつける? - Zoomのチャットは受け付ける - どうしても話したくなったら入ってもらう - 読むコードは別途検討 次回 8/19(木) 19:00-21:00

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully