Skip to content

Add Pocket Option (forex binary-options) venue with time-based forecasts#28

Merged
Payel-git-ol merged 4 commits into
Payel-git-ol:masterfrom
konard:issue-27-0a944ebd1782
May 30, 2026
Merged

Add Pocket Option (forex binary-options) venue with time-based forecasts#28
Payel-git-ol merged 4 commits into
Payel-git-ol:masterfrom
konard:issue-27-0a944ebd1782

Conversation

@konard

@konard konard commented May 30, 2026

Copy link
Copy Markdown
Contributor

Add Pocket Option (forex binary-options) venue with time-based forecasts

Fixes #27

What the issue asked for

  • Add a Pocket Option exchange to the TRADEFAST CLI and wire up its API.
  • Pocket Option is a forex binary-options venue, so use frankfurter.dev for rates, e.g. https://api.frankfurter.dev/v2/rate/EUR/USD{"amount":1.0,"base":"EUR","date":"2026-05-30","rates":{"USD":1.15186}}.
  • Keep the strategy algorithms exactly the same.
  • In the result, replace TP (take-profit) / SL (stop-loss) with TIME — the expiry duration ("how long to buy"), because Pocket Option has no takes/stops, only a timed expiry.

How it works

  • New exchange pocketoption registered alongside the crypto spot venues (src/cli/exchanges.ts). It is classified as binary via isBinaryOptions() / exchangeKind().
  • Market data via Frankfurter (FrankfurterMarketData in src/services/market-data.ts). Frankfurter returns a single ECB reference quote (no OHLCV), so we reuse the existing candlesFromSpot helper to build a deterministic candle path that lands on the live spot — feeding the unchanged strategy/forecast pipeline. Endpoint is configurable via TRADEFAST_FRANKFURTER_API.
  • Forex defaults: when Pocket Option is selected and TRADEFAST_SYMBOLS is unset, defaults switch to forex majors (EURUSD, GBPUSD, …) instead of crypto tickers (src/config.ts). User-pinned symbol lists are always honoured, and switching exchanges only swaps symbols when the current list matches the previous venue's defaults.
  • TP/SL → TIME in the result: forecasts now carry an expiryMinutes (src/strategies/forecast.ts), and the trade log renders a Time column instead of TP/SL for binary venues (src/cli/trade-log.ts). Expiry = intervalMinutes(interval) × EXPIRY_BARS.
  • Binary backtest settlement: the backtester gains simulateBinaryTrade (src/services/backtest.ts) which settles each trade on the timed expiry bar (win → +0.92R Pocket-Option-style payout, loss → −1R, flat → 0) instead of bracketing with TP/SL. The strategy/forecast logic itself is untouched.

How to reproduce / try it

TRADEFAST_EXCHANGE=pocketoption npm run dev
# or inside the CLI:
/exchange pocketoption

The forecast/trade-log output for Pocket Option shows an expiry Time column (e.g. 2h) in place of TP/SL.

Tests

All 126 tests pass; npm run typecheck and npm run build are clean. New/updated coverage:

  • tests/config.test.ts — forex vs crypto default symbols and loadConfig resolution.
  • tests/market-data.test.ts — Frankfurter endpoint URL, missing-rate error, toForexPair, and source selection for pocketoption.
  • tests/forecast.test.ts — binary-options expiry minutes.
  • tests/backtest.test.ts — binary settlement (payout/loss/timeout).
  • tests/cli.test.tsx — exchange list includes pocketoption, binary classification, and the Time column.

Other

  • README.md documents the venue, the TRADEFAST_EXCHANGE / TRADEFAST_FRANKFURTER_API env vars, and the binary settlement behaviour.
  • Version bumped 0.4.1 → 0.5.0 to trigger the next release.

This PR was generated by the AI issue solver.

konard added 3 commits May 30, 2026 08:14
Adding .gitkeep for PR creation (default mode).
This file will be removed when the task is complete.

Issue: Payel-git-ol#27
Add Pocket Option as a forex binary-options exchange:
- New exchange entry with a 'binary-options' kind; spot venues stay 'spot'.
- FrankfurterMarketData fetches ECB reference rates from frankfurter.dev and
  builds a deterministic candle path landing on the live spot, so all 13
  strategy algorithms run unchanged.
- Forecast now derives a binary-options expiry time (EXPIRY_BARS × interval)
  alongside the existing TP/SL bracket.
