Main Menu
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - alt

#1
中文 (Chinese) / 关于BTS的应用推广
September 12, 2026, 02:24:14 AM
BTS这么多年不好推广的原因之一是没有一个好的前端,使用不太方便。
BTSBots通过数据的整合重构,实现了一套高效的基于 websocket 接口的架构。
既保留了区块链的高安全性,又提供了很高的易用性。

有兴趣推广BTS的朋友可以试用一下,利用BTSBots来推广BTS的使用。
BTSBots在其中所有环节没占有任何私利,比如推荐码注册,所有分红是100%属于推广人的。

另外BTSBots承诺在社区成熟后,会开源所有后端代码。
目前开放的3部分前端代码,任何人可以完全重构包装成自己的APP。
#2
中文 (Chinese) / BTSBots增加AI交易agent
September 10, 2026, 04:10:27 AM
https://github.com/pch957/btsbots/blob/main/TradeBots.md
BTSBots增加AI交易agent
demo.btsbots在 XBTSX.USDT/BTS 市场测试,使用的 gemini-3.5-flash-lite 模型

  • 正在连接 Meteor 节点: wss://ws.btsbots.com/websocket
    🔌[DDP 协议] 连接已激活。
    🔑[等待登陆] 未登陆,等待认证...
    ✓ [BotsKey] 从 pass 成功载入账号 [demo.btsbots] 及其关联的 2 把 Key。
    ✓ [BotsClient] 登录成功!
    🔄 [配置更新] 成功载入策略 [ai_agent]: 基于 Google AI Studio (Gemini 2.0) / OpenAI 的全自主量化交易 Agent (支持吃单与做
    市)

    🚀 [TradeBots] 机器人引擎就绪!策略: [ai_agent] | 监听账户: [demo.btsbots]

    ======================================================================
    📊 [BTSBots AI Agent] 负责市场历史成交统计与盈亏看板 (PnL Dashboard)
    ======================================================================
    • 负责市场范围: [('BTS', 'XBTSX.USDT'), ('XBTSX.USDT', 'BTS')]
    • 撮合成交总笔数: 16 笔
    • 累计成交换手额: 449.86 CNY
    • 累计法币净盈亏: 🔴 -5.47 CNY
    • 各代币累计净流动明细:
        └─ BTS       : -34678.5170 (公允折合: -349.65 CNY)
        └─ XBTSX.USDT: +51.8450 (公允折合: +344.17 CNY)
    ======================================================================

    💓 [Pulse] 区块 #114230048 | 2026-09-10 13:52:48
    🧠 [AI Agent 思考分析] [区块 #114230049]
       └─ 补齐BTS市场做市挂单
       🛡️ [风控拦截] 严重警告: 报价 0.00157960 偏离公允价 0.00151879 超过 2.0% 红线 -> 自动修正到安全区间

    📡 [触发 AI 决策] [区块 #114230049] 原因: 检测到有充足余额的市场缺失挂单 ['BTS/XBTSX.USDT'],强制唤醒 AI 建立流动
    性


    # 🤖 BTSBots TradeBots 开发者与量化策略指南

    `TradeBots` 是专为 BitShares(比特股)DEX 量化交易与做市设计的 Python 自动化交易框架。它深度集成了 Meteor DDP 实时数据流、BitShares 原生高效订单修改操作(OP 77,无需撤单即可直改价格与数量)以及零信任密钥管理。

    ---

    ## 🚀 快速上手

    ### 启动量化与 AI Agent 策略机器人

    ```bash
    # 1. 启动 AI 自主交易 Agent 机器人 (支持 Google AI Studio / OpenAI / DeepSeek / Ollama)
    GEMINI_API_KEY="AIzaSy..." uv run trade_bots_ai.py --pass btsbots/my_account --strategy ai_agent

    # 2. 启动简单法定做市策略 (SimpleMaker)
    uv run trade_bots.py --pass btsbots/my_account --strategy simple

    # 3. 启动动态自适应多档网格策略 (DynamicGrid - 震荡收割机)
    uv run trade_bots_grid.py --pass btsbots/my_account --strategy grid

    # 4. 启动通用 N 环路原子无损套利策略 (UniversalArbitrage - 负对数图算法)
    uv run trade_bots_arbitrage.py --pass btsbots/my_account --strategy arbitrage

    # 5. 启动布林带均值回归做市策略 (BollingerMeanReversion)
    uv run trade_bots_bollinger.py --pass btsbots/my_account --strategy bollinger
    ```

    ---

    ## 🧠 AI 自主交易 Agent (`trade_bots_ai.py`)

    `AITradingAgent` 将大语言模型(LLM)与去中心化区块链高频交易引擎深度结合,为 AI 提供 360° 结构化全景市场决策上下文,并由底层的零信任硬风控护栏(Guardrails)确保每一笔链上操作的安全合规。

    ### 1. 核心架构与决策流

    ```text
           ┌────────────────────────────────────────────────────────┐
           │               Meteor DDP 实时行情与成交流               │
           └───────────────────────────┬────────────────────────────┘
                                       │
           ┌───────────────────────────▼────────────────────────────┐
           │            360° 全景市场上下文构建器 (Context)           │
           │  • 负责市场资产画像、余额与持仓上限 (Max Holding CNY)  │
           │  • Top 5 盘口深度、微观流动性与单价物理单位 (Price Unit)│
           │  • 历史成交记录与法定 CNY 实时盈亏看板 (PnL Tracker)   │
           │  • 市场双向缺口与在单残缺度诊断 (Coverage & Health)    │
           │  • 动态库存倾斜加价指导 (Dynamic Inventory Skew)       │
           └───────────────────────────┬────────────────────────────┘
                                       │ JSON 提示词
           ┌───────────────────────────▼────────────────────────────┐
           │               主流 LLM 决策推理引擎                    │
           │     (Gemini 2.0 / GPT-4o / DeepSeek / Ollama)          │
           └───────────────────────────┬────────────────────────────┘
                                       │ 输出 JSON 意向 (Intents)
           ┌───────────────────────────▼────────────────────────────┐
           │             🛡️ 零信任硬风控护栏 (Guardrails)            │
           │  • 市场范围锁 (Market Scoping Guard: 彻底隔离无关市场) │
           │  • 法币下单额度硬截断熔断 (target_order_cny Cap)        │
           │  • 最大持仓上限拦截 (max_holding_cny)                  │
           │  • 双向价差保底锁 (Anti Self-Match: 严禁平价自成交)    │
           │  • 冗余重复挂单自动清理撤单                            │
           └───────────────────────────┬────────────────────────────┘
                                       │ 原子打包提交
           ┌───────────────────────────▼────────────────────────────┐
           │         BitShares 区块链原生广播 (OP 77 / OP 1)        │
           └────────────────────────────────────────────────────────┘
    ```

    ### 2. AI Agent 五大核心技术优势
    - **免费 Google AI Studio 原生支持**:使用 `gemini-2.0-flash` 模型,高吞吐低延迟,免去高昂 API 费用。
    - **智能自主门控与静默心跳(Gating & Pulse Heartbeat)**:仅在发生缺单、在单被吃超 50%、价格变动等实质信号时才唤醒 AI;平稳时终端保持单行脉冲心跳,绝不刷屏。
    - **动态库存倾斜(Dynamic Inventory Skew)**:越接近设定的资产持仓上限,买入挂单价格向下偏离折价越多;未设上限则视为无上限。
    - **多资产法定盈亏看板(PnL Dashboard)**:启动即自动汇总结算负责市场的撮合成交笔数、累计换手额与净盈亏。
    - **单价物理单位防混淆**:明确区分 `A/B` 市场单价单位为 `B per 1 A`,彻底避免买卖单数值颠倒错单。

    ---

    ## 📊 经典交易策略与数学原理

    ### 1. 简单法定做市 (`SimpleMaker` / `trade_bots.py`)
    - **场景**:日常做市、提供双向流动性。
    - **原理**:基于资产的法定公允价格(或自定义锚定比率)计算理论中间价,向上加价 `maker_spread%` 挂单,同时设置严格的 Maker 防吃单保护。

    ### 2. 动态多档网格策略 (`DynamicGrid` / `trade_bots_grid.py`)
    - **场景**:宽幅震荡行情。
    - **原理**:自适应盘口中间价 $P_{\text{mid}} = \frac{P_{\text{ask1}} + P_{\text{bid1}}}{2}$ 作为中轴,按等比步长铺设 $N$ 档网格,买卖双向严格受 Maker 边界保护(买单不高过卖一,卖单不低过买一),利用 **OP 77 动态平移网格档位**。

    ### 3. 通用 $N$ 环路原子无损套利 (`UniversalArbitrage` / `trade_bots_arbitrage.py`)
    - **场景**:跨币种环路价差套利(自动发现 2 环、3 环、4 环机会)。
    - **负对数图算法优化**:
      $$\prod_{i=1}^k P_i > 1 \iff \sum_{i=1}^k -\ln(P_i) < 0$$
      将各市场的最优兑换汇率转换为有向图边权重 $-\ln(P)$,通过**负权环路探测算法**在毫秒级内自动寻优。
    - **原子事务**:将整个闭环的 $N$ 笔操作打包在同一个区块链 Transaction 内原子提交,零滑点零单边风险。

    ### 4. 布林带均值回归做市 (`BollingerMeanReversion` / `trade_bots_bollinger.py`)
    - **场景**:波动率扩张与均值回归行情。
    - **原理**:实时统计滑动采样均线(MA)与标准差 $\sigma$,在上轨超买区与下轨超卖区挂单做市,赚取波动率收缩利润。

    ---

    ## ⚙️ 配置文件说明 (`trade_rules.json` / `trade_rules-example.json`)

    ```json
    {
      "strategies": {
        "ai_agent": {
          "strategy_name": "AITradingAgent",
          "description": "基于 Google AI Studio / OpenAI 的全自主量化交易 Agent",
          "block_delay": 1.0,
          "keep_bts_fees": 30.0,
          "max_holding_cny": {
            "XBTSX.USDT": 2000.0,
            "CNY": 5000.0,
            "BTS": 10000.0
          },
          "ai_agent": {
            "provider": "gemini",
            "model": "gemini-2.0-flash",
            "api_base": "https://generativelanguage.googleapis.com/v1beta/openai/",
            "api_key": "YOUR_GEMINI_API_KEY",
            "max_price_deviation_pct": 15.0,
            "min_maker_spread_pct": 1.5
          },
          "custom_price": { "CNY": [13.597625854, "BTS"] },
          "default": { "target_order_cny": 50.0 },
          "markets": [["BTS", "CNY"], ["BTS", "XBTSX.USDT"]]
        },
        "simple": {
          "strategy_name": "SimpleMaker",
          "description": "基于公允法定价值 (CNY) 的简单做市策略",
          "block_delay": 1.0,
          "keep_bts_fees": 20.0,
          "custom_price": { "CNY": [16.0, "BTS"] },
          "default": { "freq": 2, "maker_spread": 1.5, "target_order_cny": 50.0 },
          "markets": [["BTS", "CNY"], ["BTS", "USD"]]
        },
        "grid": {
          "strategy_name": "DynamicGrid",
          "description": "多档动态等比网格策略",
          "block_delay": 1.0,
          "keep_bts_fees": 20.0,
          "custom_price": { "CNY": [16.0, "BTS"], "USD": [7.0, "CNY"] },
          "default": {
            "freq": 2,
            "grid_levels": 3,
            "grid_step_pct": 1.2,
            "target_order_cny_per_grid": 30.0
          },
          "markets": [["BTS", "CNY"], ["BTS", "USD"]]
        },
        "arbitrage": {
          "strategy_name": "UniversalArbitrage",
          "description": "通用 N 环路原子无损套利策略",
          "block_delay": 0.5,
          "keep_bts_fees": 30.0,
          "min_profit_pct": 0.5,
          "trade_amount_cny": 100.0,
          "max_cycle_length": 4,
          "markets": [["BTS", "CNY"], ["BTS", "USD"], ["CNY", "USD"]]
        },
        "bollinger": {
          "strategy_name": "BollingerMeanReversion",
          "description": "布林带均值回归做市策略",
          "block_delay": 1.0,
          "keep_bts_fees": 20.0,
          "custom_price": { "CNY": [16.0, "BTS"] },
          "default": { "freq": 2, "window_size": 20, "k_std": 2.0, "target_order_cny": 50.0 },
          "markets": [["BTS", "CNY"], ["BTS", "USD"]]
        }
      }
    }
    ```

    ---

    ## 🛠️ 二次开发指南

    ### 1. 核心数据查询 API

    | 接口名称 | 参数 | 返回值 | 说明 |
    | :--- | :--- | :--- | :--- |
    | `self.get_price(asset)` | `asset: str` | `float` | 获取资产公允定价(支持 `custom_price` 链式锚定换算) |
    | `self.get_free_balance(asset)` | `asset: str` | `float` | 获取资产可用余额(若为 BTS 已自动扣除保留的手续费) |
    | `self.get_total_balance(asset)` | `asset: str` | `float` | 获取资产总持仓(空闲余额 + 在单资产) |
    | `self.get_my_orders(sell, recv)`| `sell, recv: Optional[str]` | `List[dict]` | 获取当前账号在指定方向上的有效挂单(已清洗 order_id) |
    | `self.get_market_orders(sell, recv)` | `sell, recv: str` | `List[dict]` | 获取市场上除自身以外的盘口深度订单列表(按单价升序) |
    | `self.calculate_market_pnl(markets)` | `markets: Optional
      ` | `dict` | 统计指定市场的成交笔数、换手额及法定净盈亏 |
      | `self.get_order_by_id(order_id)` | `order_id: str` | `Optional[dict]` | 根据订单 ID 检索订单完整详情 |
      | `self.is_chain_synced()` | 无 | `Tuple[bool, delay, ts]`| 检查区块链时钟是否正常同步(30 秒容差) |

      ---

      ### 2. 极简订单意向提交接口 (`apply_order_intents`)

      #### ① 取消订单 (`cancel`)
      ```python
      {"action": "cancel", "order_id": "1.7.573627825", "reason": "清理冗余订单"}
      ```

      #### ② 修改订单 (`update` - 原生 OP 77,极简入参)
      ```python
      # 仅需传入 order_id 与期望的目标新值,底层自动计算 Delta 与在单基数
      {"action": "update", "order_id": "1.7.573174054", "price": 0.0754, "amount": 1000.0}

      # 或仅改价格:
      {"action": "update", "order_id": "1.7.573174054", "price": 0.0754}

      # 或仅改数量:
      {"action": "update", "order_id": "1.7.573174054", "amount": 1000.0}
      ```

      #### ③ 新建挂单 (`create`)
      ```python
      {
          "action": "create",
          "sell_asset": "BTS",
          "receive_asset": "CNY",
          "amount": 500.0,
          "price": 0.0754,
          "reason": "初始流动性挂单"
      }
      ```

      ---

      ### 3. 自定义策略完整编写范例

      ```python
      import asyncio
      from typing import List, Dict, Any, Optional
      from btsbots.tradebots import TradeBots

      class MyCustomBot(TradeBots):
          async def calculate_strategy(self, block_num: int) -> Optional
    [List[Dict[str, Any]]]:
            intents = []
           
            for (a_s, a_b), m_cfg in self.markets_config.items():
                freq = int(m_cfg.get("freq", 1))
                if (block_num % freq) != 0:
                    continue

                p_s = self.get_price(a_s)
                p_b = self.get_price(a_b)
                if p_s <= 0 or p_b <= 0:
                    continue

                fair_price = p_s / p_b
                spread_pct = float(m_cfg.get("maker_spread", 1.5)) / 100.0
                target_price = fair_price * (1.0 + spread_pct)

                target_cny = float(m_cfg.get("target_order_cny", 50.0))
                target_amount = target_cny / p_s

                my_orders = self.get_my_orders(a_s, a_b)
                if my_orders:
                    primary = my_orders[0]
                    curr_p = float(primary.get("p", 0.0))
                   
                    # 偏离超过 0.5% 则极简更新订单
                    if abs(curr_p - target_price) / target_price > 0.005:
                        intents.append({
                            "action": "update",
                            "order_id": primary["order_id"],
                            "price": target_price,
                            "amount": target_amount,
                            "reason": "跟随行情调价"
                        })
                else:
                    free_b = self.get_free_balance(a_s)
                    if free_b >= (target_amount * 0.1):
                        intents.append({
                            "action": "create",
                            "sell_asset": a_s,
                            "receive_asset": a_b,
                            "amount": min(free_b, target_amount),
                            "price": target_price,
                            "reason": "初始做市挂单"
                        })

            return intents if intents else None

    async def main():
        bot = MyCustomBot(config_path="trade_rules.json", strategy_name="simple")
        try:
            await bot.run()
            while True:
                await asyncio.sleep(1)
        finally:
            await bot.close()

    if __name__ == "__main__":
        asyncio.run(main())
    ```
#3
https://github.com/pch957/btsbots/blob/main/TradeBots.md

🤖 BTSBots TradeBots 开发者与量化策略指南

TradeBots 是专为 BitShares(比特股)DEX 量化交易与做市设计的 Python 自动化交易框架。它深度集成了 Meteor DDP 实时数据流、BitShares 原生高效订单修改操作(OP 77,无需撤单即可直改价格与数量)以及零信任密钥管理。
🚀 快速上手
启动内置量化策略机器人

# 1. 简单法定做市策略 (SimpleMaker)
uv run trade_bots.py --pass btsbots/my_account --strategy simple

# 2. 动态自适应多档网格策略 (DynamicGrid - 震荡收割机)
uv run trade_bots_grid.py --pass btsbots/my_account --strategy grid

# 3. 通用 N 环路原子无损套利策略 (UniversalArbitrage - 负对数图算法)
uv run trade_bots_arbitrage.py --pass btsbots/my_account --strategy arbitrage

# 4. 布林带均值回归做市策略 (BollingerMeanReversion)
uv run trade_bots_bollinger.py --pass btsbots/my_account --strategy bollinger

📊 经典交易策略与数学原理
1. 简单法定做市 (SimpleMaker / trade_bots.py)

    场景:日常做市、提供双向流动性。
    原理:基于资产的法定公允价格(或自定义锚定比率)计算理论中间价,向上加价 maker_spread% 挂单,同时设置严格的 Maker 防吃单保护。

2. 动态多档网格策略 (DynamicGrid / trade_bots_grid.py)

    场景:宽幅震荡行情。
    原理:自适应盘口中间价 P mid = P ask1 + P bid1 2 作为中轴,按等比步长铺设 N 档网格,买卖双向严格受 Maker 边界保护(买单不高过卖一,卖单不低过买一),利用 OP 77 动态平移网格档位。

3. 通用 N 环路原子无损套利 (UniversalArbitrage / trade_bots_arbitrage.py)

    场景:跨币种环路价差套利(自动发现 2 环、3 环、4 环机会)。
    负对数图算法优化: ∏ i = 1 k P i > 1 ⟺ ∑ i = 1 k − ln ⁡ ( P i ) < 0 将各市场的最优兑换汇率转换为有向图边权重 − ln ⁡ ( P ) ,通过负权环路探测算法在毫秒级内自动寻优。
    原子事务:将整个闭环的 N 笔操作打包在同一个区块链 Transaction 内原子提交,零滑点零单边风险。

4. 布林带均值回归做市 (BollingerMeanReversion / trade_bots_bollinger.py)

    场景:波动率扩张与均值回归行情。
    原理:实时统计滑动采样均线(MA)与标准差 σ ,在上轨超买区与下轨超卖区挂单做市,赚取波动率收缩利润。

⚙️ 配置文件说明 (trade_rules.json)

{
  "strategies": {
    "simple": {
      "strategy_name": "SimpleMaker",
      "description": "基于公允法定价值 (CNY) 的简单做市策略",
      "block_delay": 1.0,
      "keep_bts_fees": 20.0,
      "custom_price": { "CNY": [16.0, "BTS"] },
      "default": { "freq": 2, "maker_spread": 1.5, "target_order_cny": 50.0 },
      "markets": [["BTS", "CNY"], ["BTS", "USD"]]
    },
    "grid": {
      "strategy_name": "DynamicGrid",
      "description": "多档动态等比网格策略",
      "block_delay": 1.0,
      "keep_bts_fees": 20.0,
      "custom_price": { "CNY": [16.0, "BTS"], "USD": [7.0, "CNY"] },
      "default": {
        "freq": 2,
        "grid_levels": 3,
        "grid_step_pct": 1.2,
        "target_order_cny_per_grid": 30.0
      },
      "markets": [["BTS", "CNY"], ["BTS", "USD"]]
    },
    "arbitrage": {
      "strategy_name": "UniversalArbitrage",
      "description": "通用 N 环路原子无损套利策略",
      "block_delay": 0.5,
      "keep_bts_fees": 30.0,
      "min_profit_pct": 0.5,
      "trade_amount_cny": 100.0,
      "max_cycle_length": 4,
      "markets": [["BTS", "CNY"], ["BTS", "USD"], ["CNY", "USD"]]
    },
    "bollinger": {
      "strategy_name": "BollingerMeanReversion",
      "description": "布林带均值回归做市策略",
      "block_delay": 1.0,
      "keep_bts_fees": 20.0,
      "custom_price": { "CNY": [16.0, "BTS"] },
      "default": { "freq": 2, "window_size": 20, "k_std": 2.0, "target_order_cny": 50.0 },
      "markets": [["BTS", "CNY"], ["BTS", "USD"]]
    }
  }
}

🛠️ 二次开发指南
1. 核心数据查询 API
接口名称    参数    返回值    说明
self.get_price(asset)    asset: str    float    获取资产公允定价(支持 custom_price 链式锚定换算)
self.get_free_balance(asset)    asset: str    float    获取资产可用余额(若为 BTS 已自动扣除保留的手续费)
self.get_total_balance(asset)    asset: str    float    获取资产总持仓(空闲余额 + 在单资产)
self.get_my_orders(sell, recv)    sell, recv: Optional[str]    List[dict]    获取当前账号在指定方向上的有效挂单(已清洗 order_id)
self.get_market_orders(sell, recv)    sell, recv: str    List[dict]    获取市场上除自身以外的盘口深度订单列表(按单价升序)
self.get_order_by_id(order_id)    order_id: str    Optional[dict]    根据订单 ID 检索订单完整详情
self.is_chain_synced()    无    Tuple[bool, delay, ts]    检查区块链时钟是否正常同步(30 秒容差)
2. 极简订单意向提交接口 (apply_order_intents)
① 取消订单 (cancel)

{"action": "cancel", "order_id": "1.7.573627825", "reason": "清理冗余订单"}

② 修改订单 (update - 原生 OP 77,极简入参)

# 仅需传入 order_id 与期望的目标新值,底层自动计算 Delta 与在单基数
{"action": "update", "order_id": "1.7.573174054", "price": 0.0754, "amount": 1000.0}

# 或仅改价格:
{"action": "update", "order_id": "1.7.573174054", "price": 0.0754}

# 或仅改数量:
{"action": "update", "order_id": "1.7.573174054", "amount": 1000.0}

③ 新建挂单 (create)

{
    "action": "create",
    "sell_asset": "BTS",
    "receive_asset": "CNY",
    "amount": 500.0,
    "price": 0.0754,
    "reason": "初始流动性挂单"
}

3. 自定义策略完整编写范例

import asyncio
from typing import List, Dict, Any, Optional
from btsbots.tradebots import TradeBots

class MyCustomBot(TradeBots):
    async def calculate_strategy(self, block_num: int) -> Optional[List[Dict[str, Any]]]:
        intents = []
       
        for (a_s, a_b), m_cfg in self.markets_config.items():
            freq = int(m_cfg.get("freq", 1))
            if (block_num % freq) != 0:
                continue

            p_s = self.get_price(a_s)
            p_b = self.get_price(a_b)
            if p_s <= 0 or p_b <= 0:
                continue

            fair_price = p_s / p_b
            spread_pct = float(m_cfg.get("maker_spread", 1.5)) / 100.0
            target_price = fair_price * (1.0 + spread_pct)

            target_cny = float(m_cfg.get("target_order_cny", 50.0))
            target_amount = target_cny / p_s

            my_orders = self.get_my_orders(a_s, a_b)
            if my_orders:
                primary = my_orders[0]
                curr_p = float(primary.get("p", 0.0))
               
                # 偏离超过 0.5% 则极简更新订单
                if abs(curr_p - target_price) / target_price > 0.005:
                    intents.append({
                        "action": "update",
                        "order_id": primary["order_id"],
                        "price": target_price,
                        "amount": target_amount,
                        "reason": "跟随行情调价"
                    })
            else:
                free_b = self.get_free_balance(a_s)
                if free_b >= (target_amount * 0.1):
                    intents.append({
                        "action": "create",
                        "sell_asset": a_s,
                        "receive_asset": a_b,
                        "amount": min(free_b, target_amount),
                        "price": target_price,
                        "reason": "初始做市挂单"
                    })

        return intents if intents else None

async def main():
    bot = MyCustomBot(config_path="trade_rules.json", strategy_name="simple")
    try:
        await bot.run()
        while True:
            await asyncio.sleep(1)
    finally:
        await bot.close()

if __name__ == "__main__":
    asyncio.run(main())
#4
Btsbots发布windows版本app和签名网关
不会装 python 的可以用这个代替,也是冷钱包的安全性,密钥不上网。

https://github.com/pch957/btsbots-service/releases/tag/v0.0.1
https://github.com/pch957/btsbots-frontend/releases
#6
btsbots python端新增推荐码和小额支付功能
详细内容参考 github 说明文档
https://github.com/pch957/btsbots

章节二:sign_bots 网关风控策略与"联名信用卡"银行模式

为了让您的主私钥永远不暴露在网页端,同时满足多样化的日常转账与交易需求,btsbots 的签名网关 (sign_bots.py) 提供了一套企业级的零信任风控策略引擎。

您可以将这套系统类比为**"自己当中央银行,给家人、小孩或不同设备发放联名信用卡"**:主私钥锁在您最安全的保险箱(主服务器或本地 PC)里,而给不同的手机、平板或分身设备赋予不同的"额度与权限"。
🛡️ 风控策略能实现哪些功能?

    设备权限隔离(Device Aliasing):不同的设备拥有截然不同的操作特权(如交易平板只能挂单撤单,核心钱包才能大额转账)。
    大额白名单转账(Unlimited Payments):只有授权的高级设备,才能向官方或受信的白名单收款账户(如交易所、固定的商业伙伴)发起大额转账。
    小额微支付与"联名信用卡"银行模式(Micro Payments & PIN):您可以给家人或小孩的手机设置小额联名卡权限,限制单笔、天累计、周累计上限。当小额支付触发安全阈值时,网关会要求在 App 弹窗输入 PIN 码 验证,输入正确即刻安全放行!
    防对倒刷单与价格偏离保护(Volatility Protection):自动比对历史滑动窗口的成交价格,防止手抖或网页被劫持产生恶意低卖高买。

3. 社区裂变与邀请码注册功能(含 BitShares 激励机制)
💡 BitShares 推荐人与分红激励机制介绍

比特股(BitShares)底层区块链拥有非常独特的原生裂变与推荐激励机制:

    当您作为**推荐人(Registrar / Referrer)**在链上为新用户注册账号时,新用户后续在比特股 DEX 进行交易所产生的所有交易手续费(Trading Fees),系统都会按照设定的比例(如 100%)自动返还给推荐人账号!
    此外,通过 btsbots 的邀请码系统,不仅能帮朋友享受最低费率的极速注册,还能让您建立属于自己的 Web3 社区推广飞轮,躺赚长期的链上生态红利。

🛠️ 如何操作:

    步骤 1:生成邀请码 运行邀请码管理工具为自己生成一个专属邀请码:

    uv run invitation_tool.py --action generate --pass btsbots/my_account

    查看名下所有邀请码的使用状态:

    uv run invitation_tool.py --action list --pass btsbots/my_account

    步骤 2:朋友使用邀请码注册账号 您的朋友拿到邀请码后,只需在本地运行注册引导工具:

    uv run registre_account.py --invite BTS-XXXX

        程序会引导朋友输入符合 BitShares 规范的最低费率用户名。
        自动在本地安全生成私钥对并提交至您的 sign_bots 网关。
        您的守护进程自动审核并代为在链上广播注册,同时将您设为推荐人和注册人。
        注册成功后,朋友的电脑上会生成专属凭证文件,引导其直接启动守护并登录 App!

#7
中文 (Chinese) / 发布 BTSBots 客户端
September 01, 2026, 04:18:35 AM
https://github.com/pch957/btsbots-frontend

BTSBots 客户端发布 v0.1 版本。

包含 linux 桌面和安卓手机客户端。
一个钱包,一个交易平台。

使用文档和开发文档,参考文章中心:
https://btsbots.com/docs/index.html
#8
https://link.coolguy.vip
本站使用著名的网址收藏开源项目 linkding 搭建。
认证系统基于标准的 nginx auth_request 模块。
使用 BTSBots 的OAuth 代理 biz_proxy 接入。
所有BTS账号免注册,免密码,一键登入。

biz_proxy 位于 btsbots 的 python 客户端,除了 nginx,所有网站都能通过它轻松接入 BTS 账号系统。
#9
欢迎来到 https://coolguy.vip 选购你喜欢的域名和邮箱!
现在3折出售中,一个域名只要300BTS!
免注册,使用BTSBots OAuth 扫码登陆,使用 BTSBots 支付网关快捷支付!
支付完成,域名和邮箱实时生效,投入使用!

关于 BTSBots的OAuth和支付网关接入的文档,正在整理中。
#10
论坛的朋友们,我已经找到了BTS的崛起之路。
有兴趣的朋友请密切关注BTSBots项目
接下去我会一步步给出答案
请大家拭目以待
这次的终点绝不是什么虚拟币泡沫,而是彻底发掘出BTS真实的价值,让所有人都知道什么是BTS。
#11
中文 (Chinese) / BTSBots 钱包发布
August 20, 2026, 09:18:31 AM
BTSBots钱包发布。
访问 https://wallet.btsbots.com
需要更新 python 客户端: https://github.com/pch957/btsbots

web端无密钥,不需要注册,OTP直接登陆。
支持收款账号白名单、收款码、扫码支付、锁屏、订单记录。






#12
中文 (Chinese) / 重开 btsbots.com
August 12, 2026, 06:54:25 AM
重开 btsbots.com
这次的重新设计,使得 btsbots.com 拥有和中心交易平台一样甚至更高的灵活度,同时具备和冷钱包同等的安全级别。

web端差不多可以正常使用了
用户登陆要再等几天,等我把 python 网关整理好发布。

系统是免注册的,服务器和web端不接触任何bitshares私钥。
用户在本地使用开源的 python 网关经私钥签名后登陆系统,获取otp一次性登陆密码后,在web端登陆。
web端登陆后会生成 web crypto 密钥,获得 python 网关代理的授权,之后就可以使用此密钥签名,请求python网关代理签名广播交易。
web crypto是浏览器直接支持的签名api,只能签名,私钥不对外暴露,保证了python网关授权的安全通信。
另外python网关有审计配置文件,设有公钥授权白名单、转账白名单,交易市场白名单等进一步的安全保证机制。

#13
中文 (Chinese) / DEX到底是不是伪需求?
October 08, 2019, 02:18:31 AM
BM是在13年门头沟跑路后决定开发BTS的,今天看来结果是远超预期,在效率、安全、用户体验各方面都有不错的表现。
但是从市场看,DEX似乎正在被抛弃,喊着去中心化口号的众多虚拟币粉丝,在明知CEX无监管暗箱操作情况下,义无反顾的投入其怀抱,对DEX不屑一顾。
不仅圈外,BTS社区也几乎一致认为DEX没有能力和CEX竞争。

这个根本的认识得不到改观,BTS发展必定受阻,各种市场活动包括做市机器人可能不会有太好的效果,事倍功半。

那么DEX相比CEX到底有哪些优势?这里说的DEX除了BTS原生token,还包括GDEX等网关平台。
我是绝对的DEX用户,继多年前质疑比特时代裸卖空后,至今从未使用过任何CEX交易,下面是我的一些体会。
1. 用户使用易用性。
近两年涌现了多种BTS手机app,比如鼓鼓钱包、GDEX、bts++,我试用下来都很优秀,和CEX比应该是不落后的。PC客户端是个短板,其实有个PC上WEB界面就好了,
官方那个客户端就不说了,浪费了很多开发资金却看不到希望。
2. 资金安全性。
资金安全是平台和用户都很关注的重点,这点上DEX相对CEX有很大的优势,体现在各个环节:
1) 用户认证。CEX用户被各种花式玩弄,平台可以直接操作用户账户、平台可能泄露用户秘钥、黑客破解用户账号,关键是用户无法分辨到底是哪个环节出问题,最后就是黑客背锅、自己背锅,反正平台不负责任。DEX用户认证只依赖私钥,这个信息是用户自己保存自己负责,不存在信任风险。
2) web 服务器安全。CEX都有web服务器,可能被黑客攻击,拿下web服务器权限就可以拿下用户权限。DEX的web服务器只提供web页面、公共api等服务,没有太多敏感信息,如果是通过 app 则连 web 服务器都不需要。
3) 充提安全。 CEX 充提服务依赖自己的数据库,通过数据库攻击可能攻击钱包充提服务,威胁虚拟币钱包的安全。DEX的充提服务依赖的是区块链上的转账数据,无法被攻击,外界无法获知处理充提服务的服务器在哪里。
3. 平台稳定性。
CEX对 DOS 攻击无法抵御,这是中心化服务的弱点。DEX 可以做到很好的防范DOS攻击,比如手机 app 可能只依赖公共api节点,而这些节点是可以自己建立的。
4. 资金证明
CEX资金证明很复杂,需要对服务器用户数据做hash并公示,还要对所有钱包地址公示。而DEX很简单,只需要对钱包地址公示,因为用户余额都是区块链上的公开数据。
5. 平台维护成本。
DEX平台维护成本相对CEX无限低,CEX服务器上敏感数据包括用户身份信息、交易数据库、钱包等等,而DEX公开的服务器上基本上都是公开信息。
6. 其它
DEX 用户可以享受更多功能,包括转账、红包、创建资产、更灵活的 api 接口等等。

