• Welcome to forex.pm forex forum binary options trade. Please login or sign up.
 

API — Zipline 2.2.0 documentation

Started by PocketOption, Nov 11, 2022, 04:30 am

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

PocketOption

API -- Zipline 2.2.0 documentation

Binary options trading graphs and tables.
The function run_algorithm() creates an instance of TradingAlgorithm that represents a trading strategy and parameters to execute the strategy.
Run a trading algorithm.
start ( datetime ) - The start date of the backtest.
end ( datetime ) - The end date of the backtest..
initialize ( callable [ context -> None ] ) - The initialize function to use for the algorithm. This is called once at the very begining of the backtest and should be used to set up any state needed by the algorithm.
capital_base ( float ) - The starting capital for the backtest.
handle_data ( callable [ ( context , BarData ) -> None ] , optional ) - The handle_data function to use for the algorithm. This is called every minute when data_frequency == 'minute' or every day when data_frequency == 'daily' .
before_trading_start ( callable [ ( context , BarData ) -> None ] , optional ) - The before_trading_start function for the algorithm. This is called once before each trading day (after initialize on the first day).
analyze ( callable [ ( context , pd.DataFrame ) -> None ] , optional ) - The analyze function to use for the algorithm. This function is called once at the end of the backtest and is passed the context and the performance data.
data_frequency ( , 'minute'> , optional ) - The data frequency to run the algorithm at.
bundle ( str , optional ) - The name of the data bundle to use to load the data to run the backtest with. This defaults to 'quantopian-quandl'.
bundle_timestamp ( datetime , optional ) - The datetime to lookup the bundle data for. This defaults to the current time.
trading_calendar ( TradingCalendar , optional ) - The trading calendar to use for your backtest.
metrics_set ( iterable [ Metric ] or str , optional ) - The set of metrics to compute in the simulation. If a string is passed, resolve the set with zipline.finance.metrics.load() .
benchmark_returns ( pd.Series , optional ) - Series of returns to use as the benchmark.
default_extension ( bool , optional ) - Should the default zipline extension be loaded. This is found at $ZIPLINE_ROOT/extension.py.
extensions ( iterable [ str ] , optional ) - The names of any other extensions to load. Each element may either be a dotted module path like a.b.c or a path to a python file ending in .py like a/b/c.py .
strict_extensions ( bool , optional ) - Should the run fail if any extensions fail to load. If this is false, a warning will be raised instead.
environ ( mapping [ str -> str ] , optional ) - The os environment to use. Many extensions use this to get parameters. This defaults to os.environ .
blotter ( str or zipline.finance.blotter.Blotter , optional ) - Blotter to use with this algorithm. If passed as a string, we look for a blotter construction function registered with zipline.extensions.register and call it with no parameters. Default is a zipline.finance.blotter.SimulationBlotter that never cancels orders.
perf - The daily performance of the algorithm.
The available data bundles.
Trading Algorithm API¶
The following methods are available for use in the initialize , handle_data , and before_trading_start API functions.
In all listed functions, the self argument refers to the currently executing TradingAlgorithm instance.
Data Object¶
Provides methods for accessing minutely and daily price/volume data from Algorithm API functions.
Also provides utility methods to determine if an asset is alive, and if it has recent trade data.
An instance of this object is passed as data to handle_data() and before_trading_start() .
data_portal ( DataPortal ) - Provider for bar pricing data.
simulation_dt_func ( callable ) - Function which returns the current simulation time. This is usually bound to a method of TradingSimulation.
data_frequency ( , 'daily'> ) - The frequency of the bar data; i.e. whether the data is daily or minute bars.
restrictions ( zipline.finance.asset_restrictions.Restrictions ) - Object that combines and returns restricted list information from multiple sources.
For the given asset or iterable of assets, returns True if all of the following are true:
The asset is alive for the session of the current simulation time (if current simulation time is not a market minute, we use the next session).
The asset's exchange is open at the current simulation time or at the simulation calendar's next market minute.
There is a known last price for the asset.
assets ( zipline.assets.Asset or iterable of zipline.assets.Asset ) - Asset(s) for which tradability should be determined.
The second condition above warrants some further explanation:
If the asset's exchange calendar is identical to the simulation calendar, then this condition always returns True.
If there are market minutes in the simulation calendar outside of this asset's exchange's trading hours (for example, if the simulation is running on the CMES calendar but the asset is MSFT, which trades on the NYSE), during those minutes, this condition will return False (for example, 3:15 am Eastern on a weekday, during which the CMES is open but the NYSE is closed).
can_trade - Bool or series of bools indicating whether the requested asset(s) can be traded in the current minute.
Returns the "current" value of the given fields for the given assets at the current simulation time.
assets ( zipline.assets.Asset or iterable of zipline.assets.Asset ) - The asset(s) for which data is requested.
fields ( str or iterable [ str ] ) - Requested data field(s). Valid field names are: "price", "last_traded", "open", "high", "low", "close", and "volume".
current_value - See notes below.
Scalar, pandas Series, or pandas DataFrame.
The return type of this function depends on the types of its inputs:
If a single asset and a single field are requested, the returned value is a scalar (either a float or a pd.Timestamp depending on the field).
If a single asset and a list of fields are requested, the returned value is a pd.Series whose indices are the requested fields.
If a list of assets and a single field are requested, the returned value is a pd.Series whose indices are the assets.
If a list of assets and a list of fields are requested, the returned value is a pd.DataFrame . The columns of the returned frame will be the requested fields, and the index of the frame will be the requested assets.
The values produced for fields are as follows:
Requesting "price" produces the last known close price for the asset, forward-filled from an earlier minute if there is no trade this minute. If there is no last known value (either because the asset has never traded, or because it has delisted) NaN is returned. If a value is found, and we had to cross an adjustment boundary (split, dividend, etc) to get it, the value is adjusted to the current simulation time before being returned.
Requesting "open", "high", "low", or "close" produces the open, high, low, or close for the current minute. If no trades occurred this minute, NaN is returned.
Requesting "volume" produces the trade volume for the current minute. If no trades occurred this minute, 0 is returned.
Requesting "last_traded" produces the datetime of the last minute in which the asset traded, even if the asset has stopped trading. If there is no last known value, pd.NaT is returned.
If the current simulation time is not a valid market time for an asset, we use the most recent market close instead.

In case you have virtually any concerns about where in addition to the way to make use of binary options trading graphs and tables, you possibly can contact us at the webpage.

Source: API -- Zipline 2.2.0 documentation

http://binaryoptionsreview.space/?qa=feed&qa_1=qa.rss