Skip to content

Instantly share code, notes, and snippets.

View AjiteshBD's full-sized avatar
🎯
Focusing

Ajitesh Mishra AjiteshBD

🎯
Focusing
  • Mumbai
View GitHub Profile

Portfolio Rebalancing Script

This project provides a script (rebalancing_portfolio.py) to help rebalance cryptocurrency portfolios based on target allocations.

Features

  • Automatically fetches wallet balances and market prices.
  • Rebalances the portfolio by placing buy or sell orders on the exchange.
  • Logs all transactions and portfolio changes into a PostgreSQL database.
  • Operates on a configurable schedule (every hour by default).
@AjiteshBD
AjiteshBD / metadata.json
Last active September 18, 2023 18:00
New Project
{"valueParameterInfo":[["Collateral amount",{"valueParameterFormat":{"contents":[6,"₳"],"tag":"DecimalFormat"},"valueParameterDescription":"The amount of Lovelace to be deposited by both parties at the start of the contract to serve as an incentive for collaboration."}],["Price",{"valueParameterFormat":{"contents":[6,"₳"],"tag":"DecimalFormat"},"valueParameterDescription":"The amount of Lovelace to be paid by the _**Buyer**_ as part of the exchange."}]],"timeParameterDescriptions":[["Collateral deposit by seller timeout","The deadline by which the _**Seller**_ must deposit the _**Collateral amount**_ in the contract."],["Deposit of collateral by buyer timeout","The deadline by which the _**Buyer**_ must deposit the _**Collateral amount**_ in the contract."],["Deposit of price by buyer timeout","The deadline by which the _**Buyer**_ must deposit the _**Price**_ in the contract."],["Dispute by buyer timeout","The deadline by which, if the _**Buyer**_ has not opened a dispute, the _**Seller**_ will be paid."],["
const ethers = require('ethers');
const privateKey = 'YOUR_PRIVATE_KEY';
// Define the contract ABI and address
const contractABI = [
// Define your contract's ABI here
];
const contractAddress = 'YOUR_CONTRACT_ADDRESS';
// Define the contract instance
export type supply = {
owner: PubKey,
supply: bigint
}
export type TokenSupply = HashedMap<bigint, { [key: string]: supply }>
// a basic ERC1155-like non-fungible token
export class Niftyco1155 extends SmartContract {
@prop()
import {
assert,
hash256,
HashedMap,
method,
prop,
PubKey,
Sig,
SigHash,
SmartContract,
import {
assert,
hash256,
HashedMap,
method,
prop,
PubKey,
Sig,
SigHash,
SmartContract,
import { Erc721 } from './erc721'
const alicePubKey = new PubKey(
'03be49c232b2e39070c1e6e660a452c0427c9ac9f99d7ce8ddbc8a1a6e5aa6a68a'
)
const bobPubKey = new PubKey(
'03d7e068bf2dce1277f9873b3a937dbf57646b8f1c6dc85849ef4f6944e4bfa43e'
)
const tokenId = BigInt(123)
const bitcoin = require('bitcoinjs-lib');
const fetch = require('node-fetch');
// Define testnet transaction ID and output index
const txid = '48e7110f6fb0b6d7f6a2f0b88ea779f3b3ba3c53450b08c6b7c6f71e6c7e6dc2';
const outputIndex = 0;
// Fetch testnet transaction data
fetch(`https://api.blockcypher.com/v1/btc/test3/txs/${txid}?includeHex=true`)
.then(response => response.json())
Fetching transaction id:8bae12b5f4c088d940733dcd1455efc6a3a69cf9340e17a981286d3778615684
OP_RETURN data: charley loves heidi
@AjiteshBD
AjiteshBD / decode
Last active February 24, 2023 04:40
const bitcoin = require('bitcoinjs-lib');
const fetch = require('node-fetch');
// Define transaction ID and output index
const txid = '8bae12b5f4c088d940733dcd1455efc6a3a69cf9340e17a981286d3778615684';
const outputIndex = 0;
// Fetch transaction data
fetch(`https://blockchain.info/rawtx/${txid}?format=hex`)
.then(response => response.text())