TheForexenvironmentisaforextradingsimulatorfeaturing:configurableinitialcapital,dynamicordataset-basedspread,CSVhistorytimeseriesfortradingcurrenciesandobservationsfortheagent,fixedoragent-controlledtake-profit,stop-lossandordervolume.
Theenvironmentfeaturesdiscreteactionspacesandoptionallycontinuousactionspacesiftheordersdonthavefixedtake-profit/stop-lossandordervolume.
ObservationSpaceAconcatenationofnum_ticksvectorsforthelastest:vectorofvaluesfromtimeseries,equityanditsvariation,order_status(-1=closed,1=opened),time_opened(normalizedwithmax_order_time),order_profitanditsvariation,order_drawdown/order_volume_pips,consecutive_drawdown/max_consecutive_dd
ActionSpacediscreteaction0:0=nop,1=close,2=buy,3=selldiscreteaction0parameter:symbol(optional)continuousaction0parameter:percent_tp,percent_sl,percent_max
RewardFunctionTherewardfunctionistheaverageoftheareaunderthecurveofequityandthebalancevariation.
MQL4DatasetGeneratorThedatasetsusedforthetestsweregeneratedwithaMQL4programlocatedintheagentsfolder(Pendingdocumentation).
InstallationStep1-SetupDependenciesInstallPython,pip,OpenAIGymandotherdependencies:
sudoapt-getinstall-ypython3-numpypython3-devcmakezlib1g-devlibjpeg-devxvfbffmpeglibboost-all-devlibsdl2-devpython3-pipgitgccmakeperl
pip3installgraphvizneat-pythongitpythongymneat-pythonmatplotlib
Step2-Setupgym-forexfromGitHubgitclonehttps://github.com/harveybc/gym-forex
Step3-ConfiguretheNEATparametersSetthePYTHONPATHvenvironmentvariable,youmayaddthefollowinglinetothe.profilefileinyourhomedirectorytoexportonstartofsessions.Replacewithyourusername.
exportPYTHONPATH=/home/username/gym-forex/:${PYTHONPATH}
Step4-ConfiguretheNEATparameterscdgym-forexnanoagents/config
Configurethepopulationsizeandotherparametersaccordingtoyourcomputingcapacityorrequirements,startwiththedefaults.
Step5-Configureastartup/restartscriptnanores
Forexample:
#!/bin/bashgitpullpython3agents/agent_NEAT.py./datasets/ts_5min_1w.CSV./datasets/vs_5min_1w.CSVconfig_20
Afterediting,changethepermissionofthefiletobeexecutable:
chmod777res
Step6-Startyouroptimizerthatusesthegym-forexenvironmentandanagent../res
评论