File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed
Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change 33
44from syscore .objects import get_methods , missing_data
55from syscore .dateutils import ARBITRARY_START
6- from syscore .pdutils import prices_to_daily_prices
6+ from syscore .pdutils import prices_to_daily_prices , intraday_date_rows_in_pd_object
77from sysdata .base_data import baseData
88
99from sysobjects .spot_fx_prices import fxPrices
@@ -107,6 +107,17 @@ def daily_prices(self, instrument_code: str) -> pd.Series:
107107
108108 return dailyprice
109109
110+ def hourly_prices (self , instrument_code : str ) -> pd .Series :
111+ instrprice = self .get_raw_price (instrument_code )
112+ if len (instrprice ) == 0 :
113+ raise Exception ("No adjusted hourly prices for %s" % instrument_code )
114+
115+ intraday_only_prices = intraday_date_rows_in_pd_object (instrprice )
116+ hourly_prices = intraday_only_prices .resample ("H" ).last ()
117+ hourly_prices = hourly_prices .dropna ()
118+
119+ return hourly_prices
120+
110121 def get_fx_for_instrument (
111122 self , instrument_code : str , base_currency : str
112123 ) -> fxPrices :
Original file line number Diff line number Diff line change @@ -470,6 +470,8 @@ def get_maximum_position_contracts_for_instrument_strategy(
470470 self , instrument_strategy : instrumentStrategy
471471 ) -> int :
472472
473+ ## FIXME: THIS WON'T WORK IF THERE ARE MULTIPLE STRATEGIES TRADING AN INSTRUMENT
474+
473475 limit_for_instrument = \
474476 self ._get_position_limit_object_for_instrument (instrument_strategy .instrument_code )
475477
You can’t perform that action at this time.
0 commit comments