外汇交易员

外汇交易员

老实种地很枯燥吧 为星露谷增加外汇交易系统

简介 / Description

为星露谷物语添加外汇交易系统。

价格每 3 秒跳动一次,K 线在图表上实时生长。你可以用 1 到 100 倍杠杆做多或做空 8 个货币对,浮亏吃光保证金就当场爆仓——哪怕你正在外面钓鱼。

灵感来自网页游戏 FX 简单!。

交易是要花掉你的白天的。交易终端是全游戏唯一不暂停时间的菜单,所以你盯着图表的时候,这一天照样在流逝。

Turn Stardew Valley into a forex trading floor.

Prices tick every 3 seconds. K-line candles grow in real time on the chart. You can go long or short 8 currency pairs with 1x-100x leverage, and if your floating loss eats your margin you get liquidated on the spot — even while you are out fishing.

Inspired by the browser game FX 简单!.

Trading costs you daylight. The trading terminal is the one menu in the game that does not pause the clock, so the day keeps moving while you stare at the chart.

安装 / Installation instructions

  1. 安装最新版 SMAPI。
  2. 下载本 mod,解压到 Stardew Valley/Mods。
  3. 用 SMAPI 启动游戏。

游戏内按 X 打开交易终端。

  • 点左侧的货币对切换图表
  • 点保证金输入框,然后输入数字(Backspace 删除)
  • 选杠杆:1 到 100 之间任意数值都能直接输入,或用 - / + 逐档调整,也可点快捷档位 1x / 2x / 5x / 10x / 20x / 50x / 100x
  • 做多 BUY 赌价格上涨,做空 SELL 赌价格下跌
  • 平仓 或 全部平仓 结算盈亏并返还金币
  • 持仓 / 历史战绩 标签切换底部面板:持仓页显示货币对、方向、开仓价、现价、净盈亏、杠杆、保证金、手续费与爆仓价;历史页记录每一笔已平仓的交易
  • 持仓或历史记录多到一屏装不下时,用鼠标滚轮翻页
  • Esc 关闭终端——价格仍在跳动

按键可以在 config.json 里改(见下)。

  1. Install the latest version of SMAPI.
  2. Download this mod and unzip it into Stardew Valley/Mods.
  3. Run the game using SMAPI.

Press X in game to open the trading terminal.

  • Click a currency pair on the left to switch the chart
  • Click the margin box, then type a number (Backspace deletes)
  • Pick your leverage: type any value from 1 to 100, step it with - / +, or use the presets 1x / 2x / 5x / 10x / 20x / 50x / 100x
  • Long BUY bets the price goes up, Short SELL bets it goes down
  • Close or Close All settles your P/L and returns gold
  • Positions / History tabs switch the bottom panel: positions show pair, side, entry, current price, net P/L, leverage, margin, fee and liquidation price; history records every closed trade
  • Mouse wheel pages through positions or history when more rows than fit on screen
  • Esc closes the terminal — prices keep ticking

The key can be changed in config.json (see below).

主要特性 / Main features

  • 8 个货币对 — USD/CNY、EUR/USD、GBP/USD、USD/JPY、AUD/USD、USD/CAD、USD/CHF、NZD/USD

  • 每 tick 一根蜡烛 — 每 3 秒的每次价格变化都成为一根独立蜡烛,图表向右滚动

  • 真实起始汇率 — 起始价取自 frankfurter.dev(欧洲央行官方参考汇率),之后由游戏内市场接管

  • 保证金交易 — 1 到 100 倍杠杆,可做多做空,随时平仓

  • 开仓手续费 — 按名义价值的 0.05% 收取,开仓当场扣掉,让交易真正有成本

  • 实时爆仓 — 每个 tick 都检查,不是一天才查一次

  • 后台运行 — 关掉终端价格照样跳,回来时账户可能已经爆了

  • 历史战绩 — 记录每一笔已平仓交易:开仓价、平仓价、已实现盈亏、手续费、胜率与累计盈亏

  • 时间照走 — 交易终端是唯一不暂停游戏时钟的菜单,交易要花掉你的白天

  • 存档持久化 — 价格、持仓、盈亏、K 线历史全部写入存档

  • 中英双语 — 自动跟随游戏语言

  • 8 currency pairs — USD/CNY, EUR/USD, GBP/USD, USD/JPY, AUD/USD, USD/CAD, USD/CHF, NZD/USD

  • One candle per tick — every 3 seconds each price change becomes its own candle, and the chart scrolls to the right

  • Real starting rates — prices are seeded from frankfurter.dev (official European Central Bank reference rates). After seeding, the in-game market takes over

  • Margin trading — 1x to 100x leverage, long or short, close any time

  • Opening fee — 0.05% of notional is charged the moment you open, so trading has a real cost

  • Real-time liquidation — checked on every tick, not just once a day

  • Runs in the background — prices keep ticking even when the terminal is closed, so you can come back to a blown account

  • Trade history — every closed trade with entry price, exit price, realized P/L, fees paid, win rate and running totals

  • Time keeps flowing — the trading terminal is the one menu that does not pause the game clock, so trading costs you daylight

  • Save persistence — prices, positions, P/L and candle history all stored in your save

  • English and Chinese — follows your game language automatically

