How to trade #Bitcoin with #ChatGPT and Jesse.

How to trade #Bitcoin with #ChatGPT and Jesse.


ChatGPT is an AI assistant available to anyone online. It is trained to return coherent answers to natural language like queries in many knowledge domains. This means we can prompt it for answers to questions covering many fields including finance, trading and computing. Jesse is a simple opensource Python framework for algo trading.

Now, I show you how to use both tools to trade #Bitcoin profitably. If you don't know what Bitcoin is please click here.

  1. Have a research mindset: This is about alpha discovery. Or learning the process to trade Bitcoin like the most successful #crypto traders. Patience and a long term view are key.
  2. Create an OpenAI account. Follow the link and instructions to open an account and nagivate your way to the app, which looks like the image below. Now get ready to explore the power of ChatGPT.

No alt text provided for this image

3. Discover different trading strategies:

No alt text provided for this image
No alt text provided for this image


No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image

4. Choose a strategy:

No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image

5. Design your strategy:

No alt text provided for this image
No alt text provided for this image


import pandas as p


# Load historical data
df = pd.read_csv('bitcoin_data.csv')

# Calculate 20-day high and low prices
df['20_day_high'] = df['Close'].rolling(window=20).max()
df['20_day_low'] = df['Close'].rolling(window=20).min()

# Define the breakout signal
df['breakout'] = ((df['Close'] > df['20_day_high'].shift(1)) | (df['Close'] < df['20_day_low'].shift(1)))

# Set up initial trade parameters
position = 0
stop_loss = 0.05

# Loop through the data and execute trades based on the breakout signal
for i in range(1, len(df)):
? ? if df['breakout'][i] and position == 0:
? ? ? ? entry_price = df['Close'][i]
? ? ? ? stop_loss_price = entry_price - (entry_price * stop_loss)
? ? ? ? position = 1
? ? elif df['breakout'][i] and position == 1:
? ? ? ? if df['Close'][i] < stop_loss_price:
? ? ? ? ? ? exit_price = stop_loss_price
? ? ? ? else:
? ? ? ? ? ? exit_price = df['Close'][i]
? ? ? ? pnl = (exit_price - entry_price) / entry_price
? ? ? ? position = 0
? ? ? ? print(f"Trade exited at {exit_price}. PNL: {pnl}")
? ? elif position == 1 and i == len(df) - 1:
? ? ? ? exit_price = df['Close'][i]
? ? ? ? pnl = (exit_price - entry_price) / entry_price
? ? ? ? position = 0
? ? ? ? print(f"Trade exited at {exit_price}. PNL: {pnl}")

        



No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image

By prompting ChatGPT we now have a strategy we can backtest. Tune in next time for part 2 where I show you how to use Jesse to backtest your strategy or trade live. Please note nothing in this article constitute financial advice.

要查看或添加评论,请登录

Michael Toye Faleti的更多文章