终上所述,未来的趋势是DEX,在初期CEX会依赖暗箱操作获取暴利,而在成熟期回归服务之后,90%CEX会倒闭DEX会活的越来越好。
最后补充一句,不要再局限在bitCNY上了,DEX有太多的优势,它发展起来之后 bitCNY 才可能得到更好的使用。
#14
firstly, it's not good to increase witness from this way.
secondly, it's a  danger action to vote like this, when you or BEOS get more vote power, BEOS could take over the chain by add many self account as active witness.
lastly, you have a misunderstanding about the vote mechanism, when there are only 21 active witness, you can't add even 1 witness when you have already vote for more than 21 witness.
on the other hand, you can't reduce even 1 witness when you have already vote for less than 21 witness.

so vote for the one you support, not a random junk account please.
#15
General Discussion / lucky us, avoid from a disaster
April 23, 2019, 03:16:18 PM
becasue of this upgrade, we will get a wrong margin call price for each debt from the old api.
based on the BSIP, witness should protect black swan for CNY and USD, so they should give a feed price 10USD/BTS and 10CNY/BTS
this will destroy exist bitCNY and bitUSD, make it only worth around 0.1 FIAT CNY.
the godd thing is seems only gdex-witness run the black swan protect logic, we have avoid from this disaster.
#16
can you imagine one day when you open your bank application, try to transfer,
some random accounts  just appeared in your contract list,  even be filled in the 'transfer to' field automaticly?

