This file contains 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
//authenticate hf with token | |
import huggingface_hub | |
huggingface_hub.login() | |
//Use the model | |
sentiment_pipeline = pipeline("sentiment-analysis", model="distilbert-base-uncased-finetuned-sst-2-english") | |
result = sentiment_pipeline("Tesla's latest earnings report exceeded expectations, leading to a surge in stock price.") | |
print(result) |
This file contains 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
# load data frame in google sheet | |
import gspread | |
from google.oauth2.service_account import Credentials | |
from google.auth import default | |
# Define the scope of access you need | |
scope = ['https://spreadsheets.google.com/feeds', | |
'https://www.googleapis.com/auth/drive'] | |
creds, _ = default() |
This file contains 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 {google} from 'googleapis' | |
export async function getSheetData() { | |
const auth = new google.auth.GoogleAuth({ | |
credentials: { | |
client_email: process.env.SERVICE_EMAIL, | |
private_key: process.env.SERVICE_KEY.replace(/\\n/g, "\n"), | |
}, | |
scopes: ['https://www.googleapis.com/auth/spreadsheets.readonly'] |
This file contains 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
//target type | |
export type LatestInvoice = { | |
id: string; | |
name: string; | |
image_url: string; | |
email: string; |
This file contains 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
UPDATE TABLE_NAME SET COL1= REPLACE(COL1,'''','"') |
This file contains 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
static class BackgroundDataFetcher | |
{ | |
private static int batchSize = 2; | |
public static BindingList<LedgerModel> ledgers = new BindingList<LedgerModel>(); | |
public static async Task FetchAsync(int ledId = 0) | |
{ | |
try | |
{ | |
This file contains 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
# I encounter proplem while using Historical data | |
# For yfinance most of the case the data is in good shape | |
# The first thing I am looking for index column, of numbers. if it exist, need to replace with datetime | |
# the last thing I want make sure that the date column is in panda datetime type otherwise have to covert it. | |
df =pd.DataFrame(data['Success']) | |
df =df[['datetime','open','high','low','close','volume']] | |
df['datetime']= pd.to_datetime(df['datetime']) | |
df.set_index('datetime', inplace=True) |
This file contains 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 pandas as pd | |
import numpy as np | |
series=pd.read_excel(r'C:/Users/hp/OneDrive/documents/mahdata.xlsx',sheet_name='EASY', usecols='B:G',header=None, | |
index_col=False) | |
series= series.to_numpy() | |
data = np.flip(series,axis=0) |
This file contains 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
Managing conda environments | |
It is recommended to install Zipline in an isolated conda environment. Installing Zipline in conda environments will not interfere your default Python deployment or site-packages, which will prevent any possible conflict with your global libraries. For more information on conda environment, see the Conda User Guide. | |
Assuming conda has been set up, you can create a conda environment: | |
$ conda create -n env_zipline python=3.10 | |
Now you have set up an isolated environment called env_zipline, a sandbox-like structure to install Zipline. Then you should activate the conda environment by using the command | |
$ conda activate env_zipline | |
You can install Zipline by running |
This file contains 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
Conda Error | |
`conda error error: argument COMMAND: invalid choice: 'activate'` | |
# solution | |
`conda init powershell` |
NewerOlder