|
| 1 | +name: LongBridge API Probe |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + qpk_ref: |
| 7 | + description: "QuantPlatformKit ref containing the probe test" |
| 8 | + required: false |
| 9 | + default: "main" |
| 10 | + type: string |
| 11 | + symbol: |
| 12 | + description: "US symbol to use for the probe" |
| 13 | + required: false |
| 14 | + default: "SOXX.US" |
| 15 | + type: string |
| 16 | + limit_price: |
| 17 | + description: "Low buy limit price used by the cancellable probe order" |
| 18 | + required: false |
| 19 | + default: "0.01" |
| 20 | + type: string |
| 21 | + |
| 22 | +env: |
| 23 | + GCP_PROJECT_ID: longbridgequant |
| 24 | + GCP_WORKLOAD_IDENTITY_PROVIDER: projects/252919773759/locations/global/workloadIdentityPools/github-actions/providers/github-main |
| 25 | + GCP_WORKLOAD_IDENTITY_SERVICE_ACCOUNT: longbridge-platform-deploy@longbridgequant.iam.gserviceaccount.com |
| 26 | + |
| 27 | +jobs: |
| 28 | + hk-fractional-order: |
| 29 | + name: Probe HK Simulated Fractional Orders |
| 30 | + runs-on: ubuntu-latest |
| 31 | + permissions: |
| 32 | + contents: read |
| 33 | + id-token: write |
| 34 | + environment: longbridge-hk |
| 35 | + env: |
| 36 | + LONGPORT_APP_KEY_SECRET_NAME: ${{ vars.LONGPORT_APP_KEY_SECRET_NAME }} |
| 37 | + LONGPORT_APP_SECRET_SECRET_NAME: ${{ vars.LONGPORT_APP_SECRET_SECRET_NAME }} |
| 38 | + LONGPORT_SECRET_NAME: ${{ vars.LONGPORT_SECRET_NAME }} |
| 39 | + steps: |
| 40 | + - name: Validate inputs |
| 41 | + run: | |
| 42 | + set -euo pipefail |
| 43 | +
|
| 44 | + missing_vars=() |
| 45 | + for var_name in LONGPORT_APP_KEY_SECRET_NAME LONGPORT_APP_SECRET_SECRET_NAME LONGPORT_SECRET_NAME; do |
| 46 | + if [ -z "${!var_name:-}" ]; then |
| 47 | + missing_vars+=("${var_name}") |
| 48 | + fi |
| 49 | + done |
| 50 | +
|
| 51 | + if [ "${#missing_vars[@]}" -gt 0 ]; then |
| 52 | + printf 'Missing longbridge-hk variables:\n' >&2 |
| 53 | + printf ' - %s\n' "${missing_vars[@]}" >&2 |
| 54 | + exit 1 |
| 55 | + fi |
| 56 | +
|
| 57 | + - name: Checkout QuantPlatformKit |
| 58 | + uses: actions/checkout@v6 |
| 59 | + with: |
| 60 | + repository: QuantStrategyLab/QuantPlatformKit |
| 61 | + ref: ${{ inputs.qpk_ref }} |
| 62 | + path: quant-platform-kit |
| 63 | + |
| 64 | + - name: Set up Python |
| 65 | + uses: actions/setup-python@v6 |
| 66 | + with: |
| 67 | + python-version: "3.12" |
| 68 | + |
| 69 | + - name: Authenticate to Google Cloud |
| 70 | + uses: google-github-actions/auth@v3 |
| 71 | + with: |
| 72 | + workload_identity_provider: ${{ env.GCP_WORKLOAD_IDENTITY_PROVIDER }} |
| 73 | + service_account: ${{ env.GCP_WORKLOAD_IDENTITY_SERVICE_ACCOUNT }} |
| 74 | + |
| 75 | + - name: Set up gcloud |
| 76 | + uses: google-github-actions/setup-gcloud@v3 |
| 77 | + with: |
| 78 | + project_id: ${{ env.GCP_PROJECT_ID }} |
| 79 | + version: ">= 416.0.0" |
| 80 | + |
| 81 | + - name: Export LongPort credentials |
| 82 | + run: | |
| 83 | + set -euo pipefail |
| 84 | +
|
| 85 | + longport_app_key="$(gcloud secrets versions access latest --secret="${LONGPORT_APP_KEY_SECRET_NAME}")" |
| 86 | + longport_app_secret="$(gcloud secrets versions access latest --secret="${LONGPORT_APP_SECRET_SECRET_NAME}")" |
| 87 | + longport_access_token="$(gcloud secrets versions access latest --secret="${LONGPORT_SECRET_NAME}")" |
| 88 | +
|
| 89 | + echo "::add-mask::${longport_app_key}" |
| 90 | + echo "::add-mask::${longport_app_secret}" |
| 91 | + echo "::add-mask::${longport_access_token}" |
| 92 | +
|
| 93 | + { |
| 94 | + echo "LONGPORT_APP_KEY=${longport_app_key}" |
| 95 | + echo "LONGPORT_APP_SECRET=${longport_app_secret}" |
| 96 | + echo "LONGPORT_ACCESS_TOKEN=${longport_access_token}" |
| 97 | + } >> "$GITHUB_ENV" |
| 98 | +
|
| 99 | + - name: Install probe dependencies |
| 100 | + run: | |
| 101 | + set -euo pipefail |
| 102 | +
|
| 103 | + python -m pip install --upgrade pip |
| 104 | + python -m pip install -e quant-platform-kit pytest longport |
| 105 | +
|
| 106 | + - name: Run HK simulated fractional order probe |
| 107 | + env: |
| 108 | + LONGBRIDGE_API_PROBE: "1" |
| 109 | + LONGBRIDGE_API_PROBE_SYMBOL: ${{ inputs.symbol }} |
| 110 | + LONGBRIDGE_API_PROBE_LIMIT_PRICE: ${{ inputs.limit_price }} |
| 111 | + run: | |
| 112 | + set -euo pipefail |
| 113 | +
|
| 114 | + python -m pytest quant-platform-kit/tests/test_longbridge_fractional_order_api_probe.py -q -s |
0 commit comments