this stupid problem still exist in this GUI from the beginning several years ago.
this really suporrised me when I finally try to upgrade GUI.

the users who have lost money because of this issue should sue the GUI team definitely.

#17
I guess we all known how important the feed price is for us, and it's one of the mainy jobs for the witness.
but crazybit give us a 'fake' feed price.
here is his logic as I observe today:
every 5 minutes, he will check if his price equal the finally feed price(median price of all feed price),
if it's not, he change his price to the median price.

This is a very stupid strategy, it's cheat.
what's the thought of those who support him as a witness?
#18
Meta / please stop PM me for vote support
December 27, 2018, 02:21:25 AM
sorry I will not reply any personal message for vote support.
it's not sometihing about personal relationship.
all my decision about vote only based on the public information.
and I will ignore any discussion from private group, if you want to get my support, please show more public activities.
#19
in fact we have a significant treasure, the fees as income now and the future income.

for now, people reagard 1 bitUSD as a real USD only when there are enough collateral support the debt.
1 bitUSD can't worth 1 real USD after the blackswan. but what if we accept 1 bitUSD as a real USD for all the fees?

evntually the committee can issue an asset called DEBTUSD, and promise to pay interest or buy back with future income.
then we can pay the workers with DEBTUSD, we can even get fund from DEBTUSD to help rescue blackswan.
#20
it's has been many days since BSIP42 be voted out,
you witness please stop manipulation the price, at least you need to make sure margin call sell price must lower than real market price at least 2%,
then the margin call order can be eatern, or maybe another black swan from BITCNY will comming soon.
#21
Sure they could have a small group for fast connection to maintain the network.
but excepet that, all other things should be talked in public. it's not their private things like how to handle the comming bitCNY black swan event.
I ask to forbiden this private talk, which they have already screw up bitUSD.
#22
As we have seen, xeroc who is the bigest proxy with about 150 millions shares,
But he is very lack of trade acknowledge, and it's his blind that lead to this black swan event directely.
there are many changce that we can fix it before this happen, but he is always blind and do nothing to help.

