Skip to content

Instantly share code, notes, and snippets.

View PandaWhoCodes's full-sized avatar

Thomas Ashish Cherian PandaWhoCodes

View GitHub Profile
A
A + Certified
A-110
A-122
A-123
A-133
A-frames
A-GPS
A/B Testing
A/R analysis
To sell only the stocks that are not there in this week's new strategy and keep the stocks that still remain, you can modify the code as follows:
```python
import backtrader as bt
import pandas as pd
# Define the strategy
class MyStrategy(bt.Strategy):
def __init__(self):
import logging
import collections
import threading
import time
from collections import defaultdict
def log_info(message, logger):
logger.info(message)
time.sleep(3)
import logging
import time
import threading
from collections import defaultdict
def log_info(message,logger):
logger.info(message)
time.sleep(3)
logger.info(message)
import logging
import time
import threading
import io
def log_info(message,logger):
logger.info(message)
time.sleep(3)
logger.info(message)
import logging
import time
import threading
logger = logging.getLogger()
# Set up logging
logging.basicConfig(
level=logging.INFO, format="%(asctime)s %(message)s", datefmt="%Y-%m-%d %H:%M:%S"
)
@PandaWhoCodes
PandaWhoCodes / disable_ddl_ops.sql
Last active April 14, 2022 20:50
lock tables from being altered in postgres
CREATE OR REPLACE FUNCTION schema.ddl_issue()
RETURNS event_trigger
LANGUAGE plpgsql
AS $function$
DECLARE r RECORD;
BEGIN
FOR r IN SELECT * FROM pg_event_trigger_ddl_commands() LOOP
IF ( r.objid::regclass::text = 'schema.tablename' )
THEN
RAISE EXCEPTION 'You are not allowed to change %', r.object_identity;
def upload_gziped_df(bucketName, filename, df):
csv_buffer = io.BytesIO()
df.to_csv(csv_buffer, index=False, compression="gzip", encoding="utf-8")
# write stream to S3
s3 = boto3.client("s3")
metadata = {
"Content-Encoding": "gzip",
}
s3.put_object(
@PandaWhoCodes
PandaWhoCodes / gen_v4_sign_urls.py
Last active April 14, 2022 20:41
given the name of the file generates a version 3 signed download url for the file
from botocore.client import Config
import boto3
def gen_url(key):
"""
given the name of the file generates a signed download url for the file
:param key: filename in s3
:return: presigned URL that has AWS4-HMAC-SHA256
"""
expTime = 86400
server {
listen 80;
server_name utils.infoassistants.com;
location / {
proxy_pass http://localhost:3500;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;