external-adapters-js icon indicating copy to clipboard operation
external-adapters-js copied to clipboard

[OPDATA-3889] FTSE SFTP EA Downloading and Parsing

Open chray-zhang opened this issue 5 months ago • 2 comments

Closes https://smartcontract-it.atlassian.net/browse/OPDATA-3889

Description

  • Added transport with sftp connection
  • Added downloading file logic
  • Adding parsing and response of EA

Steps to Test

curl -X POST http://localhost:8080 \
  -H "Content-Type: application/json" \
  -d '{
    "id": "1",
    "data": {
      "endpoint": "ftse_sftp",
      "instrument": "FTSE100INDEX"
    }
  }' | jq
chrayzhang@MB-C3H04RT9WT ~ % curl -X POST http://localhost:8080 \
  -H "Content-Type: application/json" \
  -d '{
    "id": "1",
    "data": {
      "endpoint": "ftse_sftp",
      "instrument": "FTSE100INDEX"
    }
  }' | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   492  100   386  100   106  83931  23048 --:--:-- --:--:-- --:--:--  120k
{
  "data": {
    "result": {
      "indexCode": "UKX",
      "indexSectorName": "FTSE 100 Index",
      "numberOfConstituents": 100,
      "indexBaseCurrency": "GBP",
      "gbpIndex": 9195.66227592
    }
  },
  "statusCode": 200,
  "result": 9195.66227592,
  "timestamps": {
    "providerDataRequestedUnixMs": 1758082923233,
    "providerDataReceivedUnixMs": 1758082954116
  },
  "meta": {
    "adapterName": "FTSE_SFTP",
    "metrics": {
      "feedId": "{\"instrument\":\"ftse100index\"}"
    }
  }
}
chrayzhang@MB-C3H04RT9WT ~ % curl -X POST http://localhost:8080 \
  -H "Content-Type: application/json" \
  -d '{
    "id": "1",
    "data": {
      "endpoint": "ftse_sftp",
      "instrument": "Russell3000INDEX"
    }
  }' | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   453  100   343  100   110  99190  31810 --:--:-- --:--:-- --:--:--  147k
{
  "data": {
    "result": {
      "indexName": "Russell 3000® Index",
      "close": 3762
    }
  },
  "statusCode": 200,
  "result": {
    "indexName": "Russell 3000® Index",
    "close": 3762
  },
  "timestamps": {
    "providerDataRequestedUnixMs": 1758081524053,
    "providerDataReceivedUnixMs": 1758081538672
  },
  "meta": {
    "adapterName": "FTSE_SFTP",
    "metrics": {
      "feedId": "{\"instrument\":\"russell3000index\"}"
    }
  }
}
chrayzhang@MB-C3H04RT9WT ~ % curl -X POST http://localhost:8080 \
  -H "Content-Type: application/json" \
  -d '{
    "id": "1",
    "data": {
      "endpoint": "ftse_sftp",
      "instrument": "Russell2000INDEX"
    }
  }' | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   459  100   349  100   110   117k  37774 --:--:-- --:--:-- --:--:--  224k
{
  "data": {
    "result": {
      "indexName": "Russell 2000® Index",
      "close": 2403.03
    }
  },
  "statusCode": 200,
  "result": {
    "indexName": "Russell 2000® Index",
    "close": 2403.03
  },
  "timestamps": {
    "providerDataRequestedUnixMs": 1758081454432,
    "providerDataReceivedUnixMs": 1758081468618
  },
  "meta": {
    "adapterName": "FTSE_SFTP",
    "metrics": {
      "feedId": "{\"instrument\":\"russell2000index\"}"
    }
  }
}
chrayzhang@MB-C3H04RT9WT ~ % curl -X POST http://localhost:8080 \
  -H "Content-Type: application/json" \
  -d '{
    "id": "1",
    "data": {
      "endpoint": "ftse_sftp",
      "instrument": "Russell1000INDEX"
    }
  }' | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   459  100   349  100   110  81427  25664 --:--:-- --:--:-- --:--:--  112k
{
  "data": {
    "result": {
      "indexName": "Russell 1000® Index",
      "close": 3616.83
    }
  },
  "statusCode": 200,
  "result": {
    "indexName": "Russell 1000® Index",
    "close": 3616.83
  },
  "timestamps": {
    "providerDataRequestedUnixMs": 1758081384501,
    "providerDataReceivedUnixMs": 1758081401216
  },
  "meta": {
    "adapterName": "FTSE_SFTP",
    "metrics": {
      "feedId": "{\"instrument\":\"russell1000index\"}"
    }
  }
}

Quality Assurance

  • [ x] If a new adapter was made, or an existing one was modified so that its environment variables have changed, update the relevant infra-k8s configuration file.
  • [x ] If a new adapter was made, or an existing one was modified so that its environment variables have changed, update the relevant adapter-secrets configuration file or update the soak testing blacklist.
  • [x ] If a new adapter was made, or a new endpoint was added, update the test-payload.json file with relevant requests.
  • [x ] The branch naming follows git flow (feature/x, chore/x, release/x, hotfix/x, fix/x) or is created from Jira.
  • [ x] This is related to a maximum of one Jira story or GitHub issue.
  • [x ] Types are safe (avoid TypeScript/TSLint features like any and disable, instead use more specific types).
  • [ x] All code changes have 100% unit and integration test coverage. If testing is not applicable or too difficult to justify doing, the reasoning should be documented explicitly in the PR.

chray-zhang avatar Sep 17 '25 04:09 chray-zhang