so we all have learned that how important that we need more wise vote proxy.
I would ask @stan or any other share holders, remove xeroc as your proxy,
give the trust to others more wise  like @thul3 @pc

Quote from: alt on November 25, 2018, 05:35:35 AM
Quote from: Thul3 on November 25, 2018, 12:10:20 AM
BitUSD has arround 12 pm triggered global settlement.Borrowing no more possible.
I'm sorry to the people who lost money because of this event.


congrats @xeroc
               @bitcrab
               @still
               @abit

Who were the main supporters of BSIP42 even seeing that open margin calls are not being eaten.
They just watched from the side doing NOTHING to rescue that situation but instead celebrate that BSIP42 ,Witnesses and themself as proxies have not being downvoted much because of the global settlement event and even making fun that DEX had today the highest volume.


You guys are disgusting
They made way more disgusting comments but i will make an article about it to settle up their actions and of witnesses who screwed up totaly.
the other three support manipulation because they have heavy short position.
xeroc is the most stupid one, without any trader knowledge but gain too many support through the proxy.
It's very important that we need tell more people how stupid xeroc are, and should remove him from the vote proxy. or he will do more stupid things in the future.

by the way, do you have any idea why the witness give bitUSD's feed price to real price suddenly while keep bitCNY as before?
I have mentioned them should give a feed price higher than global settle price to give more time to eatern the margin call order, but again they screw up it.
#23
no block generate from the witness anymore,
what happend?
#24
Quote from: alt on November 26, 2018, 07:28:29 PM
Quote from: abit on November 26, 2018, 06:09:26 PM
@alt if you really don't want bitcny to go GS (globally settle), you'd better vote for the witnesses who are feeding price higher than GS price, and don't vote for the witnesses who are feeding price lower than GS price. Of course, if you want GS, you can ignore this comment.

