This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
# Example function to place a simulated trade | |
def place_trade(api_url, api_key, trade_details): | |
headers = {'Authorization': f'Bearer {api_key}'} | |
response = requests.post(f'{api_url}/trades', headers=headers, json=trade_details) | |
return response.json() | |
# Trade details | |
trade_details = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from EigenLedger import portfolio_analysis, Engine | |
portfolio = Engine( | |
start_date= "2018-06-09", #start date for the backtesting | |
portfolio= ["BABA", "PDD", "KO", "AMD","^IXIC"], #assets in your portfolio | |
weights = [0.2, 0.2, 0.2, 0.2, 0.2], #equal weighting is set by default | |
benchmark = ["SPY"] #SPY is set by default | |
) | |
portfolio_analysis(portfolio) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ch.algotrader.entity.marketData.MarketDataEvent; | |
import ch.algotrader.entity.trade.Order; | |
import ch.algotrader.strategy.GenericStrategy; | |
import ch.algotrader.util.collection.FixedSizeQueue; | |
public class SMACrossoverStrategy extends GenericStrategy { | |
private final FixedSizeQueue<Double> shortWindow = new FixedSizeQueue<>(10); | |
private final FixedSizeQueue<Double> longWindow = new FixedSizeQueue<>(30); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using QuantConnect.Algorithm; | |
using QuantConnect.Indicators; | |
using QuantConnect.Data.Market; | |
public class SMACrossoverAlgorithm : QCAlgorithm | |
{ | |
private SimpleMovingAverage _smaFast; | |
private SimpleMovingAverage _smaSlow; | |
private decimal _previous; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SMACrossoverAlgorithm(QCAlgorithm): | |
def Initialize(self): | |
self.SetStartDate(2022, 1, 1) | |
self.SetEndDate(2022, 12, 31) | |
self.AddEquity("SPY", Resolution.Daily) | |
self.sma_fast = self.SMA("SPY", 10, Resolution.Daily) | |
self.sma_slow = self.SMA("SPY", 30, Resolution.Daily) | |
self.previous = None | |
def OnData(self, data): |