- Trade Log shows a Time (expiry) column instead of TP/SL on binary venues.
- Backtester gains a binary-options settlement mode (resolve on expiry by
  direction, Pocket Option-style payout).
- Pocket Option defaults to forex majors (EURUSD, GBPUSD, …) for symbols.
- Wire exchange/interval through RunReport so the UI picks the right columns.

Tests cover the Frankfurter source, forex pair parsing, expiry derivation,
binary settlement, forex symbol defaults, and the Time column.
README: describe the forex binary-options venue (Frankfurter rates, expiry
time instead of TP/SL), the new TRADEFAST_EXCHANGE / TRADEFAST_FRANKFURTER_API
env vars, the pocketoption market source, the binary-options backtest
settlement, and the updated /exchange command.
@konard konard changed the title [WIP] Нужно добавить биржу pocket option Add Pocket Option (forex binary-options) venue with time-based forecasts May 30, 2026
@konard konard marked this pull request as ready for review May 30, 2026 08:38
@konard

konard commented May 30, 2026

Copy link
Copy Markdown
Contributor Author

Working session summary

The task is complete. Here's a summary of what was delivered for issue #27.

Summary

PR #28#28 — is now ready for review with a full description, passing CI, and 126 passing tests.

What was implemented

The issue asked to add a Pocket Option forex binary-options venue, wire up its API via frankfurter.dev, keep the strategy algorithms unchanged, and replace TP/SL with a TIME (expiry) value in the result.

  • New pocketoption exchange (src/cli/exchanges.ts), classified as binary via isBinaryOptions().
  • Frankfurter market data (FrankfurterMarketData, src/services/market-data.ts): pulls the ECB spot quote (/v2/rate/EUR/USD) and reuses the existing candlesFromSpot helper to feed the unchanged strategy/forecast pipeline. Endpoint is configurable via TRADEFAST_FRANKFURTER_API.
  • Forex defaults (src/config.ts): Pocket Option defaults to forex majors (EURUSD, GBPUSD, …) when no symbols are pinned; user lists are always honoured.
  • TP/SL → TIME: forecasts carry expiryMinutes (src/strategies/forecast.ts); the trade log renders a Time column for binary venues (src/cli/trade-log.ts). Expiry = intervalMinutes × EXPIRY_BARS.
  • Binary backtest settlement (simulateBinaryTrade, src/services/backtest.ts): settles on the timed expiry bar (win +0.92R, loss −1R, flat 0) instead of TP/SL brackets — strategy logic untouched.

Verification

  • npm run typecheck clean, npm test → 126/126 pass, npm run build clean.
  • CI green on the latest commit de895e8.
  • Branch up to date with upstream/master; working tree clean.
  • New tests cover config defaults, Frankfurter endpoint, binary expiry, binary settlement, and the CLI Time column.
  • README documents the venue + env vars; version bumped 0.4.1 → 0.5.0.

This summary was automatically extracted from the AI working session output.

@konard

konard commented May 30, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost: $10.557159

📊 Context and tokens usage:

Claude Opus 4.8: (3 sub-sessions)

  1. 116.4K / 1M (12%) input tokens, 35.3K / 128K (28%) output tokens
  2. 116.1K / 1M (12%) input tokens, 33.2K / 128K (26%) output tokens
  3. 38.8K / 1M (4%) input tokens, 4.1K / 128K (3%) output tokens

Total: (26.5K new + 301.3K cache writes + 12.3M cache reads) input tokens, 87.4K output tokens, $10.337608 cost

Claude Haiku 4.5:

  • 82.7K / 200K (41%) input tokens, 9.7K / 64K (15%) output tokens

Total: (2.9K new + 79.8K cache writes + 681.6K cache reads) input tokens, 9.7K output tokens, $0.219551 cost

🤖 Models used:

  • Tool: Anthropic Claude Code
  • Requested: opus
  • Main model: Claude Opus 4.8 (claude-opus-4-8)
  • Additional models:
    • Claude Haiku 4.5 (claude-haiku-4-5-20251001)

📎 Log file uploaded as Gist (5357KB)


Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard

konard commented May 30, 2026

Copy link
Copy Markdown
Contributor Author

✅ Ready to merge

This pull request is now ready to be merged:

  • All CI checks have passed
  • No merge conflicts
  • No pending changes

Monitored by hive-mind with --auto-restart-until-mergeable flag

@Payel-git-ol Payel-git-ol merged commit ed57670 into Payel-git-ol:master May 30, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Нужно добавить биржу pocket option

2 participants