TradingStrategyDataSource#
tradingstrategy.frameworks.qstrader.TradingStrategyDataSource Python class in Trading Strategy framework.
- class TradingStrategyDataSource[source]#
Bases:
object
QSTrader daily price integration for Capitalgram dataframe object.
- __init__(exchange_universe, pair_universe, candle_universe, price_look_back_candles=5)[source]#
- Parameters:
exchange_universe (ExchangeUniverse) –
pair_universe (PandasPairUniverse) –
candle_universe (GroupedCandleUniverse) –
price_look_back_candles – For low liquidity assets that may have no data at the certain data point, how many candles look back t
Methods
__init__
(exchange_universe, pair_universe, ...)- param exchange_universe:
get_ask
(dt, pair_id[, complain])get_assets_historical_closes
(start_dt, ...)Obtain a multi-asset historical range of closing prices as a DataFrame, indexed by timestamp with asset symbols as columns.
get_bid
(dt, pair_id[, complain])Get a bid price for an asset at a certain timestamp.
get_price
(dt, pair_id[, ohlc, complain])Get a price for a trading pair base pair from candle data.
- __init__(exchange_universe, pair_universe, candle_universe, price_look_back_candles=5)[source]#
- Parameters:
exchange_universe (ExchangeUniverse) –
pair_universe (PandasPairUniverse) –
candle_universe (GroupedCandleUniverse) –
price_look_back_candles – For low liquidity assets that may have no data at the certain data point, how many candles look back t
- get_price(dt, pair_id, ohlc='Open', complain=False)[source]#
Get a price for a trading pair base pair from candle data.
If there is no candle (no trades at the day), look for a previous day.
- get_bid(dt, pair_id, complain=False)[source]#
Get a bid price for an asset at a certain timestamp.
LIMITATIONS: - Assume using daily bars - Use opening price of each candle
- get_assets_historical_closes(start_dt, end_dt, assets)[source]#
Obtain a multi-asset historical range of closing prices as a DataFrame, indexed by timestamp with asset symbols as columns.
Parameters#
- start_dtpd.Timestamp
The starting datetime of the range to obtain.
- end_dtpd.Timestamp
The ending datetime of the range to obtain.
- assetslist[str]
The list of asset symbols to obtain closing prices for.
Returns#
- pd.DataFrame
The multi-asset closing prices DataFrame.