Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions algo.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import alpaca_trade_api as tradeapi
import requests
import time
from ta import macd
import ta
import numpy as np
from datetime import datetime, timedelta
from pytz import timezone
Expand Down Expand Up @@ -224,7 +224,7 @@ async def handle_second_bar(conn, channel, data):
volume_today[symbol] > 30000
):
# check for a positive, increasing MACD
hist = macd(
hist = ta.trend.macd(
minute_history[symbol]['close'].dropna(),
n_fast=12,
n_slow=26
Expand All @@ -234,7 +234,7 @@ async def handle_second_bar(conn, channel, data):
not (hist[-3] < hist[-2] < hist[-1])
):
return
hist = macd(
hist = ta.trend.macd(
minute_history[symbol]['close'].dropna(),
n_fast=40,
n_slow=60
Expand Down Expand Up @@ -287,7 +287,7 @@ async def handle_second_bar(conn, channel, data):
# Sell for a loss if it's fallen below our stop price
# Sell for a loss if it's below our cost basis and MACD < 0
# Sell for a profit if it's above our target price
hist = macd(
hist = ta.trend.macd(
minute_history[symbol]['close'].dropna(),
n_fast=13,
n_slow=21
Expand Down