TraderGPT

TraderGPT · Actions GPT

TraderGPT Repo-Driven Backend API

API schema for GPT to interact with GitHub repo files as backend data and logic.

  • POST /repo/files/readRead file content from repository
  • POST /repo/files/writeWrite content to a file in the repository
  • GET /repo/trade-labelsList all trade labels
  • POST /repo/trade-labelsAdd or update a trade label
  • GET /repo/sim-tradesList simulated trades
  • POST /repo/sim-tradesAdd or update a simulated trade
Schéma original API
{
  "openapi": "3.1.0",
  "info": {
    "title": "TraderGPT Repo-Driven Backend API",
    "version": "1.0.0",
    "description": "API schema for GPT to interact with GitHub repo files as backend data and logic."
  },
  "servers": [
    {
      "url": "https://api.yourdomain.com"
    }
  ],
  "security": [
    {
      "apiKeyAuth": []
    }
  ],
  "components": {
    "securitySchemes": {
      "apiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key"
      }
    },
    "schemas": {
      "TradeLabel": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "symbol": {
            "type": "string"
          },
          "time": {
            "type": "string"
          },
          "price": {
            "type": "number"
          },
          "type": {
            "type": "string",
            "enum": [
              "Entry",
              "Exit",
              "Stop Loss",
              "Take Profit",
              "Note"
            ]
          },
          "note": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "symbol",
          "time",
          "type"
        ]
      },
      "SimTrade": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "symbol": {
            "type": "string"
          },
          "side": {
            "type": "string",
            "enum": [
              "buy",
              "sell"
            ]
          },
          "qty": {
            "type": "number"
          },
          "price": {
            "type": "number"
          },
          "time": {
            "type": "string"
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "id",
          "symbol",
          "side",
          "qty",
          "price",
          "time"
        ]
      }
    }
  },
  "paths": {
    "/repo/files/read": {
      "post": {
        "summary": "Read file content from repository",
        "operationId": "readFile",
        "security": [
          {
            "apiKeyAuth": []
          }
        ],
        "requestBody": {
          "description": "File path to read",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "filePath": {
                    "type": "string",
                    "description": "Path to file in repo"
                  }
                },
                "required": [
                  "filePath"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "File content",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string",
                  "description": "Content of the file"
                }
              }
            }
          }
        }
      }
    },
    "/repo/files/write": {
      "post": {
        "summary": "Write content to a file in the repository",
        "operationId": "writeFile",
        "security": [
          {
            "apiKeyAuth": []
          }
        ],
        "requestBody": {
          "description": "File path and content to write",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "filePath": {
                    "type": "string"
                  },
                  "content": {
                    "type": "string"
                  },
                  "commitMessage": {
                    "type": "string"
                  }
                },
                "required": [
                  "filePath",
                  "content",
                  "commitMessage"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Write result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "commitSha": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/repo/trade-labels": {
      "get": {
        "summary": "List all trade labels",
        "operationId": "listTradeLabels",
        "security": [
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Array of trade labels",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TradeLabel"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "summary": "Add or update a trade label",
        "operationId": "addTradeLabel",
        "security": [
          {
            "apiKeyAuth": []
          }
        ],
        "requestBody": {
          "description": "Trade label data",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TradeLabel"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Trade label saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TradeLabel"
                }
              }
            }
          }
        }
      }
    },
    "/repo/sim-trades": {
      "get": {
        "summary": "List simulated trades",
        "operationId": "listSimTrades",
        "security": [
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Array of simulated trades",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/SimTrade"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "summary": "Add or update a simulated trade",
        "operationId": "addSimTrade",
        "security": [
          {
            "apiKeyAuth": []
          }
        ],
        "requestBody": {
          "description": "Simulated trade data",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SimTrade"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sim trade saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SimTrade"
                }
              }
            }
          }
        }
      }
    }
  }
}