You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+23-5Lines changed: 23 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -73,6 +73,10 @@ commit credentials.
73
73
|`FIRSTRADE_DRY_RUN_ONLY`| Optional | Defaults to `true` for platform runtime |
74
74
|`FIRSTRADE_REUSE_SESSION`| Optional | Reuse cached Firstrade session headers inside the same warm runtime instance before logging in again. Defaults to `false`|
75
75
|`FIRSTRADE_SESSION_CACHE_TTL_SECONDS`| Optional | Max age for local session header reuse when `FIRSTRADE_REUSE_SESSION=true`. Defaults to `21600`|
76
+
|`FIRSTRADE_PERSIST_SESSION_CACHE`| Optional | Persist Firstrade session headers to the configured GCS state bucket when `FIRSTRADE_REUSE_SESSION=true`. Defaults to `false`|
77
+
|`FIRSTRADE_GCS_STATE_BUCKET`| Optional | GCS bucket for runtime state JSON, including persisted session cache and account funds snapshots |
78
+
|`FIRSTRADE_STATE_PREFIX`| Optional | Object prefix within `FIRSTRADE_GCS_STATE_BUCKET`, default `firstrade-platform`|
79
+
|`FIRSTRADE_PERSIST_ACCOUNT_SNAPSHOT`| Optional | Persist compact masked account funds snapshots from `/session-check`. Defaults to `false`|
|`FIRSTRADE_ENABLE_LIVE_TRADING`| Optional | Must be `true` before any live order can be submitted |
83
87
|`FIRSTRADE_RUN_SMOKE_ON_HTTP`| Optional | Must be `true` before `/smoke` performs a real login/quote |
88
+
|`FIRSTRADE_RUN_SESSION_CHECK_ON_HTTP`| Optional | Must be `true` before `/session-check` performs a read-only login/session/account-state check |
89
+
|`FIRSTRADE_SESSION_CHECK_INCLUDE_POSITIONS`| Optional | Include compact symbol/quantity/market-value positions in `/session-check` funds snapshots. Defaults to `false`|
84
90
|`FIRSTRADE_RUN_STRATEGY_ON_HTTP`| Optional | Must be `true` before `/run` performs strategy evaluation and order routing |
85
91
|`FIRSTRADE_LIVE_ORDER_ACK`| Optional | Must be `true` before `/run` can submit live orders |
86
92
|`FIRSTRADE_MAX_ORDER_NOTIONAL_USD`| Optional | Single-order cap for strategy-generated orders, default `25`|
@@ -175,11 +181,21 @@ The strategy execution service uses whole-share limit orders for generated
175
181
strategy orders. If the notional cap is below the current price of a target
176
182
symbol, that order is skipped instead of being enlarged.
177
183
178
-
`FIRSTRADE_REUSE_SESSION=true` reduces repeated login attempts while the same
179
-
Cloud Run instance stays warm. It stores the current session headers only in the
180
-
container-local cookie directory and tries that session before calling Firstrade
181
-
login again. A cold start, new revision, expired session, or broker-side
182
-
invalidation still falls back to a fresh login.
184
+
`FIRSTRADE_REUSE_SESSION=true` reduces repeated login attempts by trying cached
185
+
session headers before calling Firstrade login again. By default this cache is
186
+
container-local. When `FIRSTRADE_PERSIST_SESSION_CACHE=true` and
187
+
`FIRSTRADE_GCS_STATE_BUCKET` is set, the same cache is also written to GCS so a
188
+
cold start can try the last known session first. Expired sessions, new broker
189
+
sessions from another device, or broker-side invalidation still fall back to a
190
+
fresh login.
191
+
192
+
`/session-check` is a read-only route for session keepalive experiments and
193
+
account-state persistence. It connects to Firstrade, selects the account, reads
194
+
balances, optionally reads positions, and returns a compact masked funds
195
+
snapshot. With `FIRSTRADE_PERSIST_ACCOUNT_SNAPSHOT=true`, it writes the snapshot
196
+
to `accounts/<masked-account>/funds/latest.json` plus a timestamped history path
197
+
under the configured GCS prefix. Raw account IDs and login secrets are not
198
+
included in the snapshot.
183
199
184
200
## Cloud Run Shape
185
201
@@ -190,6 +206,8 @@ invalidation still falls back to a fresh login.
190
206
-`/probe` health metadata only
191
207
-`/profiles` shared US equity strategy matrix
192
208
-`/smoke` login + quote only when `FIRSTRADE_RUN_SMOKE_ON_HTTP=true`
209
+
-`/session-check` read-only session/account-state check only when
210
+
`FIRSTRADE_RUN_SESSION_CHECK_ON_HTTP=true`
193
211
-`/run` strategy evaluation + guarded order routing only when
0 commit comments