1. the best strategy is max(realprice, GS price)
2. the second is real price
3. the last is manupulation price
wirntess please give a feed price with strategy max(real price, GS price)
please leave your account name here if you agree and have done this.
I will vote for the first 9
others witness who still agree the BSIP 42 will never get my vote
#25
depends on no any response from the wintess. all smart asset include bitCNY bitUSD faced a coming black swan, or in another words, the collabrary can't pay their debt, 1 bitUSD can't buy BTS as same as a real USD dollar.
you'd be better tell all the users include some exchange the potencial risk.
it's a unhonest behave if you continue to give bitUSD to others don't know the risk.
it's a unhonest behave to ask others adopt bitUSD as a stable peg asset.
it's even worst to give a bonus to encourage others adopt bitUSD.

if you are an honest man, please stop any marketing for smart asset.
#26
are you still think you need to improve the stupid bsip42(market manipulation)?
come out to say what's your plan
and those voters/proxy who support bsip42, please come out to explain us what happend.
#27
Meta / do you have modify the trade logic in this fork?
December 20, 2017, 01:50:01 AM
I have a buy order at price 2.84

2.840 10000.0000 28405.0000 kaifeng9
2.840 969536.4689 2753532.0542 demo.btsbots
2.840 3038.1662 8628.5439 abcbts

