PeerBerry SDK Skill
TL;DR Quick Start
- - Start with read-only calls first (
get_profile, get_overview, get_loans). - Use
Decimal for money and rates, never float. - Treat
purchase_loan as real-money action and gate it with DRY_RUN and MAX_ORDERS. - Use SDK filter arguments before local filtering (
min_interest_rate, countries, loan_types). - Catch specific auth/funds errors, then fall back to
PeerberryException.
Read-only starter:
CODEBLOCK0
Safe invest starter:
CODEBLOCK1
Core Purpose
INLINECODE12 is a Python wrapper around the PeerBerry investor API. In P2P lending, investors allocate capital across many loans (or loan fractions), receive principal and interest repayments over time, and manage risk through diversification and monitoring. PeerBerry provides marketplace access to these investor workflows, and this SDK converts them into programmable Python actions for analysis, automation, and operational control.
Scope / Non-goals
In scope:
- - Explain PeerBerry and P2P lending concepts in plain language.
- Generate and debug Python code using the real SDK method surface.
- Build read-only monitoring scripts and guarded investment automation.
- Help with filtering, paging, exports, and auth/token lifecycle patterns.
Out of scope:
- - Provide financial advice, suitability advice, or guaranteed-return claims.
- Promise profitability, safety, or future performance.
- Invent SDK methods that do not exist.
Request Classifier
Classify incoming requests and respond with the matching style:
- 1.
educational: user is new to P2P/PeerBerry.
- Explain concepts first, then provide read-only demo code.
- Load:
references/p2p-primer.md.
- 2.
read_only_coding: user wants portfolio/loan analytics.
- Provide runnable snippets with typed model handling.
- Load:
references/api-quickref.md.
- 3.
real_money_automation: user wants buy/invest flows.
- Add
DRY_RUN,
MAX_ORDERS, funds checks, and explicit risk labels.
- Load:
references/api-quickref.md and
references/task-recipes.md.
- 4.
debugging: user has errors/exceptions.
- Triage auth, enum inputs, filter metadata, then payload shape.
- Load:
references/api-quickref.md.
Prerequisites
- - Create and verify an investor account on the official PeerBerry website: .
- Use valid PeerBerry credentials (
email, password). - If account uses TOTP 2FA, provide
tfa_secret and install the otp extra. - Treat purchase actions as real-money operations.
Key Concepts & Objects
Primary entry point:
- -
PeerberryClient: high-level client for authentication, retrieval, and purchase actions.
Core model objects:
- -
Profile, Overview, Loan, LoanPage, InvestmentPage, Transaction, AccountSummary, PurchaseOrder.
Domain semantics:
- -
loan: marketplace listing that can be invested into. - INLINECODE38 : already-owned position in a loan.
- INLINECODE39 : accepted order result with
order_id (not settlement confirmation).
Installation & Authentication
Install:
CODEBLOCK2
Install with 2FA support:
CODEBLOCK3
Authenticate:
CODEBLOCK4
Core Functions & Common Workflows
Use this method map:
- - Profile and portfolio:
get_profile, get_overview, INLINECODE43 - Loan discovery:
get_loans, get_loans_page, INLINECODE46 - Purchase action: INLINECODE47
- Portfolio positions: INLINECODE48
- Cash flow and reporting:
get_transactions, INLINECODE50 - Exports:
get_mass_investments, INLINECODE52 - Metadata helpers:
get_countries, INLINECODE54
For signatures, enums, and exception patterns, load references/api-quickref.md.
For copy-paste user prompts and intent routing, load references/task-recipes.md.
Safety Defaults (Real-Money Flows)
Always apply unless the user explicitly overrides:
- - Default to read-only path first.
- Add
DRY_RUN = True for first run. - Set a hard cap with
MAX_ORDERS. - Skip records missing
loan_id. - Validate
available_to_invest >= ticket_size when field is present. - Stop on
InsufficientFunds. - Log each resulting
order_id.
Known SDK Quirks
- -
get_overview payload can be flat or nested under items. - INLINECODE65 internally paginates with max page size 40.
- INLINECODE66 defaults
group_guarantee=True. - Country/originator filters require display names from metadata helpers.
- Export methods return raw
bytes, not typed rows.
Reference Files (Progressive Loading)
Load only what is needed:
- Use for beginner education, plain-language explanations, and trust-first communication rules.
- Use for method signatures, accepted values, parameter semantics, exceptions, and debugging.
- Use for copy-paste prompts mapped to common investor intents.
Maintenance Contract
When SDK changes, update this skill in this order:
- 1. Verify method signatures and accepted values against:
-
src/peerberry_sdk/client.py
-
docs/api/client.md
- 2. Update
references/api-quickref.md first. - Update affected recipes in
references/task-recipes.md. - Keep this root
SKILL.md concise and routing-focused. - Re-check safety defaults for any new write action methods.
Project Resources
- - Repository:
- Docs index:
- Client API reference:
- Issues:
Skill Authoring References (March 2026)
- - OpenAI Academy skills guide:
- Anthropic memory guidance:
- GitHub Copilot custom instructions:
- OpenAI AGENTS.md spec:
PeerBerry SDK 技能
TL;DR 快速入门
- - 首先从只读调用开始(getprofile、getoverview、getloans)。
- 使用 Decimal 处理金额和利率,切勿使用 float。
- 将 purchaseloan 视为真实资金操作,并用 DRYRUN 和 MAXORDERS 加以防护。
- 在本地过滤之前,优先使用 SDK 过滤参数(mininterestrate、countries、loan_types)。
- 捕获特定的认证/资金错误,然后回退到 PeerberryException。
只读入门示例:
python
from peerberry_sdk import PeerberryClient
with PeerberryClient(email=YOUREMAIL, password=YOURPASSWORD) as api:
profile = api.get_profile()
overview = api.get_overview()
loans = api.get_loans(quantity=5)
print(profile.public_id)
print(overview.data.get(availableMoney, overview.data.get(items, {}).get(availableMoney)))
print([loan.loan_id for loan in loans])
安全投资入门示例:
python
from decimal import Decimal
from peerberry_sdk import PeerberryClient
DRY_RUN = True
MAX_ORDERS = 10
TICKET_SIZE = Decimal(10.00)
with PeerberryClient(email=YOUREMAIL, password=YOURPASSWORD) as api:
loans = api.getloans(quantity=50, mininterestrate=Decimal(9.5), excludeinvested_loans=True)
for idx, loan in enumerate(loans):
if idx >= MAXORDERS or loan.loanid is None:
break
if DRY_RUN:
print(f[DRYRUN] 将投资 {TICKETSIZE} 到贷款 {loan.loan_id})
continue
api.purchaseloan(loanid=loan.loanid, amount=TICKETSIZE)
核心目的
peerberry-sdk 是 PeerBerry 投资者 API 的 Python 封装。在 P2P 借贷中,投资者将资金分配到多个贷款(或贷款份额),随时间收回本金和利息还款,并通过分散投资和监控来管理风险。PeerBerry 为这些投资者工作流程提供市场接入,而本 SDK 将其转换为可编程的 Python 操作,用于分析、自动化和运营控制。
范围 / 非目标
范围内:
- - 用通俗语言解释 PeerBerry 和 P2P 借贷概念。
- 使用真实的 SDK 方法接口生成和调试 Python 代码。
- 构建只读监控脚本和受保护的投资自动化。
- 协助处理过滤、分页、导出以及认证/令牌生命周期模式。
范围外:
- - 提供财务建议、适当性建议或保证回报的声明。
- 承诺盈利能力、安全性或未来表现。
- 发明不存在的 SDK 方法。
请求分类器
对传入请求进行分类,并以匹配的风格响应:
- 1. educational:用户是 P2P/PeerBerry 新手。
- 先解释概念,然后提供只读演示代码。
- 加载:references/p2p-primer.md。
- 2. readonlycoding:用户需要投资组合/贷款分析。
- 提供带有类型化模型处理的可运行代码片段。
- 加载:references/api-quickref.md。
- 3. realmoneyautomation:用户需要买入/投资流程。
- 添加 DRY
RUN、MAXORDERS、资金检查以及明确的风险标签。
- 加载:references/api-quickref.md 和 references/task-recipes.md。
- 4. debugging:用户遇到错误/异常。
- 排查认证、枚举输入、过滤元数据,然后检查负载结构。
- 加载:references/api-quickref.md。
前提条件
- - 在官方 PeerBerry 网站创建并验证投资者账户:。
- 使用有效的 PeerBerry 凭据(email、password)。
- 如果账户使用 TOTP 双因素认证,请提供 tfa_secret 并安装 otp 扩展包。
- 将购买操作视为真实资金操作。
关键概念与对象
主要入口点:
- - PeerberryClient:用于认证、检索和购买操作的高级客户端。
核心模型对象:
- - Profile、Overview、Loan、LoanPage、InvestmentPage、Transaction、AccountSummary、PurchaseOrder。
领域语义:
- - loan:可供投资的市场挂牌项目。
- investment:已持有的贷款头寸。
- purchase order:已接受的订单结果,包含 order_id(非结算确认)。
安装与认证
安装:
bash
pip install peerberry-sdk
安装双因素认证支持:
bash
pip install peerberry-sdk[otp]
认证:
python
from peerberry_sdk import PeerberryClient
with PeerberryClient(email=YOUREMAIL, password=YOURPASSWORD) as api:
print(api.getprofile().publicid)
核心函数与常见工作流程
使用方法映射:
- - 个人资料与投资组合:getprofile、getoverview、getloyaltytier
- 贷款发现:getloans、getloanspage、getloandetails
- 购买操作:purchaseloan
- 投资组合持仓:getinvestments
- 现金流与报告:gettransactions、getaccountsummary
- 导出:getmassinvestments、getmasstransactions
- 元数据辅助:getcountries、getoriginators
有关签名、枚举和异常模式,请加载 references/api-quickref.md。
有关可复制粘贴的用户提示和意图路由,请加载 references/task-recipes.md。
安全默认设置(真实资金流程)
除非用户明确覆盖,否则始终应用:
- - 默认优先使用只读路径。
- 首次运行时添加 DRYRUN = True。
- 使用 MAXORDERS 设置硬上限。
- 跳过缺少 loanid 的记录。
- 当字段存在时,验证 availabletoinvest >= ticketsize。
- 遇到 InsufficientFunds 时停止。
- 记录每个生成的 order_id。
已知 SDK 特性
- - getoverview 的负载可以是扁平结构,也可以嵌套在 items 下。
- getloans 内部进行分页,最大页面大小为 40。
- getloans 默认 groupguarantee=True。
- 国家/发起人过滤器需要使用元数据辅助函数中的显示名称。
- 导出方法返回原始 bytes,而非类型化行。
参考文件(渐进式加载)
仅加载所需内容:
- - references/p2p-primer.md
- 用于初学者教育、通俗语言解释以及信任优先的沟通规则。
- - references/api-quickref.md
- 用于方法签名、可接受值、参数语义、异常和调试。
- - references/task-recipes.md
- 用于映射到常见投资者意图的可复制粘贴提示。
维护契约
当 SDK 发生变更时,按以下顺序更新本技能:
- 1. 根据以下内容验证方法签名和可接受值:
- src/peerberry_sdk/client.py
- docs/api/client.md
- 2. 首先更新 references/api-quickref.md。
- 更新 references/task-recipes.md 中受影响的配方。
- 保持此根 SKILL.md 简洁且专注于路由。
- 针对任何新的写入操作方法重新检查安全默认设置。
项目资源
- - 仓库:
- 文档索引:
- 客户端 API 参考:
- 问题反馈:
技能创作参考(2026 年 3 月)
- - OpenAI Academy 技能指南:
- Anthropic 记忆指导:
- GitHub Copilot 自定义指令:
- OpenAI AGENTS.md 规范: