0% found this document useful (0 votes)
5 views

algobull_strategy2

The document outlines a trading strategy called the EMA Crossover Strategy, which utilizes the Exponential Moving Average (EMA) to identify buy and sell signals based on historical data. It includes team members' names and IDs, as well as suggested parameters for the strategy, such as a short-term period of 50 and a long-term period of 200. The strategy operates on 15-minute candle sizes with a risk appetite of 3%.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

algobull_strategy2

The document outlines a trading strategy called the EMA Crossover Strategy, which utilizes the Exponential Moving Average (EMA) to identify buy and sell signals based on historical data. It includes team members' names and IDs, as well as suggested parameters for the strategy, such as a short-term period of 50 and a long-term period of 200. The strategy operates on 15-minute candle sizes with a risk appetite of 3%.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Team Details

nishchay Chaudhary (2023uma0226)


Gaurav krishna (2023uma0212)
Aryan singh (2023uma0205)
jay mangal pandey (2023uma0216)

strategy

import talib
from pyalgotrading.strategy import StrategyBase

class EMACrossoverStrategy(StrategyBase):
name = 'EMA Crossover Strategy'

def _init_(self, *args, **kwargs):


super()._init_(*args, **kwargs)
self.short_term_period = 50
self.long_term_period = 200
self.main_order_map = None

def initialize(self):
self.main_order_map = {}

def get_crossover(self, instrument):


hist_data = self.get_historical_data(instrument)
short_term_ema = talib.EMA(hist_data['close'],
timeperiod=self.short_term_period)
long_term_ema = talib.EMA(hist_data['close'],
timeperiod=self.long_term_period)

buy_crossover = self.utils.crossover(short_term_ema, long_term_ema)


sell_crossover = self.utils.crossover(long_term_ema, short_term_ema)

return buy_crossover, sell_crossover

def strategy_select_instruments_for_entry(self, candle, instruments_bucket):


selected_instruments, meta = [], []

for instrument in instruments_bucket:


if self.main_order_map.get(instrument) is None:
buy_crossover, sell_crossover = self.get_crossover(instrument)

if buy_crossover:
selected_instruments.append(instrument)
meta.append({'action': 'BUY'})

return selected_instruments, meta

def strategy_enter_position(self, candle, instrument, sideband_info):


self.main_order_map[instrument] = _ = self.broker.OrderRegular(instrument,
sideband_info['action'], quantity=self.number_of_lots * instrument.lot_size)
return _

def strategy_select_instruments_for_exit(self, candle, instruments_bucket):


selected_instruments, meta = [], []

for instrument in instruments_bucket:


if self.main_order_map.get(instrument) is not None:
buy_crossover, sell_crossover = self.get_crossover(instrument)

if sell_crossover:
selected_instruments.append(instrument)
meta.append({'action': 'EXIT'})

return selected_instruments, meta

def strategy_exit_position(self, candle, instrument, sideband_info):


if sideband_info['action'] == 'EXIT':
self.main_order_map[instrument].exit_position()
self.main_order_map[instrument] = None
return True

return False

# Suggested Parameters
strategy_parameters = {
'TIMEPERIOD1': 50,
'TIMEPERIOD2': 200
}

candle size - 15 minute


risk appetite- 3%

You might also like