there are 2.8M CNY margin call,
the margin call order not filled my buy order, but others more less price.
what have you done to the trade logic?
who will take responsibility to my lost?



12/20 12:38:06 2.833 16970.4275 48077.2211 xlggd tara
12/20 12:38:06 2.835 35263.8986 99973.1561 xlggd yxb
12/20 12:38:06 2.835 1763.6683 5000.0000 xlggd exchange.btsbots
12/20 12:38:06 2.839 352.1127 1000.0000 xlggd hsh19830907
12/20 12:38:06 2.840 100000.0000 284000.0000 xlggd ags
12/20 12:38:06 2.840 3521.1268 10000.0000 xlggd bts8129
12/20 12:38:06 2.840 35193.3518 99949.1228 xlggd yxb
12/20 12:38:06 2.840 50000.0000 142000.5000 xlggd
#28
General Discussion / to GOLD/SILVER/BTC holders
July 08, 2017, 01:24:49 AM
I saw big margin call had happen on these three market,
but the share holders seems refuse to take the 10% profit help others quit short position.

you need to know when the price continue drop, black swan will happen in these SILVER,
then these SILVER you hold will lose the value it can be.

sell your SILVER, take the 10% profit, this is what you should do, or your SILVER will not worth 1 real SILVER after the blackswan
#29
中文 (Chinese) / btsbots.com 代码
June 15, 2017, 01:22:43 PM
手机掉水里了,最近没办法上微信了,看到的朋友帮忙在微信群说一下

