Hi there,
I am just testing zipline-reloaded for the first time and am getting unexpected results. My algo looks like this:
from zipline import run_algorithm
import pandas as pd
from zipline.api import symbol, order_target_percent
from zipline.finance import commission, slippage
def initialize(context):
context.asset = symbol('AAPL')
context.set_commission(commission.PerDollar(cost=0.00))
context.set_slippage(slippage.FixedSlippage(spread=0.0))
context.has_ordered = False
def handle_data(context, data):
if not context.has_ordered:
order_target_percent(context.asset, 1.0)
context.has_ordered = True
def analyze(context, perf):
pass
if __name__ == "__main__":
start_date = pd.Timestamp('2019-01-01')
end_date = pd.Timestamp('2022-12-31')
result = run_algorithm(
start=start_date,
end=end_date,
initialize=initialize,
handle_data=handle_data,
analyze=analyze,
capital_base=20000,
data_frequency='daily',
bundle='custom'
)
I have installed the package with python 3.11 on a linux environment.
Now when I check the results, my algo is always keeping 10% of the capital uninvested. Not sure why it does this or where is this set, but I have used the algo on python 3.8 using windows, and there it doestn do that.
Does anybody know what is happening here?
Many thanks.
Best,
Chris