# China FDI Flow & Position Monitor (`zinin/china-fdi-flow-position-monitor`) Actor

Monitor official OECD China FDI financial flows and positions by assets and liabilities, with paid-delivery-safe deltas.

- **URL**: https://apify.com/zinin/china-fdi-flow-position-monitor.md
- **Developed by:** [Tim Zinin](https://apify.com/zinin) (community)
- **Categories:** News, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.40 / 1,000 public oecd fdi dataset checkeds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## China FDI Flow & Position Monitor

Track China's official OECD foreign-direct-investment financial flows and positions without maintaining an SDMX integration. The Actor returns quarterly flows and annual positions for **assets and liabilities**, detects delivery-to-delivery revisions, and is ready for scheduled monitoring.

### What it monitors

- **FDI financial flows** — quarterly OECD `DF_FDI_FLOW_AGGR` total financial-account values.
- **FDI financial positions** — annual OECD `DF_FDI_POS_AGGR` total financial-account values.
- China (`CHN`), USD values, world counterpart, total economy, assets and liabilities.
- Only public OECD rows marked `CONF_STATUS=F`.

The accounting labels matter: assets and liabilities are not renamed to “outbound” and “inbound.” A flow is activity during a period; a position is a stock at a point in time.

### Example input

```json
{
  "datasets": ["flow", "position"],
  "startYear": 2021,
  "endYear": 2025,
  "watchName": "china-fdi-main",
  "cacheMaxAgeMinutes": 60
}
```

The inclusive window is limited to 10 years. Selecting both datasets makes one bounded official request for each. The Actor never uses an Apify proxy, a third-party proxy, or a VPN.

### Output

One Dataset row represents one selected OECD dataflow. `observations` contains assets/liabilities periods, the original numeric `value`, OECD `unitMultiplier`, and a convenient `valueUsd`. Negative source values remain negative.

```json
{
  "dataset": {"kind": "flow", "title": "FDI financial flows"},
  "terminology": "assets_liabilities",
  "changeType": "revision",
  "observations": [
    {
      "accountingEntry": "L",
      "side": "liabilities",
      "period": "2024-Q2",
      "value": -8990,
      "unitMultiplier": 6,
      "valueUsd": -8990000000,
      "currency": "USD",
      "confidentialityStatus": "F"
    }
  ],
  "adaptation": {"marker": "ACTOR_DERIVED_DELTA", "isAdapted": true},
  "source": {"provider": "OECD", "apiUrl": "https://sdmx.oecd.org/..."}
}
```

`changeType`, new/revised/removed observations and changed keys are computed by this Actor from successive confirmed paid deliveries. They are not fields supplied by OECD, and every row carries an explicit adaptation marker.

### Scheduling

1. Save the example as an Apify Task.
2. Keep `watchName`, datasets and year window stable.
3. Schedule it weekly or monthly.
4. Read changed rows from the Dataset or connect a webhook/automation to the run result.

OECD states a two-hour HTTP cache lifetime on current responses. This Actor also offers a conservative 0-120 minute parsed-response cache. It sends at most two data requests per run, counts retries against that ceiling, honors bounded `Retry-After`, and returns explicit free error rows when a retry cannot be made safely.

### Billing and safety

The Actor uses pay per event: one start event and one `fdi-dataset-checked` event per successfully delivered dataflow row containing public observations. Empty or source-error rows are not charged as result events. The Apify SDK may omit its implicit free default Dataset event from the resolved price map. If that key is present, it must be exact numeric positive zero; `-0`, strings and other malformed values fail closed.

Production baselines advance only after the atomic Dataset delivery receipt confirms a paid result event with a finite numeric positive-integer `chargedCount`. Missing, string, zero, fractional, `NaN` or infinite receipt values are fatal uncertain delivery. Pricing drift, unreadable budget state, rate limits, source failures and uncertain delivery fail closed and preserve the prior baseline. Local development runs intentionally do not advance the production-style baseline.

### Source and attribution

Source: OECD foreign direct investment statistics, official SDMX dataflows `OECD.DAF.INV:DSD_FDI@DF_FDI_FLOW_AGGR(1.0)` and `OECD.DAF.INV:DSD_FDI@DF_FDI_POS_AGGR(1.0)`. Data is adapted by this Actor to calculate delivery-to-delivery deltas. See the [OECD API guide](https://www.oecd.org/en/data/insights/data-explainers/2024/09/api.html) and [OECD Terms and Conditions](https://www.oecd.org/en/about/terms-conditions.html).

This Actor is independently maintained and is not an OECD product or endorsement. Source classifications and historical observations can be revised by OECD.

# Actor input Schema

## `datasets` (type: `array`):

Official OECD aggregate financial flows (quarterly), positions (annual), or both. Values use the assets/liabilities accounting principle; they are not inbound/outbound labels.

## `startYear` (type: `integer`):

Inclusive first year. Runtime validation enforces 2005 or later and a maximum 10-year window.

## `endYear` (type: `integer`):

Inclusive last year, not later than the current UTC year.

## `watchName` (type: `string`):

Stable private baseline scope. Reuse it in scheduled runs to compare only against a previously confirmed paid delivery.

## `cacheMaxAgeMinutes` (type: `integer`):

Reuse a validated official OECD response for 0-120 minutes. Set 0 to disable cache reads. Cache state never changes the paid-delivery baseline.

## Actor input object example

```json
{
  "datasets": [
    "flow",
    "position"
  ],
  "startYear": 2021,
  "endYear": 2025,
  "watchName": "china-fdi-main",
  "cacheMaxAgeMinutes": 60
}
```

# Actor output Schema

## `results` (type: `string`):

API URL for paid public snapshots and free explicit empty/error rows.

## `OUTPUT` (type: `string`):

API URL for terminal status, counters, request ceiling and baseline policy.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "datasets": [
        "flow",
        "position"
    ],
    "startYear": 2021,
    "endYear": 2025,
    "watchName": "china-fdi-main",
    "cacheMaxAgeMinutes": 60
};

// Run the Actor and wait for it to finish
const run = await client.actor("zinin/china-fdi-flow-position-monitor").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "datasets": [
        "flow",
        "position",
    ],
    "startYear": 2021,
    "endYear": 2025,
    "watchName": "china-fdi-main",
    "cacheMaxAgeMinutes": 60,
}

# Run the Actor and wait for it to finish
run = client.actor("zinin/china-fdi-flow-position-monitor").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "datasets": [
    "flow",
    "position"
  ],
  "startYear": 2021,
  "endYear": 2025,
  "watchName": "china-fdi-main",
  "cacheMaxAgeMinutes": 60
}' |
apify call zinin/china-fdi-flow-position-monitor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,zinin/china-fdi-flow-position-monitor"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/htfBume9gvN46ZXcj/builds/GBC7jaDwZa93GZj5V/openapi.json
