René's URL Explorer Experiment


Title: Compare agents1.py · Issue #7 · six519/PastebinPython · GitHub

Open Graph Title: Compare agents1.py · Issue #7 · six519/PastebinPython

X Title: Compare agents1.py · Issue #7 · six519/PastebinPython

Description: """ Compare PPO, A2C, and DQN on MT5 trading environment. Each agent is trained separately Results (mean reward) are logged """ import time import numpy as np import pandas as pd import gym from gym import spaces import MetaTrader5 as mt...

Open Graph Description: """ Compare PPO, A2C, and DQN on MT5 trading environment. Each agent is trained separately Results (mean reward) are logged """ import time import numpy as np import pandas as pd import gym from gy...

X Description: """ Compare PPO, A2C, and DQN on MT5 trading environment. Each agent is trained separately Results (mean reward) are logged """ import time import numpy as np import p...

Opengraph URL: https://github.com/six519/PastebinPython/issues/7

X: @github

direct link

Domain: patch-diff.githubusercontent.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Compare agents1.py","articleBody":"\"\"\"\nCompare PPO, A2C, and DQN on MT5 trading environment.\n- Each agent is trained separately\n- Results (mean reward) are logged\n\"\"\"\n\nimport time\nimport numpy as np\nimport pandas as pd\nimport gym\nfrom gym import spaces\nimport MetaTrader5 as mt5\n\nfrom stable_baselines3 import PPO, A2C, DQN\nfrom stable_baselines3.common.vec_env import DummyVecEnv\nfrom stable_baselines3.common.evaluation import evaluate_policy\n\n# -------------------------\n# CONFIG\n# -------------------------\nSYMBOL = \"EURUSD\"\nTIMEFRAME = mt5.TIMEFRAME_M5\nLOOKBACK = 50\nTRAIN_TIMESTEPS = 20000\nN_BARS = 5000\nSEED = 42\n# -------------------------\n\n# -------------------------\n# MT5 Connection\n# -------------------------\ndef mt5_connect():\n    if not mt5.initialize():\n        raise RuntimeError(f\"MT5 init failed: {mt5.last_error()}\")\n    if not mt5.symbol_select(SYMBOL, True):\n        raise RuntimeError(f\"Could not select {SYMBOL}\")\n\ndef mt5_shutdown():\n    mt5.shutdown()\n\ndef fetch_bars(symbol, timeframe, n_bars):\n    rates = mt5.copy_rates_from_pos(symbol, timeframe, 0, n_bars)\n    if rates is None:\n        raise RuntimeError(f\"Failed to fetch data: {mt5.last_error()}\")\n    df = pd.DataFrame(rates)\n    df['time'] = pd.to_datetime(df['time'], unit='s')\n    return df\n\n# -------------------------\n# Custom Gym Env\n# -------------------------\nclass MT5TradingEnv(gym.Env):\n    def __init__(self, df, lookback=LOOKBACK):\n        super().__init__()\n        self.df = df.reset_index(drop=True)\n        self.lookback = lookback\n        self.ptr = lookback\n        self.position = 0\n        self.entry_price = 0\n        self.observation_space = spaces.Box(low=-np.inf, high=np.inf,\n                                            shape=(lookback+1,), dtype=np.float32)\n        self.action_space = spaces.Discrete(3)  # 0=hold, 1=buy, 2=sell\n\n    def _get_obs(self):\n        closes = self.df.loc[self.ptr-self.lookback:self.ptr-1, \"close\"].values.astype(np.float32)\n        norm = closes / (closes[-1] + 1e-9) - 1.0\n        return np.concatenate([norm, [float(self.position)]], axis=0)\n\n    def reset(self):\n        self.ptr = self.lookback\n        self.position = 0\n        self.entry_price = 0\n        return self._get_obs()\n\n    def step(self, action):\n        done, reward = False, 0\n        price = float(self.df.loc[self.ptr, \"close\"])\n        if action == 1:  # buy\n            if self.position == 0:\n                self.position, self.entry_price = 1, price\n            elif self.position == -1:\n                reward += (self.entry_price - price)\n                self.position, self.entry_price = 1, price\n        elif action == 2:  # sell\n            if self.position == 0:\n                self.position, self.entry_price = -1, price\n            elif self.position == 1:\n                reward += (price - self.entry_price)\n                self.position, self.entry_price = -1, price\n\n        self.ptr += 1\n        if self.ptr \u003e= len(self.df):\n            done = True\n        else:\n            next_price = float(self.df.loc[self.ptr, \"close\"])\n            if self.position == 1:\n                reward += (next_price - self.entry_price) * 0.1\n            elif self.position == -1:\n                reward += (self.entry_price - next_price) * 0.1\n\n        obs = self._get_obs() if not done else np.zeros(self.observation_space.shape, dtype=np.float32)\n        return obs, float(reward), done, {}\n\n# -------------------------\n# Training \u0026 Evaluation\n# -------------------------\ndef run_comparison():\n    mt5_connect()\n    df = fetch_bars(SYMBOL, TIMEFRAME, N_BARS)\n    mt5_shutdown()\n\n    results = {}\n    agents = {\n        \"PPO\": PPO,\n        \"A2C\": A2C,\n        \"DQN\": DQN\n    }\n\n    for name, algo in agents.items():\n        print(f\"\\n=== Training {name} ===\")\n        env = DummyVecEnv([lambda: MT5TradingEnv(df, lookback=LOOKBACK)])\n        model = algo(\"MlpPolicy\", env, verbose=0, seed=SEED)\n        model.learn(total_timesteps=TRAIN_TIMESTEPS)\n        mean_reward, std_reward = evaluate_policy(model, env, n_eval_episodes=5)\n        results[name] = (mean_reward, std_reward)\n        print(f\"{name} → mean reward: {mean_reward:.2f}, std: {std_reward:.2f}\")\n\n    print(\"\\n=== Summary ===\")\n    for k, v in results.items():\n        print(f\"{k}: mean {v[0]:.2f}, std {v[1]:.2f}\")\n\nif __name__ == \"__main__\":\n    run_comparison()","author":{"url":"https://github.com/vicks4u","@type":"Person","name":"vicks4u"},"datePublished":"2025-09-16T01:34:59.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/7/PastebinPython/issues/7"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:3e393dc9-24eb-2576-af89-9ff01e478400
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idA554:3197C5:2126091:2A61DB1:6975E8CA
html-safe-nonce20452040244110b14fd05e1b5ac7dd0f2d9089f0819649dd611e3cc1cae3f1a8
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNTU0OjMxOTdDNToyMTI2MDkxOjJBNjFEQjE6Njk3NUU4Q0EiLCJ2aXNpdG9yX2lkIjoiNzI4OTMyNjk1MzYwNzU4ODA0MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac8ea2b95ec14fa656a2132c0f919c9fa95073382781b971f42b546e54138cb522
hovercard-subject-tagissue:3420007604
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/six519/PastebinPython/7/issue_layout
twitter:imagehttps://opengraph.githubassets.com/0611f8dbcd6ecb44603cddbaf5e1e811fea1a5fc09c3e75f4baa717f63e9fb6a/six519/PastebinPython/issues/7
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/0611f8dbcd6ecb44603cddbaf5e1e811fea1a5fc09c3e75f4baa717f63e9fb6a/six519/PastebinPython/issues/7
og:image:alt""" Compare PPO, A2C, and DQN on MT5 trading environment. Each agent is trained separately Results (mean reward) are logged """ import time import numpy as np import pandas as pd import gym from gy...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamevicks4u
hostnamegithub.com
expected-hostnamegithub.com
None2bce766e7450b03e00b2fc5badd417927ce33a860e78cda3e4ecb9bbd1374cc6
turbo-cache-controlno-preview
go-importgithub.com/six519/PastebinPython git https://github.com/six519/PastebinPython.git
octolytics-dimension-user_id483547
octolytics-dimension-user_loginsix519
octolytics-dimension-repository_id8210586
octolytics-dimension-repository_nwosix519/PastebinPython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id8210586
octolytics-dimension-repository_network_root_nwosix519/PastebinPython
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasefcca2b8ef702b5f7f91427a6e920fa44446fe312
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://patch-diff.githubusercontent.com/six519/PastebinPython/issues/7#start-of-content
https://patch-diff.githubusercontent.com/
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsix519%2FPastebinPython%2Fissues%2F7
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsix519%2FPastebinPython%2Fissues%2F7
Sign up https://patch-diff.githubusercontent.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=six519%2FPastebinPython
Reloadhttps://patch-diff.githubusercontent.com/six519/PastebinPython/issues/7
Reloadhttps://patch-diff.githubusercontent.com/six519/PastebinPython/issues/7
Reloadhttps://patch-diff.githubusercontent.com/six519/PastebinPython/issues/7
six519 https://patch-diff.githubusercontent.com/six519
PastebinPythonhttps://patch-diff.githubusercontent.com/six519/PastebinPython
Notifications https://patch-diff.githubusercontent.com/login?return_to=%2Fsix519%2FPastebinPython
Fork 48 https://patch-diff.githubusercontent.com/login?return_to=%2Fsix519%2FPastebinPython
Star 90 https://patch-diff.githubusercontent.com/login?return_to=%2Fsix519%2FPastebinPython
Code https://patch-diff.githubusercontent.com/six519/PastebinPython
Issues 4 https://patch-diff.githubusercontent.com/six519/PastebinPython/issues
Pull requests 0 https://patch-diff.githubusercontent.com/six519/PastebinPython/pulls
Actions https://patch-diff.githubusercontent.com/six519/PastebinPython/actions
Projects 0 https://patch-diff.githubusercontent.com/six519/PastebinPython/projects
Wiki https://patch-diff.githubusercontent.com/six519/PastebinPython/wiki
Security 0 https://patch-diff.githubusercontent.com/six519/PastebinPython/security
Insights https://patch-diff.githubusercontent.com/six519/PastebinPython/pulse
Code https://patch-diff.githubusercontent.com/six519/PastebinPython
Issues https://patch-diff.githubusercontent.com/six519/PastebinPython/issues
Pull requests https://patch-diff.githubusercontent.com/six519/PastebinPython/pulls
Actions https://patch-diff.githubusercontent.com/six519/PastebinPython/actions
Projects https://patch-diff.githubusercontent.com/six519/PastebinPython/projects
Wiki https://patch-diff.githubusercontent.com/six519/PastebinPython/wiki
Security https://patch-diff.githubusercontent.com/six519/PastebinPython/security
Insights https://patch-diff.githubusercontent.com/six519/PastebinPython/pulse
New issuehttps://patch-diff.githubusercontent.com/login?return_to=https://github.com/six519/PastebinPython/issues/7
New issuehttps://patch-diff.githubusercontent.com/login?return_to=https://github.com/six519/PastebinPython/issues/7
Compare agents1.pyhttps://patch-diff.githubusercontent.com/six519/PastebinPython/issues/7#top
https://github.com/vicks4u
https://github.com/vicks4u
vicks4uhttps://github.com/vicks4u
on Sep 16, 2025https://github.com/six519/PastebinPython/issues/7#issue-3420007604
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.