我正在使用pyalgotrade交易策略,我想在列表中使用多个代码.
它现在的设置方式,它为列表中的每个单独的股票代码运行策略,但我希望它做的是将它们全部作为一个复合策略运行.
我该怎么做呢?
这是代码:
from pyalgotrade.tools import yahoofinance
from pyalgotrade import strategy
from pyalgotrade.barfeed import yahoofeed
from pyalgotrade.technical import stoch
from pyalgotrade import dataseries
from pyalgotrade.technical import ma
from pyalgotrade import technical
from pyalgotrade.technical import highlow
from pyalgotrade import talibext
from pyalgotrade.talibext import indicator
import numpy as np
import talib
testlist = ['aapl', 'msft', 'z']
class MyStrategy( strategy.BacktestingStrategy ):
def __init__( self, feed, instrument ):
strategy.BacktestingStrategy.__init__( self, feed )
self.__position = []
self.__instrument = instrument
self.setUseAdjustedValues( True ) …Run Code Online (Sandbox Code Playgroud) python quantitative-finance yahoo-finance pyalgotrade ta-lib
但是我不想使用来自yahoo!finance的数据,我想用我自己的但无法弄清楚如何解析CSV,它的格式如下:
Timestamp Low Open Close High BTC_vol USD_vol [8] [9]
2013-11-23 00 800 860 847.666666 886.876543 853.833333 6195.334452 5248330 0
2013-11-24 00 745 847.5 815.01 860 831.255 10785.94131 8680720 0
Run Code Online (Sandbox Code Playgroud)
我想做的事情如下:
def main(plot):
instruments = ["AA", "AES", "AIG"]
feed = yahoofinance.build_feed(instruments, 2008, 2009, ".")
Run Code Online (Sandbox Code Playgroud)
然后yahoofinance.build_feed(instruments, 2008, 2009, ".")用我的替换CSV
我试过了:
import csv
with open( 'FinexBTCDaily.csv', 'rb' ) as csvfile:
data = csv.reader( csvfile )
def main( plot ): …Run Code Online (Sandbox Code Playgroud) csv algorithmic-trading quantitative-finance pyalgotrade back-testing