很早就答应要把 btsbots.com 代码开源,但是一直没找到时间整理
今天先把现有的代码开源供有需要的朋友参考,地址为:
https://github.com/pch957/btsbots-demo-2016

操作系统建议 ubuntu1604, 使用方法
1 安装 meteor
2 下载代码,安装 npm 包

cd btsbots-demo-2016; npm install

3 运行 meteor 服务端程序,默认端口为本机 3000 端口,运行成功之后通过浏览器访问本机 3000 端口可以看到页面,但是还没有数据。

cd btsbots-demo-2016; meteor run

4 使用 scripts 目录下的 python 脚本生成数据, 需要 python3,
1) 安装依赖 bts 包

pip3 install bts

2) 修改配置文件 config.json
一个是 mongodb 数据库,上面 meteor 启动后默认在 3001 端口开了个 mongodb 服务器。
一个是 witness_node api 地址,用来获取区块链数据
3) 初始化 balance, order 数据,只需要初始化运行一次
运行 python3 correct-balance.py config.json ,注意作为 demo 代码中我只获取了很少量的数据。
4) 实时监控历史记录、orderbook, balance 等数据
python3 monitor.py config.json
5) 处理统计数据:
python3 statistics.py config.json


这份代码中只有架构值得借鉴,其它部分都会重写。主要几个工作:
1. 优化 mongodb 数据以及索引
2. 实时监控脚本需要处理分叉,保证 balance , order book 正确无误
3. meteor UI 部分使用 reactjs 引擎重写,优化页面,减少订阅数据量
#30
General Discussion / why so many fork???
April 14, 2017, 12:59:03 AM
WHAT'S WRONG WITH YOU?
xeldal, fox, in.abit

