Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

alphagens

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

alphagens

An event-driven backtesting system

  • 0.5.5
  • Source
  • PyPI
  • Socket score

Maintainers
1

AlphaGens


An agent-environment based backtesting framework.

Event-Driven backtesting


class BuyAndHold(BaseStrategy):
    def __init__(self, engine, broker, account):
        super().__init__(engine, broker, account)
    
    def before_trading_end(self):
        if self.current_date == self.trade_dates[0]:
            self.account.order_target_pct_to(pd.Series(1, index=["000001"]))

quick start


class BuyAndHold(BaseAgent):
    def __init__(self, data):
        super().__init__(data)
        self.i = -1
    
    def take_action(self, state, date):
        self.buffer.append(state)
        self.i += 1
        if self.i == 0:
            target_positions = np.array([0.2 for i in range(5)]) 
            return target_positions
        else:
            return NO_ACTION
while True:
    try:
        print(f"current date is {env.current_date}")
        action = agent.take_action(state, env.current_date)
    
        next_state, reward, truncated, terminated, info = env.step(action)
        state = next_state
        returns.append(reward)

    except IndexError:
        break

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc