{"id":13838600,"url":"https://github.com/drift-labs/driftpy","last_synced_at":"2025-05-16T06:05:00.911Z","repository":{"id":40362299,"uuid":"449395628","full_name":"drift-labs/driftpy","owner":"drift-labs","description":"python sdk to interact with drift v2","archived":false,"fork":false,"pushed_at":"2025-05-04T23:48:09.000Z","size":3801,"stargazers_count":84,"open_issues_count":19,"forks_count":46,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-05T00:27:36.079Z","etag":null,"topics":["python","solana"],"latest_commit_sha":null,"homepage":"https://drift-labs.github.io/driftpy/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/drift-labs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-01-18T18:11:23.000Z","updated_at":"2025-05-04T23:48:13.000Z","dependencies_parsed_at":"2023-11-26T03:22:09.171Z","dependency_job_id":"5c022359-8265-4456-84ef-5caac82e2f80","html_url":"https://github.com/drift-labs/driftpy","commit_stats":{"total_commits":372,"total_committers":8,"mean_commits":46.5,"dds":0.467741935483871,"last_synced_commit":"8ccac229d64cb608b2533e5ddbe8f25d1ce368fa"},"previous_names":[],"tags_count":184,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drift-labs%2Fdriftpy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drift-labs%2Fdriftpy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drift-labs%2Fdriftpy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drift-labs%2Fdriftpy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/drift-labs","download_url":"https://codeload.github.com/drift-labs/driftpy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254478187,"owners_count":22077676,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python","solana"],"created_at":"2024-08-04T16:00:23.579Z","updated_at":"2025-05-16T06:05:00.885Z","avatar_url":"https://github.com/drift-labs.png","language":"Python","funding_links":[],"categories":["Uncategorized","Awesome Drift","Quant and Trading Agents"],"sub_categories":["Uncategorized","Official SDK","Benchmark Reality Check (real-world tool use)"],"readme":"# DriftPy\n\n\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\"docs/img/drift.png\" width=\"30%\" height=\"30%\"\u003e\n\u003c/div\u003e\n\nDriftPy is the Python client for the [Drift](https://www.drift.trade/) protocol.\nIt allows you to trade and fetch data from Drift using Python.\n\n**[Read the full SDK documentation here!](https://drift-labs.github.io/v2-teacher/)**\n\n## Installation\n\n```\npip install driftpy\n```\n\nNote: requires Python \u003e= 3.10.\n\n\n## SDK Examples\n\n- `examples/` folder includes more examples of how to use the SDK including how to provide liquidity/become an lp, stake in the insurance fund, etc.\n\n\n## Note on using QuickNode\n\nIf you are using QuickNode free plan, you *must* use `AccountSubscriptionConfig(\"demo\")`, and you can only subscribe to 1 perp market and 1 spot market at a time.\n\nNon-QuickNode free RPCs (including the public mainnet-beta url) can use `cached` as well.\n\nExample setup for `AccountSubscriptionConfig(\"demo\")`: \n\n```python\n    # This example will listen to perp markets 0 \u0026 1 and spot market 0\n    # If you are listening to any perp markets, you must listen to spot market 0 or the SDK will break\n\n    perp_markets = [0, 1]\n    spot_market_oracle_infos, perp_market_oracle_infos, spot_market_indexes = get_markets_and_oracles(perp_markets = perp_markets)\n\n    oracle_infos = spot_market_oracle_infos + perp_market_oracle_infos\n\n    drift_client = DriftClient(\n        connection,\n        wallet, \n        \"mainnet\",             \n        perp_market_indexes = perp_markets,\n        spot_market_indexes = spot_market_indexes,\n        oracle_infos = oracle_infos,\n        account_subscription = AccountSubscriptionConfig(\"demo\"),\n    )\n    await drift_client.subscribe()\n```\nIf you intend to use `AccountSubscriptionConfig(\"demo)`, you *must* call `get_markets_and_oracles` to get the information you need.\n\n`get_markets_and_oracles` will return all the necessary `OracleInfo`s and `market_indexes` in order to use the SDK.\n\n# Development\n\n## Setting Up Dev Env\n\n`bash setup.sh`\n\n\nEnsure correct python version (using pyenv is recommended):\n```bash\npyenv install 3.10.11\npyenv global 3.10.11\npoetry env use $(pyenv which python)\n```\n\nInstall dependencies:\n```bash\npoetry install\n```\n\nTo run tests, first ensure you have set up the RPC url, then run `pytest`:\n```bash\nexport MAINNET_RPC_ENDPOINT=\"\u003cYOUR_RPC_URL\u003e\"\nexport DEVNET_RPC_ENDPOINT=\"https://api.devnet.solana.com\" # or your own RPC\n\npoetry run pytest -v -s -x tests/ci/*.py\npoetry run pytest -v -s tests/math/*.py\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrift-labs%2Fdriftpy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdrift-labs%2Fdriftpy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrift-labs%2Fdriftpy/lists"}