86993ms th_a       witness.cpp:194               block_production_loo ] Not producing block because it isn't my turn
3387429ms th_a       application.cpp:523           handle_block         ] Got block: #15659043 time: 2017-04-14T00:56:27 latency: 436 ms from: xeldal  irreversible: 15659025 (-18)
3388105ms th_a       application.cpp:523           handle_block         ] Got block: #15659043 time: 2017-04-14T00:56:27 latency: 1112 ms from: xeldal  irreversible: 15659029 (-14)

3350376ms th_a       application.cpp:523           handle_block         ] Got block: #15659030 time: 2017-04-14T00:55:48 latency: 2356 ms from: fox  irreversible: 15659015 (-15)
3350472ms th_a       application.cpp:523           handle_block         ] Got block: #15659030 time: 2017-04-14T00:55:48 latency: 2479 ms from: fox  irreversible: 15659015 (-15)
3

3246353ms th_a       application.cpp:523           handle_block         ] Got block: #15658996 time: 2017-04-14T00:54:06 latency: 360 ms from: in.abit  irreversible: 15658978 (-18)
3246893ms th_a       application.cpp:523           handle_block         ] Got block: #15658996 time: 2017-04-14T00:54:06 latency: 900 ms from: in.abit  irreversible: 15658978 (-18)