Merge pull request #4963 from robcaulk/patch-1

update doc to reflect better empty dataframe check
This commit is contained in:
Matthias 2021-05-21 09:31:16 +02:00 committed by GitHub
commit 10b013dc34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,7 +40,6 @@ class AwesomeStrategy(IStrategy):
!!! Note !!! Note
If the data is pair-specific, make sure to use pair as one of the keys in the dictionary. If the data is pair-specific, make sure to use pair as one of the keys in the dictionary.
## Dataframe access ## Dataframe access
You may access dataframe in various strategy functions by querying it from dataprovider. You may access dataframe in various strategy functions by querying it from dataprovider.
@ -65,8 +64,9 @@ class AwesomeStrategy(IStrategy):
trade_date = timeframe_to_prev_date(self.timeframe, trade.open_date_utc) trade_date = timeframe_to_prev_date(self.timeframe, trade.open_date_utc)
# Look up trade candle. # Look up trade candle.
trade_candle = dataframe.loc[dataframe['date'] == trade_date] trade_candle = dataframe.loc[dataframe['date'] == trade_date]
# trade_candle may be None for trades that just opened as it is still incomplete. # trade_candle may be empty for trades that just opened as it is still incomplete.
if trade_candle is not None: if trade_candle.empty:
trade_candle = trade_candle.squeeze()
# <...> # <...>
``` ```