Skip to content

Instantly share code, notes, and snippets.

@marcosan93
Created January 3, 2022 18:33
Show Gist options
  • Select an option

  • Save marcosan93/28e5cf11045bbe8b720f3061ec55fa72 to your computer and use it in GitHub Desktop.

Select an option

Save marcosan93/28e5cf11045bbe8b720f3061ec55fa72 to your computer and use it in GitHub Desktop.
# Adding sentiment positions to the forecast DF
positions = pred_df.merge(
sent_df,
right_index=True,
left_index=True,
how='inner'
)
# Getting forecast prophet positions
positions['fbp_positions'] = positions.apply(
lambda x: fbpPositions(x, short=True),
axis=1
)
# Getting the overall positions of prophet and sentiment
positions['news_and_fbp'] = positions.apply(
lambda x: overallPosition(x),
axis=1
)
# Buy and hold position
positions['buy_hold'] = 1
# Random positions
positions['random_positions'] = random.choices(
[1,0,-1], k=len(positions)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment