fg-strategy-modelling-core · PyPI Skip to main content Switch to mobile version Warning Some features may not work
without JavaScript. Please try enabling it if you encounter problems. Search PyPI Search Help Docs Log in Register Help
Docs Log in Register Deutsch English español Esperanto français português (Brasil) Ελληνικά русский
українська עברית 中文 (简体) 中文 (繁體) 日本語 한국어 Search PyPI Search
fg-strategy-modelling-core 0.2.5 ForexGrand strategy modelling core library for ML model training on forex data |
financial price data pip install fg-strategy-modelling-core==0.2.5 Copy PIP instructions Description Download files
Release history ForexGrand Strategy Modelling Core ForexGrand Strategy Modelling Core is a Python package for building
forex strategy modelling workflows. It includes utilities for loading market data from Cloudflare R2, preparing TFRecord
datasets, training models, evaluating model quality, and packaging trained models for deployment. The distribution name
is fg-strategy-modelling-core; the Python import package is forexgrand_core. Features Cloudflare R2-backed storage
access through the S3-compatible API. A runtime configuration helper so users do not have to manually export environment
variables. Data loading and local caching for symbol market data. Dataset generation utilities for train, evaluation,
and test workflows. Training pipelines for neural-network, KNN, XGBoost, and no-train target models. Model evaluation,
performance checks, and model publishing helpers. Extensible preprocessing classes for custom feature pipelines.
Installation Install from PyPI: pip install fg-strategy-modelling-core Install from source for development: git clone
https://github.com/forexgrand/fg-strategy-modelling-core.git cd fg-strategy-modelling-core pip install -e ".[dev]"
Command Line Interface Installing the package provides an fg_core command with data workflow subcommands: fg_core
download_data EURUSD forex --bucket forexgrand-data --source mt5 fg_core generate_train_data EURUSD forex
--sequence-length 2800 --stride 100 fg_core preprocess_data prices.parquet preprocess.py --output data/processed.pkl.gz
preprocess.py must define preprocess_fn(dataframe). The input can be CSV, Parquet, or a pickle file, and the
preprocessing result is saved as a gzip-compressed pickle. Each command prints a JSON object containing its output path
and summary information. Storage credentials and other runtime settings use the same environment variables as the Python
API. Configure Cloudflare R2 The package currently supports Cloudflare R2 storage. Configure it at the start of your
script with configure_r2: from forexgrand_core import configure_r2 settings = configure_r2(
account_id="your-cloudflare-account-id", access_key_id="your-r2-access-key-id",
secret_access_key="your-r2-secret-access-key", bucket_name="forexgrand-data", train_bucket_name="forexgrand-train",
eval_bucket_name="forexgrand-eval", test_bucket_name="forexgrand-test", model_upload_bucket="forexgrand-models", ) You
can pass endpoint="https://<account-id>.r2.cloudflarestorage.com" instead of account_id if you already have the
full endpoint. configure_r2 sets these environment variables for the current Python process and returns a fresh Settings
object: Variable Purpose S3_STORAGE_OPTION Always set to cloudflare S3_ENDPOINT Cloudflare R2 S3 API endpoint
S3_ACCESS_KEY R2 access key ID S3_SECRET_KEY R2 secret access key S3_REGION_NAME R2 region, defaults to auto
S3_BUCKET_NAME Main data bucket TRAIN_BUCKET_NAME Training dataset bucket EVAL_BUCKET_NAME Evaluation dataset bucket
TEST_BUCKET_NAME Test dataset bucket MODEL_UPLOAD_BUCKET Trained model upload bucket If bucket-specific names are
omitted, bucket_name is reused for all buckets. Load Market Data from forexgrand_core import configure_r2 from
forexgrand_core.data_manager import DataManager configure_r2( account_id="your-cloudflare-account-id",
access_key_id="your-r2-access-key-id", secret_access_key="your-r2-secret-access-key", bucket_name="forexgrand-data", )
manager = DataManager(base_bucket_name="forexgrand-data") df, properties = manager.load_data( symbol_pair="EURUSD",
instrument_group="forex", ) Generate Training Data import tensorflow as tf from forexgrand_core import configure_r2 from
forexgrand_core.pipeline.no_train_trainer import NoTrainTrainer from
forexgrand_core.pipeline.preprocessing.base_preprocessor import PreprocessBase from forexgrand_core.schemas import
SymbolIn, TimeBasedTarget class Preprocess(PreprocessBase): def preprocess(self, data, training=False): return
{"direction": tf.zeros(tf.shape(data["close"])[0], dtype=tf.int64)} def features_metadata(self): return {"direction":
tf.io.FixedLenFeature([], tf.int64)} configure_r2( account_id="your-cloudflare-account-id",
access_key_id="your-r2-access-key-id", secret_access_key="your-r2-secret-access-key", bucket_name="forexgrand-data", )
trainer = NoTrainTrainer( symbols=[SymbolIn(symbol="EURUSD", group="forex")], sequence_length=2800,
preprocessor_class=Preprocess, target_model_type=TimeBasedTarget(stop_minutes=60, mode="prices"),
run_performance_test=False, hot_reload_data=False, upload_models=True, target_percentile=99, use_dataframe_format=False,
) results = trainer.run() For data generation APIs, pass source explicitly when the data is not under the DATA_SOURCE
environment value: data_gen.load_single_data(..., source="metaquotes") data_gen.load_data(..., source="metaquotes")
Backtest A Strategy Backtesting currently uses the Python API only. The CLI backtest command is temporarily unavailable.
Pass an instance of SignalsBase to run_backtest; its signals(batch) method returns one direction per input window: 0 for
buy, 1 for sell, or 2 for no trade. from forexgrand_core.backtesting import run_backtest result = run_backtest(
strategy=my_strategy, bucket_name="forexgrand-test", source="dukascopy", symbol_pair="EURUSD", instrument_group="forex",
sequence_length=60, stride=5, max_open_trades=1, start_index=0, end_index=-1, return_in_points=True,
sl_calculation={"mode": "fixed", "sl_points": 100, "tp_points": 150}, ) print(result.positions)
print(result.positions_total, result.buy_count, result.sell_count) Backtests allow one open trade at a time by default.
Set max_open_trades to a higher positive integer to allow concurrent trades; signals rejected because the limit is
reached are excluded from positions and all statistics. The returned backtest result is dictionary-compatible and
contains the realized positions, curves, counts, final balance, and optional statistics. sl_calculation supports exactly
these mode-specific keys (omitted keys use the shown defaults): {"mode": "fixed", "sl_points": 100, "tp_points": 100}
{"mode": "range", "range": 60, "sl_ratio": 1.0, "tp_ratio": 1.0} {"mode": "atr", "sl_multiplier": 3.0, "tp_multiplier":
3.0, "atr_period": 14} Unknown keys or unsupported modes raise ValueError. Entry prices default to the bid-based
convention; use entry_price_type="ask" or "mid" when needed. Use start_index and end_index to limit the test data;
end_index is an exclusive endpoint, and -1 (the default) runs through the final bar. Every position is closed by tp, sl,
a tiebreak, or eod, and the result contains profit_equity, dd_equity, and unsupported_signal_count. Set
return_in_points=True to divide position profits, drawdowns, and both equity curves by the symbol point size. The CLI
accepts the same options; pass --sl-calculation as a JSON object and use --return-in-points for point-valued output. Add
--output result.pkl.gz to save the complete result dataclass. Validate Configuration Configuration is not validated on
package import, so import forexgrand_core works before credentials are available. Validate explicitly when you want a
clear setup error: from forexgrand_core.env_validator import validate_environment_on_import
validate_environment_on_import() Build And Publish To PyPI Install build tools: python -m pip install --upgrade build
twine Build the source distribution and wheel: python -m build Check the package: python -m twine check dist/* Upload to
TestPyPI first: python -m twine upload --repository testpypi dist/* Upload to PyPI: python -m twine upload dist/*
Development Run tests: pytest Build locally: python -m build Check imports: import forexgrand_core from forexgrand_core
import configure_r2, Settings License MIT Project links Bug Tracker Documentation Homepage Repository Key dates PyPI
data Data sourced directly from PyPI's database. Released: Sep 4, 2026 Latest release 1 maintainer PyPI data Data
sourced directly from PyPI's database. kudston Credits Author: ForexGrand Team License expression MIT View SPDX License
List Requires Python >=3.9 Provides Extra dev aws gcs cloudflare Tags forex machine-learning deep-learning tensorflow
trading strategy timeseries Classifiers Development Status 3 - Alpha Intended Audience Developers Financial and
Insurance Industry Natural Language English Operating System OS Independent Programming Language Python :: 3 Python ::
3.9 Python :: 3.10 Python :: 3.11 Python :: 3.12 Topic Office/Business :: Financial Software Development :: Libraries
Report project as malware Download files Download the file for your platform. If you're not sure which to choose, learn
more about installing packages. Source Distribution fg_strategy_modelling_core-0.2.5.tar.gz (109.5 kB view details)
Uploaded Sep 4, 2026 Source Built Distribution Filter files by name, interpreter, ABI, and platform. If you're not sure
about the file name format, learn more about wheel file names. The dropdown lists show the available interpreters, ABIs,
and platforms. Enable javascript to be able to filter the list of wheel files. Copy a direct link to the current filters
Copy File name Interpreter Interpreter py3 ABI ABI none Platform Platform any
fg_strategy_modelling_core-0.2.5-py3-none-any.whl (132.4 kB view details) Uploaded Sep 4, 2026 Python 3 File details
Details for the file fg_strategy_modelling_core-0.2.5.tar.gz. File metadata Download URL:
fg_strategy_modelling_core-0.2.5.tar.gz Upload date: Sep 4, 2026 Size: 109.5 kB Tags: Source Uploaded using Trusted
Publishing? No Uploaded via: twine/7.0.0 CPython/3.12.1 File hashes Hashes for fg_strategy_modelling_core-0.2.5.tar.gz
Algorithm Hash digest SHA256 4b72b135a24fc32842915d302af0fc777ea2cab6bee8951cb36d79af9da05ea7 Copy MD5
f89208bb0ff71a592271d4fd97f29c84 Copy BLAKE2b-256 b53d58dc5cdb7f6553e7a6ef577817641a2c492ff9b3db06e11f094f964a7b28 Copy
See more details on using hashes here. File details Details for the file
fg_strategy_modelling_core-0.2.5-py3-none-any.whl. File metadata Download URL:
fg_strategy_modelling_core-0.2.5-py3-none-any.whl Upload date: Sep 4, 2026 Size: 132.4 kB Tags: Python 3 Uploaded using
Trusted Publishing? No Uploaded via: twine/7.0.0 CPython/3.12.1 File hashes Hashes for
fg_strategy_modelling_core-0.2.5-py3-none-any.whl Algorithm Hash digest SHA256
51db35ba3c5461c7daf5a7b15b632bfb8d716bd751152b88efe3b653928d7608 Copy MD5 deeae8c370a47d45d6a37f99603d5cf4 Copy
BLAKE2b-256 c728bb7d4101414ca2d1ca7f1194d8ec9d1baec2472c636e669c0372cc7914f5 Copy See more details on using hashes here.
Release history Release notifications | RSS feed This release 0.2.5 This release Sep 4, 2026 2 files 0.2.4 Aug 31, 2026
2 files 0.2.2 Aug 28, 2026 2 files 0.2.1 Aug 27, 2026 2 files 0.2.0 Aug 26, 2026 2 files 0.1.1 Aug 25, 2026 2 files
0.1.0 Jul 31, 2026 2 files PyPI Developed and maintained by the Python Software Foundation and Python community, for the
Python community. Status: all systems operational Donate today! Help Installing packages Uploading packages User guide
Project name retention FAQs About PyPI PyPI Blog Infrastructure dashboard Statistics Logos & trademarks Our sponsors
Contributing to PyPI Bugs and feedback Contribute on GitHub Translate PyPI Sponsor PyPI Development credits Using PyPI
Terms of Service Report security issue Code of conduct Privacy Notice Acceptable Use Policy Switch to desktop version
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary
sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and
Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page
"PyPI", "Python Package Index", and the blocks logos are registered trademarks of the Python Software Foundation. ©
2026 Python Software Foundation Site map Deployed from cfde89f
