MCPcopy Create free account
hub / github.com/DVampire/FinAgent / get_state

Method get_state

finagent/environment/trading.py:117–154  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

115 return self.cash + self.position * price
116
117 def get_state(self):
118
119 state = {}
120
121 days_ago = self.prices_df.index[self.day - self.look_back_days]
122 days_future = self.prices_df.index[min(self.day + self.look_forward_days, len(self.prices_df) - 1)]
123
124 price = self.prices_df[self.prices_df.index <= days_future]
125 price = price[price.index >= days_ago]
126
127 news = self.news_df[self.news_df.index <= days_future]
128 news = news[news.index >= days_ago]
129
130 if self.guidances_df is not None:
131 guidance = self.guidances_df[self.guidances_df.index <= days_future]
132 guidance = guidance[guidance.index >= days_ago]
133 else:
134 guidance = None
135
136 if self.sentiments_df is not None:
137 sentiment = self.sentiments_df[self.sentiments_df.index <= days_future]
138 sentiment = sentiment[sentiment.index >= days_ago]
139 else:
140 sentiment = None
141
142 if self.economics_df is not None:
143 economic = self.economics_df[self.economics_df.index <= days_future]
144 economic = economic[economic.index >= days_ago]
145 else:
146 economic = None
147
148 state["price"] = price
149 state["news"] = news
150 state["guidance"] = guidance
151 state["sentiment"] = sentiment
152 state["economic"] = economic
153
154 return state
155
156 def reset(self, **kwargs):
157 self.day = self.init_day

Callers 2

resetMethod · 0.95
stepMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected