cryptocurrency – binance macd script in python language

def initialize(state):
    state.counter = 0



@schedule(interval="1h",symbol="BTCUSDT")





if state.counter < 4:
state.counter += 1
Else:
state.counter = 0

 if counter == 4: (every four hours)




macd = data.macd(12,26,9)
signalLine = macd(‘macd_signal’)



- Check if bot has position

has_position = has_open_position(data.symbol, truncated=True)









import numpy as np










def initialize(state):

state.counter = 0




@schedule(interval="1h", symbol="BTCTUSD")

def handler(state, data):




angle = 0




macd_ind = data.macd(12,26,9)




if macd_ind is None:

return




signal = macd_ind('macd_signal')





has_position = has_open_position(data.symbol, truncated=True)

balance_base = float(query_balance_free(data.base))

balance_quoted = float(query_balance_free(data.quoted))

buy_amount = balance_quoted * 0.80 / data.close_last







plot("signal",signal(-1),"BTCTUSD")




if state.counter < 4:

state.counter += 1

else:

state.counter = 0




if state.counter == 4:





lastsignals = signal(-4:)




# calculating the slope of last 4 candles

slope = (lastsignals(-1) - lastsignals(0)) / 3

angle = np.rad2deg(np.arctan(slope))




print("slope: ",slope)

print("angle: ",angle)

plot("angle of signal",angle,"BTCTUSD")




if angle > 30 and balance_base<buy_amount:

print("-------")

print("Checking for buying possibility of {}".format(data.symbol))

print("buy amount:",buy_amount)

print("buy price:", data.close_last)




create_order(symbol=data.symbol,amount = buy_amount)




elif angle < -30 and has_position:

print("-------")

print("Checking for selling possibility of {}".format(data.symbol))

print("sell amount:",balance_base)

print("sell price:",data.close_last)

close_position(data.symbol)

The first state.counter = 0 should be indented. But aside from that I have this error message:

> Engine error:   File "bot.py", line 19.
> Engine error:     if state.counter < 4:.
> Engine error:      ^.
> Engine error: SyntaxError: invalid syntax.
>   File "bot.py", line 19
    if state.counter < 4:
     ^
SyntaxError: invalid syntax

The script is meant to be used on binance for automated trading. The point is to look at the slope of macd line on a 4 hour macd candle interval. This was given to me as a pseudo code so I guess there are some things that need to be changed. Thank you

How to speed up script compilation?

Is there a way to speed up script compile time when I change something in VS then click on Unity?

It takes 15 seconds. Is this normal?

unity – Coroutine different behaviour when called from another script

I am quite new with game dev, specially with unity. In order to understand how it works, I decided to start small with a pong game.

I have a Ball script, which in the Update() method move the ball depending to the speed, and if a player score, it increment a score field and reset the ball to the center (and stop the ball for 2 seconds) trough a coroutine function.

Ball script:

public class Ball : MonoBehaviour
{
    (SerializeField)
    float speed;
    int isMoving = 1;
    float radius;
    Vector2 direction;
    Vector2 startPosition;

    // Start is called before the first frame update
    void Start()
    {
        direction = Vector2.one.normalized;
        radius = transform.localScale.x / 2; // half the width
        startPosition = new Vector2(transform.position.x, transform.position.y);
    }

    // Update is called once per frame
    void Update()
    {
        transform.Translate(direction * speed * isMoving * Time.deltaTime);

        if (transform.position.y < GameManager.bottomLeft.y + radius && direction.y < 0) {
            direction.y = -direction.y;
        } 
        if (transform.position.y > GameManager.topRight.y - radius && direction.y > 0) {
            direction.y = -direction.y;
        }

        // Ball go in any goal
        if (transform.position.x < GameManager.bottomLeft.x + radius && direction.x < 0) {
            GameManager.instance.addScorePlayer("p2");
            StartCoroutine( Reset() );
        } 
        if (transform.position.x > GameManager.topRight.x - radius && direction.x > 0) {
            GameManager.instance.addScorePlayer("p1");
            StartCoroutine( Reset() );
        }
    }

    IEnumerator Reset() {
        isMoving = 0;
        transform.position = startPosition;

        yield return new WaitForSeconds(2);

        isMoving = 1;
    }
}

This works as expected! The score is incremented, the ball go back to the center, wait for 2 seconds and start to move again.
However, now I want to call the Ball Reset() method trough my GameManager (because I want to code some logics inside the GameManager).

So here are my modifications:

Ball script: (remove Reset() calls and update Reset() method to public)

public class Ball : MonoBehaviour
{
    ...

    // Update is called once per frame
    void Update()
    {
        ...

        // Ball go in any goal
        if (transform.position.x < GameManager.bottomLeft.x + radius && direction.x < 0) {
            GameManager.instance.addScorePlayer("p2");
        } 
        if (transform.position.x > GameManager.topRight.x - radius && direction.x > 0) {
            GameManager.instance.addScorePlayer("p1");
        }
    }

    public IEnumerator Reset() {
        isMoving = 0;
        transform.position = startPosition;

        yield return new WaitForSeconds(2);

        isMoving = 1;
    }

GameManager script:

public class GameManager : MonoBehaviour
{

