-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
Source: https://github.com/openai/evals/blob/main/docs/custom-eval.md as well as the new functions and function_call as per OpenAI's recent announcement.
try:
candles = self.get_oanda_candles(instrument, from_time, granularity, price)
if not candles:
return "Failed to fetch candles."
candles_percentage = self.determine_candles_to_analyze(granularity)
num_candles = int(len(candles) * candles_percentage)
last_candles = candles[-num_candles:]
closing_prices = np.array([float(candle['mid']['c']) for candle in last_candles])
sma_periods = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 25, 30, 40, 50, 100, 200]
smas = {}
for period in sma_periods:
sma = np.mean(closing_prices[-period:])
smas[period] = sma
trailing_sma_average = np.mean(list(smas.values()))
sentiment = 'Uncertain' # Default sentiment
if closing_prices[-1] > trailing_sma_average:
if closing_prices[-1] - trailing_sma_average > 0.1 * trailing_sma_average:
sentiment = 'Very bullish'
else:
sentiment = 'Bullish'
elif closing_prices[-1] < trailing_sma_average:
if trailing_sma_average - closing_prices[-1] > 0.1 * trailing_sma_average:
sentiment = 'Very bearish'
else:
sentiment = 'Bearish'
# Return sentiment and SMAs
return {'sentiment': sentiment, 'smas': smas}
except Exception as e:
print(f"Error analyzing market: {e}")
return {'error': str(e)}```
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels