-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
38 lines (33 loc) · 1.38 KB
/
main.py
File metadata and controls
38 lines (33 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from strategies import PivotPoints
from pyalgotrade import bar
from pyalgotrade.barfeed import csvfeed
import os
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
def get_filepath(relative_file_path):
''' Helper function to get the absolute filepath from root programmatically. '''
filepath = os.path.join(ROOT_DIR, *relative_file_path.replace('/', ' ').split())
return filepath
def get_generic_feed(instrument, relative_filepath, frequency):
# feed.setBarFilter(csvfeed.DateRangeFilter(firstDate,endDate))
feed = csvfeed.GenericBarFeed(frequency)
feed.addBarsFromCSV(instrument, get_filepath(relative_filepath))
return feed
def main(plot):
# Miscellaneous settings
instrument = "EURUSD1"
frequency = bar.Frequency.MINUTE
relative_filepath = 'data/forex/EURUSD1_small_2.csv'
feed = get_generic_feed(instrument, relative_filepath, frequency)
# ---------------------------------------------------------
# Strategy settings
vwapWindowSize = 30
threshold = 0.001
# ---------------------------------------------------------
# Strategy
strategy = PivotPoints.PivotPointMomentum(feed, instrument, vwapWindowSize, threshold)
# ---------------------------------------------------------
# Run Strategy
strategy.run()
# ---------------------------------------------------------
if __name__ == "__main__":
main(True)