# HK IPO Fee & Allotment Calculator (`tiezhengzhang/hk-ipo-fee-calculator`) Actor

Batch-calculate Hong Kong IPO subscription costs from the terms you supply: one-lot entry fee, margin financing and interest, allotment expected value, break-even sell price and first-day P\&L scenarios. No scraping.

- **URL**: https://apify.com/tiezhengzhang/hk-ipo-fee-calculator.md
- **Developed by:** [tiezheng zhang](https://apify.com/tiezhengzhang) (community)
- **Categories:** Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.30 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
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.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## 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.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## HK IPO Fee & Allotment Calculator

Work out exactly what a **Hong Kong IPO subscription** costs, and what it could make, for a whole batch of IPOs at once.
You supply the terms (offer price, board lot, your margin and broker fees, allotment odds). The Actor returns:

- the **one-lot entry fee**, accurate to the cent;
- the amount payable for all lots applied;
- financed amount, own cash and margin interest;
- the cost you pay even if you are not allotted;
- the **break-even sell price**;
- **P\&L and expected value** for each first-day scenario.

There is no scraping and no network access: it is pure arithmetic on your input. That makes it fast (one run handles thousands of rows in seconds), cheap and private.

### Why use it

- **Exact fees.** Application money + 1% brokerage + 0.0027% SFC transaction levy + 0.00015% AFRC transaction levy + 0.00565% HKEX trading fee, each rounded to the cent, as in a prospectus "amount payable" table.
  Selling costs include 0.1% stamp duty rounded up to HK$1, levies, the trading fee and your broker's commission and platform fee.
- **Margin (IPO financing) maths.** Give a margin multiple (10 = 10x) or a financed percentage, your annual rate and the number of interest days.
- **Allotment expected value.** Give the probability directly, or the *valid applications* and *successful applicants* counts from the allotment results announcement.
- **One engine everywhere.** The same fee engine powers [hk-ipo-calc.pages.dev](https://hk-ipo-calc.pages.dev/en/), the HK IPO Ledger Chrome extension and the [HK IPO Fee & Listings API on RapidAPI](https://rapidapi.com/tiezhengzhang/api/hk-ipo-fee-listings-api). It is cross-checked against 600+ test vectors.

### Input

Use the **IPOs (JSON list)**, the **CSV** box, or both. **Broker defaults** apply to every row unless the row sets its own value. Percentages are entered as percent: `3.5` means 3.5%.

| Field | Required | Meaning |
|---|---|---|
| `price` | yes | Offer price in HK$ |
| `lot` | yes | Shares per board lot |
| `name`, `code` | | Your labels, copied to the output |
| `lotsApplied` | | Lots applied for (default 1) |
| `marginMultiple` or `marginRatioPct` | | 10 = 10x margin; or the financed share in % (90 = 90%) |
| `annualRatePct`, `days` | | Margin interest rate (% p.a.) and interest days |
| `handlingFee`, `financingFee` | | Broker's per-application fees in HK$ |
| `allottedLots` | | Lots you assume you receive (default 1) |
| `allotProbabilityPct` or `validApps` + `successfulApps` | | Allotment odds, needed for expected value |
| `scenarios` | | First-day moves in %, e.g. `"-20,-10,0,10,20,50,100"` (the default) |
| `commissionRatePct`, `minCommission`, `platformFee` | | Your broker's selling charges |

Example:

```json
{
  "ipos": [
    {"name": "Cash, 1 lot", "price": 8.88, "lot": 500, "allotProbabilityPct": 30},
    {"name": "10x margin", "price": 25.5, "lot": 200, "lotsApplied": 50, "marginMultiple": 10, "annualRatePct": 3.5, "days": 7, "handlingFee": 100, "validApps": 120000, "successfulApps": 18000}
  ],
  "defaults": {"commissionRatePct": 0.03, "minCommission": 3, "platformFee": 15}
}
```

### Output

One dataset item per valid row. The **Overview**, **Scenarios** (one line per scenario) and **Fee breakdown** views are ready to export as Excel, CSV or JSON.
Key fields: `entryFee`, `entryFeeBreakdown`, `appliedPayable`, `financed`, `ownCash`, `interest`, `fixedCost`, `totalCostIfAllotted`, `breakEvenPrice`, `breakEvenPct`, `allotProbability`, `expectedValueAtFlat`, `scenarios[]` (`changePct`, `sellPrice`, `pnlIfAllotted`, `pnlIfNotAllotted`, `expectedValue`).

Invalid rows (for example a missing price) are listed with the reason in the run's **OUTPUT** record (Storage → Key-value store) and are **not charged**.

### Pricing

Pay per result: **$0.30 per 1,000 IPO plans** (one plan = one dataset item), plus Apify's standard Actor start event ($0.00005 per run).
A run with 20 IPOs costs about $0.006. You can set a maximum cost per run; the Actor stops when it is reached.

### Use cases

- Compare this week's IPOs on cash and on 10x margin before you subscribe.
- Re-run with the real allotment results to see each IPO's actual expected value and break-even price.
- Feed a newsletter, spreadsheet, bot or AI agent (works through the Apify API and Apify's MCP server).

### Limitations and disclaimer

- The Actor does not fetch IPO terms. HKEX and HKEXnews content may not be scraped or redistributed without HKEX's written permission, so you enter the terms from the prospectus and announcements yourself.
- The break-even price is theoretical; round it up to a valid tick. Broker fee schedules vary, so enter yours.
- Arithmetic only. **Not investment advice.** Not affiliated with Hong Kong Exchanges and Clearing Limited.

Questions or bugs: use the Issues tab, or email ztz1024666@gmail.com.

# Actor input Schema

## `ipos` (type: `array`):

One object per IPO / scenario. Required: price (HK$) and lot (shares per board lot). Optional: name, code, lotsApplied, marginMultiple or marginRatioPct, annualRatePct, days, handlingFee, financingFee, allottedLots, allotProbabilityPct or validApps + successfulApps, scenarios (e.g. "-20,0,20,50"), commissionRatePct, minCommission, platformFee.

## `csv` (type: `string`):

Paste CSV with a header row using the same field names as the JSON list, e.g.
name,price,lot,lotsApplied,marginMultiple,annualRatePct,days,allotProbabilityPct
Foo,8.88,500,20,10,3.5,7,25

## `defaults` (type: `object`):

Same fields as a row, for example your broker's margin rate and fees: {"annualRatePct": 3.5, "days": 7, "handlingFee": 100, "commissionRatePct": 0.03, "minCommission": 3, "platformFee": 15, "scenarios": "-20,-10,0,10,20,50,100"}

## Actor input object example

```json
{
  "ipos": [
    {
      "name": "Example A (cash, 1 lot)",
      "price": 8.88,
      "lot": 500,
      "lotsApplied": 1,
      "allotProbabilityPct": 30
    },
    {
      "name": "Example B (10x margin)",
      "price": 25.5,
      "lot": 200,
      "lotsApplied": 50,
      "marginMultiple": 10,
      "annualRatePct": 3.5,
      "days": 7,
      "handlingFee": 100,
      "allottedLots": 1,
      "validApps": 120000,
      "successfulApps": 18000
    }
  ],
  "defaults": {
    "days": 7,
    "commissionRatePct": 0.03,
    "minCommission": 3,
    "platformFee": 15,
    "scenarios": "-20,-10,0,10,20,50,100"
  }
}
```

# Actor output Schema

## `plans` (type: `string`):

One item per valid IPO row: entry fee and breakdown, amount payable, margin financing, cost if (not) allotted, break-even price, allotment probability, expected value and day-1 scenarios.

## `summary` (type: `string`):

OUTPUT record: number of results, invalid rows with the reason (not billed) and disclaimer.

# 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 = {
    "ipos": [
        {
            "name": "Example A (cash, 1 lot)",
            "price": 8.88,
            "lot": 500,
            "lotsApplied": 1,
            "allotProbabilityPct": 30
        },
        {
            "name": "Example B (10x margin)",
            "price": 25.5,
            "lot": 200,
            "lotsApplied": 50,
            "marginMultiple": 10,
            "annualRatePct": 3.5,
            "days": 7,
            "handlingFee": 100,
            "allottedLots": 1,
            "validApps": 120000,
            "successfulApps": 18000
        }
    ],
    "defaults": {
        "days": 7,
        "commissionRatePct": 0.03,
        "minCommission": 3,
        "platformFee": 15,
        "scenarios": "-20,-10,0,10,20,50,100"
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("tiezhengzhang/hk-ipo-fee-calculator").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 = {
    "ipos": [
        {
            "name": "Example A (cash, 1 lot)",
            "price": 8.88,
            "lot": 500,
            "lotsApplied": 1,
            "allotProbabilityPct": 30,
        },
        {
            "name": "Example B (10x margin)",
            "price": 25.5,
            "lot": 200,
            "lotsApplied": 50,
            "marginMultiple": 10,
            "annualRatePct": 3.5,
            "days": 7,
            "handlingFee": 100,
            "allottedLots": 1,
            "validApps": 120000,
            "successfulApps": 18000,
        },
    ],
    "defaults": {
        "days": 7,
        "commissionRatePct": 0.03,
        "minCommission": 3,
        "platformFee": 15,
        "scenarios": "-20,-10,0,10,20,50,100",
    },
}

# Run the Actor and wait for it to finish
run = client.actor("tiezhengzhang/hk-ipo-fee-calculator").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 '{
  "ipos": [
    {
      "name": "Example A (cash, 1 lot)",
      "price": 8.88,
      "lot": 500,
      "lotsApplied": 1,
      "allotProbabilityPct": 30
    },
    {
      "name": "Example B (10x margin)",
      "price": 25.5,
      "lot": 200,
      "lotsApplied": 50,
      "marginMultiple": 10,
      "annualRatePct": 3.5,
      "days": 7,
      "handlingFee": 100,
      "allottedLots": 1,
      "validApps": 120000,
      "successfulApps": 18000
    }
  ],
  "defaults": {
    "days": 7,
    "commissionRatePct": 0.03,
    "minCommission": 3,
    "platformFee": 15,
    "scenarios": "-20,-10,0,10,20,50,100"
  }
}' |
apify call tiezhengzhang/hk-ipo-fee-calculator --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,tiezhengzhang/hk-ipo-fee-calculator"
        }
    }
}
```

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/eNJbKtCqtzUsjC37W/builds/J2rZV3cLFjeUbPWhG/openapi.json