    public Ball ball;

    ...

    void Start()
    {   
        ...

        // Create ball
        Instantiate (ball);

    }

    public void addScorePlayer(string player) {

        if (player == "p1") {
            score1 += 1;
            score1Text.text = score1.ToString();
        }
        else if (player == "p2") {
            score2 += 1;
            score2Text.text = score2.ToString();
        }

        StartCoroutine( ball.Reset() );
    }

This doesn’t work for some reason. The ball don’t come back to the center, and the score increment infinitely.

I have tried many things and I have figured out that the behaviour is the same as running the Reset() method trough the Ball script without the StartCoroutine.

So it seems that the Coroutine don’t work properly if called trough the GameManager ?
I have also printed some logs into my console in the Ball.Reset() method, and the method is being called, so I don’t understand why the ball don’t go back to the center.

(Link to my public github repository https://github.com/Sewake/Unity2D-Pong)

macos – How can I make a script containing passwords secure?

I have made a simple script :

sysadminctl -adminUser AdminUserHere -adminPassword AdminPasswordHere -addUser NewUserNameHere -fullName "Full Name Here" -password NewUserPasswordHere

Now the system in which this script is need to run will deploy by an MDM. So I need to encode/encrypt/hash the AdminPassword (it can be in script or as argument).

Get ItemChild properties using Powershell Script SharePoint 2013 document library

We have a document library which contains multiple document set we have below requirements :

  1. Get all document set properties like Name, Created Date, Modified date.
  2. Get all ItemChild (document present inside the document set) properties Name, Created Date, Modified date.

We are able to get document set properties but unable to get ItemChild properties, any lead much appreciated, Please find my below code.

Add-PSSnapin "Microsoft.SharePoint.PowerShell"

$web = Get-SPWeb "Site URL"

$list = $web.Lists("ENERGY")


foreach ($listItem in $list.Items)
{
$CabinetName = $listItem('Name')
$CabinetCreateDate = $listItem('Created')
$CabinetModifiedDate = $listItem('Modified')
$CabinetChildItemCount = $listItem('ItemChildCount')

   Write-Host "    Cabinet Name: " $listItem.Name "  Modified: " $CabinetModifiedDate "Cabinet ChildItem Count" $CabinetChildItemCount "Created Date:" $CabinetCreateDate

}
$web.Dispose ()

ubuntu – Ruby program start from console but fail from service & shell script

I’m a developer.
I have a ruby program and I have to launch it as daemon.

This program has a shell script

#!/bin/bash
dir=$(pwd)
while sleep 60
do
    if pgrep -fa bin/bot >/dev/null
    then
        echo 'works'
    else
     pkill -f bin/bot
        ruby $dir/bin/bot >> $dir/logs/bot.log 2>&1 &!
    fi

    if pgrep -fa mongod >/dev/null
    then
        echo 'mongo works'
    else
        mongod --fork --logpath /var/log/mongod.log
    fi
done

I’m not the author.
I fix the ruby script.

If I launch in console from the right folder

ruby $dir/bin/bot >> $dir/logs/bot.log 2>&1 &!

The script works.

When I use the shell script in a service I have ‘mongo works’ but my ruby process fail.
Why?

windows – how to run powershell script so that it affects all users on a device

i need to be able to log in as an administrator and run a powershell script so that it affects all users registry keys.

i have a powershell script that fixes the TWINUI issue. It resets the corrupted registry keys of a users defualt apps back to standard. it only really seems to work if the user is temporarily made a local admin on the device and run it from that login. Obviously removing their local admin privlages afterward.

this issue seems to crop up constantly and when it happens on one user on a device it happens for multiple users. going through every user on a device can be time consuming. if i could log in as an administrator and run the powershell and it go through all the affected registry keys of all the users it could save us a lot of time.

mac – I want to write a script to open a fixed URL + whats in the clipboard. Ex: Open Safari to Url+clipboard contents “https://site.com/clipboard contents”

Will this applescript work?

Tell Application "Safari" to open location
"http://www.site.com/"
end tell

Tell Process "Safari"
   Keystroke "l" using command down

Tell application "System Events" to key code
124 using command down

Tell Process "Safari"
   Keystroke "v" using command down
   Keystroke return
end tell

web application – Is running bash script that is taking arguments from site dialog box a good idea?

I’m building a site that will use youtubeAPI to keep track of playlist changes.
In order for 3rd party to use it I would supply a dialog box in which user would type his/hers playlistID – this would be read and then put as an argument into bash script that in turn runs curl/python scripts to connect with API (ran on my machine) and another bash script that would mkdirs on my disk.

Does this potentially endanger me/my files somehow ?
Can someone input some magic command that would do “rm * -f” or similar malicious endeavor ?
Should I use some external server instead of my machine ?

I know nothing about security, Ive read few topics here but didnt find similar problem.

Criar um script (batch) para calcular um bonus de venda de 5% (5/100) de uma loja em relação ao mês anterior. (inf: vendedor, março, abril e bonus)

Vendedor
Vendas no mês de março
Vendas no mês de abril
Bônus 5% (5/100)