交易规则 / Trading rules

名义 Notional    = 保证金 margin x 杠杆 leverage
手续费 Fee       = 名义 x 0.05%   (开仓收取,不退)
敞口 Exposure    = 名义 / 开仓价   (价格每变动 1.0 时的金币盈亏)
盈亏 P/L         = 方向 x (现价 - 开仓价) x 敞口
爆仓 Liquidation = 浮亏 >= 保证金  ->  强制平仓,保证金没收

手续费和保证金一起从钱包里扣,所以开一笔仓的实际成本是 margin + fee。平仓时手续费不退,因此终端上显示的盈亏永远已经扣掉手续费。

敞口按你的开仓价换算,所以你选的杠杆就是你真正拿到的杠杆,跟交易哪个货币对无关。价格反向动 1%,你亏掉保证金的 1% x 杠杆。

举例:1000 金币保证金、50x 杠杆,名义 50,000 金币,开仓手续费 25 金币。价格动 1% 值 500 金币(你保证金的一半),动 2% 就归零。一个 tick 大约动 0.12%,所以 50x 下连续约 17 个坏 tick 就会爆仓。

1x = 100%    5x = 20%    20x =  5%
2x =  50%   10x = 10%    50x =  2%   100x = 1%

The opening fee is taken from your wallet together with the margin, so opening a position costs margin + fee. It is not refunded when you close, which is why the P/L shown in the terminal is always the net figure.

Exposure is converted at your entry price, so the leverage you pick is the leverage you actually get, no matter which pair you trade. A 1% adverse move costs you 1% x leverage of your margin.

Example: 1000g margin at 50x gives 50,000g notional and costs 25g to open. A 1% move is worth 500g (half your margin) and a 2% move wipes you out. One tick moves roughly 0.12%, so about 17 bad ticks in a row at 50x will liquidate you.

1x = 100%    5x = 20%    20x =  5%
2x =  50%   10x = 10%    50x =  2%   100x = 1%

前置要求 / Requirements

支持 Windows、Linux、macOS。支持单人和多人——每个玩家有自己的持仓。

Works on Windows, Linux and macOS. Works in single player and multiplayer — each player has their own positions.

配置 / Configuration

首次运行会在 Mods/FXTrader/ 生成 config.json:

{
"UseLiveData": true,           // 用 frankfurter (ECB) 播种起始价
"TickIntervalSeconds": 3.0,    // 价格跳动间隔(秒)
"TickVolatility": 0.0012,      // 每 tick 波动幅度(0.0012 = 0.12%)
"RefreshMinutes": 30,          // 汇率刷新间隔(分钟)
"OpenKey": "X"                 // 打开交易终端的按键
}

装了 Generic Mod Config Menu 的话可以在游戏内改这些设置。

A config.json is created in Mods/FXTrader/ on first run:

{
"UseLiveData": true,           // seed prices from frankfurter (ECB)
"TickIntervalSeconds": 3.0,    // how often prices tick
"TickVolatility": 0.0012,      // swing per tick (0.0012 = 0.12%)
"RefreshMinutes": 30,          // rate refresh interval
"OpenKey": "X"                 // key to open the terminal
}

If you have Generic Mod Config Menu installed you can edit these in game.

说明与限制 / Notes and limitations

  • ECB 参考汇率每个工作日只更新一次,所以"真实汇率"只用来给起始价播种。之后每 tick 的波动是游戏内市场——否则就没东西可交易了。

  • 交易终端不暂停游戏时钟。其他菜单(背包、对话、发货箱)仍然照常暂停时间。

  • 保证金在你开仓那一刻检查,不会因为之后金币变化重新校验。

  • 爆仓会立刻弹出 HUD 提示,并在第二天寄一封汇总信。

  • ECB reference rates update once per business day, so the "real rate" only seeds the starting price. The per-tick movement is the in-game market — otherwise there would be nothing to trade.

  • The trading terminal does not pause the game clock. Every other menu (inventory, dialogue, shipping bin) still pauses time as usual.

  • Margin is checked at the moment you open a position, not re-validated against later gold changes.

  • Liquidation shows a HUD alert immediately and also sends a summary letter the next day.

致谢 / Shout outs

  • 灵感来自 FX 简单! —— 一个让我一下看懂外汇概念的网页游戏。

  • frankfurter.dev 提供免费、无需 API key 的 ECB 参考汇率接口。

  • SMAPI 以及星露谷 mod 社区。

  • Inspired by FX 简单! — a browser forex game that made the concept click for me.

  • frankfurter.dev for the free, keyless ECB reference rate API.

  • SMAPI and the Stardew Valley modding community.

欢迎反馈 bug 和建议。更新日志在下载包里的 README。

Bug reports and suggestions are welcome. Release notes are in the README inside the download.