working code
Browse files- app.py +13 -1
- instructions.md +1 -1
app.py
CHANGED
@@ -77,7 +77,7 @@ def fetch_forex_intraday(api_key, from_symbol, to_symbol, interval, outputsize='
|
|
77 |
data = response.json()
|
78 |
|
79 |
# Extracting the time series data from the JSON object
|
80 |
-
time_series_key = 'Time Series FX (' + interval + ')'
|
81 |
forex_data = pd.DataFrame(data[time_series_key]).T
|
82 |
forex_data.columns = ['Open', 'High', 'Low', 'Close']
|
83 |
|
@@ -219,6 +219,18 @@ def should_trade(strategy, api_endpoint, api_key, base_currency, quote_currency)
|
|
219 |
import backtrader as bt
|
220 |
|
221 |
def run_backtest(api_key, from_symbol, to_symbol, interval):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
222 |
# Set up Cerebro engine
|
223 |
cerebro = bt.Cerebro()
|
224 |
cerebro.addstrategy(TrendFollowingStrategy)
|
|
|
77 |
data = response.json()
|
78 |
|
79 |
# Extracting the time series data from the JSON object
|
80 |
+
time_series_key = 'Time Series FX (' + str(interval) + ')'
|
81 |
forex_data = pd.DataFrame(data[time_series_key]).T
|
82 |
forex_data.columns = ['Open', 'High', 'Low', 'Close']
|
83 |
|
|
|
219 |
import backtrader as bt
|
220 |
|
221 |
def run_backtest(api_key, from_symbol, to_symbol, interval):
|
222 |
+
"""
|
223 |
+
Run a backtest using the specified API key, currency symbols, and interval.
|
224 |
+
|
225 |
+
Parameters:
|
226 |
+
- api_key (str): The API key for accessing the data.
|
227 |
+
- from_symbol (str): The base currency symbol.
|
228 |
+
- to_symbol (str): The quote currency symbol.
|
229 |
+
- interval (str): The time interval for the data.
|
230 |
+
|
231 |
+
Returns:
|
232 |
+
- html_message (str): An HTML message containing the calculated statistics, trade log, and trade decision information.
|
233 |
+
"""
|
234 |
# Set up Cerebro engine
|
235 |
cerebro = bt.Cerebro()
|
236 |
cerebro.addstrategy(TrendFollowingStrategy)
|
instructions.md
CHANGED
@@ -18,6 +18,6 @@ This script is for research purposes only and is not intended for actual trading
|
|
18 |
|
19 |
Code Documentation
|
20 |
------------------
|
21 |
-
[README.md](README.md)
|
22 |
---
|
23 |
|
|
|
18 |
|
19 |
Code Documentation
|
20 |
------------------
|
21 |
+
* [README.md](https://huggingface.co/spaces/tosin2013/forex-research/blob/main/README.md)
|
22 |
---
|
23 |
|